Business Rule to copy a string field's value into another journal field?

Aki18
Tera Contributor

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.

Aki18_0-1668419718045.png

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

5 REPLIES 5

Mohith Devatte
Tera Sage
Tera Sage

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

AnubhavRitolia
Mega Sage
Mega Sage

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:

 

AnubhavRitolia_0-1668420971896.png

 

 

AnubhavRitolia_1-1668421041099.png

 

AnubhavRitolia_2-1668421062061.png

 

Once you add 'Description' field.

 

Any changes to Description value will be captured in Activities as below:

 

AnubhavRitolia_3-1668421157033.png

 

This would be more preferred then adding it as work notes to make it more easy to Audit and Track.

 

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

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?

AnubhavRitolia
Mega Sage
Mega Sage

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();

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023