- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 02:30 AM
Am trying to update a field inside the current records reference field.Am using the below code and able to get the logs, but data is not getting updated inside the reference record. Could someone please help on this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 02:38 AM
Unless you have the glideRecord object of the record you cannot set the field value
try this
var a2 = new GlideRecord ('ast_contract');
a2.addQuery('parent_contract',current.parent_contract);
a2.orderByDesc('u_import_sync');
a2.query();
if (a2.next())
{
gs.info("inside if");
var b = a2.u_import_sync;
var ref = current.parent_contract.getRefRecord();
ref.setValue('u_import_sync',b);
ref.update();
}
gs.info("done");
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 02:38 AM
Unless you have the glideRecord object of the record you cannot set the field value
try this
var a2 = new GlideRecord ('ast_contract');
a2.addQuery('parent_contract',current.parent_contract);
a2.orderByDesc('u_import_sync');
a2.query();
if (a2.next())
{
gs.info("inside if");
var b = a2.u_import_sync;
var ref = current.parent_contract.getRefRecord();
ref.setValue('u_import_sync',b);
ref.update();
}
gs.info("done");
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 02:45 AM
Thank you so much for the quick help.It worked !!