fd.field('Title').value() delivers ID

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
wdeffner
Posts: 30
Joined: Thu Sep 22, 2016

06 Sep 2017

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

06 Sep 2017

Hello, Wolfgang!
If you want to get Text, try this instead:

Code: Select all

fd.field('Lookup').control('getSelectedText');
Cheers

wdeffner
Posts: 30
Joined: Thu Sep 22, 2016

06 Sep 2017

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

wdeffner
Posts: 30
Joined: Thu Sep 22, 2016

06 Sep 2017

... 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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

06 Sep 2017

What do you mean by display/edit mode? Can you include screenshots for us to understand better?
Cheers

wdeffner
Posts: 30
Joined: Thu Sep 22, 2016

06 Sep 2017

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):
Image

"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):
Image

Thank you, Wolfgang

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

06 Sep 2017

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.
Cheers

wdeffner
Posts: 30
Joined: Thu Sep 22, 2016

06 Sep 2017

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

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests