Page 1 of 1

Cross-site field value

Posted: 03 Sep 2015
by SPTech
Hello,

I'm using a cross-site lookup field in one list(A) that looksup a value on another list(B).

On the list A in the new form I am trying to get the value of this lookup field using javascript when user choose a value from this field.

If I try fd.field('CrossSiteLookup').value() I get a number but in the form display name is shown. When I look this column using SP CAML Query Helper I get entries like this, "123;# Display Name". As I said if I use fd.field('CrossSiteLookup').value() I get 123, but I want to get "Display Name". How can I achieve this ?

Thanks in advance.

Re: Cross-site field value

Posted: 03 Sep 2015
by rostislav
Hello! If you have a single-value CSL field use:

Code: Select all

fd.field('CrossSiteLookup').control('data')['Title']
If you have a multi-value CSL field:

Code: Select all

fd.field('CrossSiteLookup').control('data')[index]['Title']
where index is a number starting from 0 that indicates the position of the value in the field you're trying to access Please note, that if you try to access an entry with no Title property (an empty entry), you'll get an exception.

Re: Cross-site field value

Posted: 03 Sep 2015
by SPTech
Thank you for your reply. It is a single value CSL and I have tried fd.field('CrossSiteLookup').control('data')['Title'] and it does not generate an exception but for the value it says "undefined".

Re: Cross-site field value

Posted: 03 Sep 2015
by rostislav
Sorry, I did not mention that Title is the internal name of the target field, so substitute as appropriate.

Re: Cross-site field value

Posted: 03 Sep 2015
by SPTech
Thank you, I was not using the internal name. Changed to code using internal name and it is working now.