- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 09:53 PM
Hi Team,
I am trying to update the current record in the workflow run script. When I am trying to use current.update(), workflow giving a warning. So i have removed that line and simple set the value for a field. But the value of the field is not getting update even after the workflow is completed.
Is there any other way to update the current record in workflow? I have tried using "Set Value" activity also, it is not updating the record.
Any suggestions are helpful.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 03:08 AM
Did you try updating the u_status as 4 from background script for that record just for testing?
any before update BR is blocking the update?
try this in workflow run script
current.setWorkflow(false);
current.u_status = '4';
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 10:07 PM
Have you tried with Glide Record to update the current record in run script. You can refer below script for the same.
var currentRecordId = current.getUniqueValue();
var record = new GlideRecord('table_name');
record.addQuery('sys_id', currentRecordId);
record.query();
if (record.next()) {
record.your_field1 = 'values1';
record.your_field2 = 'values2';
record.update();
gs.log('record updated!');
} else {
gs.log('record not found');
}
Thanks!
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 10:15 PM
Hi
Tried like the way you have mentioned. It is not even logging the message.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 10:33 PM
Yesh,
Share your complete script here
On which table workflow is attached?
What should be updated for current record? give example.
Thanks!
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 11:08 PM
Hi
Workflow is running for the x_import_bulk table. I am updating the status of the current record in that table.
current.u_status = '4';
Status is the choice field. That status should be Error, The value of Error is 4. That is the reason I have mention 4 as a string.
Thanks