Page 1 of 1
fd.field('Title').value() delivers ID
Posted: 06 Sep 2017
by wdeffner
In a form we are using:
var status = fd.field('Test').control().value();
to get the value of the lookup-field "Test". This has been working fine for some time, but now status contains the ID of the lookup-field.
Ist it possible to get the shown content of the lookup-field?
Thanks, Wolfgang
Re: fd.field('Title').value() delivers ID
Posted: 06 Sep 2017
by Nikita Kurguzov
Hello, Wolfgang!
If you want to get Text, try this instead:
Code: Select all
fd.field('Lookup').control('getSelectedText');
Re: fd.field('Title').value() delivers ID
Posted: 06 Sep 2017
by wdeffner
Sharepoint can drive you crazy:
Now fd.field('Test').control().value() delivers the text I need and
fd.field('Lookup').control('getSelectedText'); delivers nothing
On our test-system with identical lists the second code worked fine.
Looks like we will have to check every morning ...
Thank you, Wolfgang
Re: fd.field('Title').value() delivers ID
Posted: 06 Sep 2017
by wdeffner
... and another observation:
in display mode fd.field('Test').control().value() delivers the text I need
when I switch to edit mode
fd.field('Test').control('getSelectedText') delivers the text I need
Wolfgang
Re: fd.field('Title').value() delivers ID
Posted: 06 Sep 2017
by Nikita Kurguzov
What do you mean by display/edit mode? Can you include screenshots for us to understand better?
Re: fd.field('Title').value() delivers ID
Posted: 06 Sep 2017
by wdeffner
Hi Nikita,
I meant the change from the display form to the edit by clicking on Edit in the ribbon.
I placed both functions in the javascript code and have added an alert to show the values they deliver.
The alert shows these results when show the item (display form):
"GS" ist the text of the lookup-field that I need
When I click on "edit" in the ribbon, the alert shows these results (edit form):
Thank you, Wolfgang
Re: fd.field('Title').value() delivers ID
Posted: 06 Sep 2017
by Nikita Kurguzov
Ah, you are talking about different Forms, I see. Of course, that's because on Display form, it is not an actual Lookup, the field simply displays information, so it requires different code.
But on other Forms - New and Edit, you need to use fd.field('Lookup').control('getSelectedText'); to get text from an actual Lookup.
Re: fd.field('Title').value() delivers ID
Posted: 06 Sep 2017
by wdeffner
Ok, understood.
I handle it this way:
var status = fd.field('Schulform').control().value();
var status2 = fd.field('Schulform').control('getSelectedText');
if (status2 == "") {
// alert ("Status2 is empty")
}
else {
status=status2}
Thanks, Wolfgang