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

u_interaction is a reference field or is a string field? If reference try setting the value to a string filed it should set sys_id.

Since, for reference it will check for sys_id but will reflect that is used as the Display Value for the record.

MrMuhammad
Giga Sage

Hi Swaroop,

 

Here you go. You don't need to call getDisplayValue() on trigger_id. 

document_id itself holds the sys_id of the record.  Please try below in your business rule and see how it goes. I am using this on Assessment Instance table for driving logic's. Hope this will help.

var display = current.trigger_id;
gs.addInfoMessage("SYS ID - " + display);
current.u_interaction = display;
current.update();

Please mark this accepted & helpful if it answered your question.

 

Thanks,

Sharjeel

 

Regards,
Muhammad