How to get "sys_id" from a Document Id field and set that "sys_id" into a reference field.

Swaroop10
Giga Contributor

How to get "sys_id" from a Document Id field and set that "sys_id" into  a reference field.

I have written the below script,

var display = current.trigger_id.getDisplayValue();
var number = display.split(' ')[1];
current.u_interaction.setDisplayValue(number);
current.update();

It was returning the "number" from the "trigger_id" field properly and getting that number displayed in the "u_interaction" reference field.

find_real_file.png

Instead of the "Number" getting populated in "u_interaction" field, sys_id should get populated in that field, how to get sys_is populated instead of number.

 

 

Thanks & Regards,

S.Swaroop.

6 REPLIES 6

Jaspal Singh
Mega Patron
Mega Patron

Hi Swaroop,

 

Try using,

current.trigger_id.sys_id; 

instead of 

current.trigger_id.getDisplayValue();

There are couple of options that document field support with .sys_id being one of those. This will give you sys_id of the record directly.

Hello Jaspal,

Thanks for the quick reply,

When i am using the below script, number is getting populated in the "u_interaction" field, but i want sys_is to be populated, which is not getting populated. Below is the script i am using.

var number = current.trigger_id.sys_id;
current.u_interaction.setDisplayValue(number);
current.update();

Can you please rectify me if i am doing mistake anywhere in the above script.

 

 

Thanks & Regards,

S.Swaroop.

Try using below.

var number = current.trigger_id.sys_id;

gs.log('Sysid is ',number);
current.u_interaction=number;
current.update();

Hello Jaspal,

Still it was returning the "number" of the ticket, not populating with "sys_id".

 

 

Thanks & Regards,

S.Swaroop.