Page 1 of 1

Lookup column issue

Posted: 30 Nov 2017
by jacob
Hi,

I downloaded and installed a trial of forms designer and cross-site lookup. I have two lists. One list with hardware details, and one list with issues. In the issue list i created a lookup column to the hardware list like this:
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Serienr_x0020_apparaat,Medewerker/Title&$expand=Medewerker&$orderby=Created desc&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Serienr_x0020_apparaat,Medewerker/Title&$expand=Medewerker&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "') or " +
"startswith(Medewerker/Title, '" + encodeURIComponent(term) + "') or " +
"startswith(Serienr_x0020_apparaat, '" + encodeURIComponent(term) + "')&$top=10";
}
function(item) {
return '<span class="csl-option">' + item["{LookupField}"] + ' / ' + item["Medewerker"].Title + ' / ' + item.Serienr_x0020_apparaat + '</span>'
}
This works fine when adding a new item. However when i display the item, the lookup column says #WAARDE!
Second problem (probably related): i get an error when i try to edit the item
You are using the trial version of Forms Designer. Please, visit http://spform.com to buy it.
Dit webonderdeel kan niet worden weergegeven. U kunt proberen dit probleem op te lossen door deze webpagina te openen in een met Microsoft SharePoint Foundation compatibele HTML-editor zoals Microsoft SharePoint Designer. Neem contact op met de webserverbeheerder als dit probleem zich blijft voordoen.


Correlatie-id:e7ea319e-b21c-b0d2-9220-efc10900770a
What am i doing wrong?

Re: Lookup column issue

Posted: 30 Nov 2017
by Nikita Kurguzov
Hello, Jacob!
That's actually a very good configuration, especially for someone who is just getting to know the apps. I've recreated your lists with how I assumed they work, at least with relation to this lookup field, and didn't get any issues at all using the same code.

As you can see, here is my Edit Form:
EditForm.png
EditForm.png (4.74 KiB) Viewed 11915 times
And my Display Form:
DisplayForm.png
DisplayForm.png (4.03 KiB) Viewed 11915 times
There still might be some issues though, since it doesn't seem to work for you, but it doesn't seem connected to this code.
First of all, can you tell me which version of SharePoint you are using?

Re: Lookup column issue

Posted: 30 Nov 2017
by jacob
We are using SharePoint 2016 on premisses with the Nov update installed.
My lookup column is pointed to a custom field which is not unique. Is that a problem?

Re: Lookup column issue

Posted: 30 Nov 2017
by Nikita Kurguzov
Depends on the type of the field. Is it supported by the regular lookup?

Re: Lookup column issue

Posted: 30 Nov 2017
by jacob
Yes, it's a choice field.

Re: Lookup column issue

Posted: 30 Nov 2017
by Nikita Kurguzov
Unfortunately, Choice Field is not supported by Lookups. Neither Cross-site Lookup, nor SharePoint default Lookup.
Same is true with Person or Group field, for example.

There is an option to choose these fields in Cross-site Lookup, but that's more of a program limitation that it doesn't filter out unsupported fields. Fields that are supported by default Lookup are also supported by Cross-site Lookup + it offers advanced scripts and actually works across different sites, but it still doesn't support fields like Choice, Person or Group, etc.

And yes, that's exactly the reason for the errors, as I've managed to reproduce them with Choice field as well.

Re: Lookup column issue

Posted: 30 Nov 2017
by jacob
Ah, that explains it. Thanks for the info!

Re: Lookup column issue

Posted: 30 Nov 2017
by jacob
I changed the lookup field to a custom text field and it works perfectly now. Thanks!