Business Rule to copy a string field's value into another journal field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 02:03 AM
I have a "u_description" field (String) and would like make it show the change history of the populated value just like journal field as below.
Since I can't change the existing field type, I came up with the idea to create another journal field and copy "u_description" value into the new journal field using after/update Business Rule.
However, the BR I created does not populate any value into the journal field... Could you please help me with troubleshooting?
Otherwise, any alternative solutions would be appreciated if any.
*Filter Conditions: [u_description] [changes]
*Script:
(function executeRule(current, previous /*null when async*/) {
var Comment = current.u_description;
current.u_journal_field = Comment;
})(current, previous);
Best Regards,
Aki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 02:19 AM
hello @Aki18 can you try this script ?
As you are not trying to update the form may be its not updating it
function executeRule(current, previous /*null when async*/) {
var Comment = current.u_description;
var gr = new GlideRecord('your_current_table_name');
gr.addQuery('sys_id',current.sys_id);
gr.query();
if(gr.next())
{
gr.u_journal_field = Comment;
gr.update();
}
})(current, previous);
Hope this helps
Mark the answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 02:19 AM
Hi @Aki18
For this, you don't need any extra field or any Business Rule or any kind of scripting.
You just have to add 'Description' field on your Activity Log fields as below:
Once you add 'Description' field.
Any changes to Description value will be captured in Activities as below:
This would be more preferred then adding it as work notes to make it more easy to Audit and Track.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 06:11 PM
Hi @AnubhavRitolia ,
Thank you for the information, but the Description value change was not captured in Activities on Service Portal table page...
*It was captured when tried on Classic (Platform) UI, but not on Portal. Could you give me your advice?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 02:21 AM
Hi @Aki18
If you want to implement it with After/Update Business Rule, find code below:
Filter Conditions: [u_description] [changes]
var cmt = current.u_description.toString();
current.u_journal_field = cmt;
current.update();
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023