Correct syntax for using internal column name?

Discussions about Cross-site Lookup
Locked
kflorian
Posts: 4
Joined: Thu Aug 02, 2018

02 Aug 2018

What is the correct syntax for using internal column name?

The internal column name is _x0030_3

How do I change the default "Request Items" and "Item Format" code to use the internal name instead of the {LookupField}

function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby=Created desc&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "')&$top=10";
}

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

03 Aug 2018

Dear kflorian,
Do you want to use this field additionally to the {LookupField} or instead of {LookupField}? If you want to use it instead, there really is no need to manually replace it. Cross-site Lookup automatically replaces {LookupField} with the internal name of the selected field when it sends a request. So, you can just use {LookupField} instead.

If you want to additionally load an extra field, you can add it by its Internal Name to the code, like this:

Code: Select all

function (term, page) {
  if (!term || term.length == 0) {
    return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},_x0030_3&$orderby=Created desc&$top=10";
  }
  return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},_x0030_3&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "')&$top=10";
}
Though this will only load the value, you need to still do something with it to see it anywhere.
Cheers

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

03 Aug 2018

I was wrong, updated answer here - viewtopic.php?f=5&t=2164&p=6894
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests