How can we update reference field value on table using Glide Record?

Harshal Sonawa1
Kilo Guru
contractNumber = 'FSD1111';
gr.setValue('u_contract', contractNumber);
gr.update();
 
I m trying to update using setValue() but its not working
1 ACCEPTED SOLUTION

Hi @shloke04 ,

Thanks a lot for helping and having patience. Finally, I am able to resolve this.

ac.update() will not work for saving(updating) values in table for reference field.

ac.updateWithReferences(); is correct method for it.

 

View solution in original post

18 REPLIES 18

Ct111
Giga Sage

reference field require you to set "sys_id".

contractNumber = 'FSD1111';
gr.setValue('u_contract', 'sys_id_of_contractnumber');
gr.update();

 

Mark my ANSWER as CORRECt and HELPFUL if it helps

 

if you don't know what sys_id is check this link

https://www.servicenowelite.com/blog/2020/9/29/ten-methods-to-find-sysid

I did same as u suggested but getting one error .

Unable to find workflow version for 0f670c8e1b23fb00b80e86ae6e4bcb0f (user=7e7721e4dbc04910347766d4059619ed)

I m running background script.

Alok Das
Tera Guru

Hi Harshal,

You can try using setDisplayValue() instead of setValue(), something like below:

var contractNumber = 'FSD1111';
gr.setDisplayValue('u_contract', contractNumber);
gr.update();

 

Kindly mark my answer as Correct and Helpful based on the Impact.

Regards,

Alok

will try it