The CreatorCon Call for Content is officially open! Get started here.

how to return sysid in clientscript in ui builder from a reference field

Raviteja Kunal1
Tera Expert

Hi

I am new to UI builder. How can I return sysid in the UI builder client script from the below code.

 

 const data = api.data.cost_centers_table_data.output.data.GlideRecord_Query.cmn_cost_center._results;
    let cost_item = data.filter((cost) => {
        return cost.sys_id.value == item.id;
    });
  api.setState("funds",  cost_item[0].u_fund); 
 
'funds' is a reference field but cost_item[0].u_fund is not setting sys_id, it is returning displayvalue. How to return sysid of the u_fund.
 
I tired with cost_item[0].u_fund.sys_id and cost_item[0].u_fund.value but it is not working.
 
Thank you.
1 REPLY 1

Sumanth16
Kilo Patron

Hi @Raviteja Kunal1 ,

 

Please refer to below thread:

 

https://www.servicenow.com/community/developer-forum/ui-builder-list-component-fetch-sysid-s-from-se...

 

https://www.servicenow.com/community/developer-forum/unable-to-access-the-reference-field-value-in-u...

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda