Get yes/no value from control lookup field

I'll try and then I'll let you know.
Thank you @Nikita_Kurguzov .

Hello @Nikita_Kurguzov ,
Does it possible get a value form a list that isn't in the same site
My list is in a subsite and must retrieve value from a field in a list that is in the parent site.
Thank you.

Dear @stefano.mazzi,
Yes, it's possible, you need to define new web for it:

//specify your site URL
var siteURL = 'https://sitename.sharepoint.com/sites/Main/';
let web = new Web(siteURL);

web.lists.getByTitle("ListName").items.select('Expiration').filter("ID eq '2'").get().then(function(items) {
   console.log(items[0].Expiration);
});
1 Like

Dear @Nikita_Kurguzov ,
sorry but I don't understand how I must compose the entire code.
Can you write me a complete example?
Thank you very much.

maybe I made it :wink:
I'll let you know asap.
thank you

Your code works great! THANK YOU!
Last question, I want retrieve the lookup id value from the control lookup field in display mode and I can't get the value with fd.control(DocumentType).value.LookupId.
I must made in this way:

fd.spRendered(function() {

var displayValue = fd.control('DocumentType').displayValue;
var displayValueObj = JSON.parse(displayValue);
var id = displayValueObj.id;
var strFilter = "ID eq " + id;
console.log("strFilter = " + strFilter);

//specify your site URL
var siteURL = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
let web = new Web(siteURL);

web.lists.getByTitle("Matrix").items.select('Expiration').filter(strFilter).get().then(function(items) {
   console.log('Expiration = ' + items[0].Expiration);
   varExpiration = items[0].Expiration;
   
   if (varExpiration == true) {
            // Show Expiration
            fd.field('Expiration').hidden = false;
        } else {
            // Hide Expiration
            fd.field('Expiration').hidden = true;
        }
});

But, if I check the value of console.log(fd.control('DocumentType')); I can see all the value that I need.

Is there another way to get this value in display mode?
Thank you.

Dear @stefano.mazzi,
This is the correct way, you're right.

var id = JSON.parse(fd.control('DocumentType').displayValue).id;
1 Like

Thank you so much @Nikita_Kurguzov !!!

1 Like