Business Rule to update Comments with Close Notes

cnharris1
Kilo Sage

Good morning everyone,

I'm trying to write a business rule that updates the Comments (Customer Visible) field with the information provided in the Close Notes field once the technician decides to resolve the ticket. I know this information can be seen in the Activity, however, I need the Comments field to be updated with the Close Notes field for my organization. I have provided a copy of my script, which should be simple but I'm having some trouble. The script is on the Incident table and runs on an update after Close Notes is not empty (I think that's correct):

(function executeRule(current, previous /*null when async*/) {
 current.comments = current.close_notes.getDisplayValue(); 
})(current, previous);

 

Any help will be greatly appreciated!

Best regards,

cnharris

1 ACCEPTED SOLUTION

cnharris1
Kilo Sage

Thanks Prateek! I tried using the code and it does work but it just doesn't work on the comments field for some reason. I think it has something to do with that field being an array but I'm not too certain. I did find a workaround to my problem and I provided the link below:

https://community.servicenow.com/community?id=community_question&sys_id=9997c7a9db1cdbc01dcaf3231f961933&view_source=searchResult

 

View solution in original post

8 REPLIES 8

dvp
Mega Sage
Mega Sage

Is it a before business rule and also is the update field set to true?

find_real_file.png

Yes sir, it is a business rule and I have the update field set to true.

I don't see anything wrong in the script. There might be a rule that is stopping this from execution.

Check if there is any setWorkflow(false) in any of the business rules on incident table.

Also, can you try by adding some log statements or addInfoMessage to see whether it is running or not

Thanks dvp,

I checked and I didn't have anything that would prevent the rule from running. The code does work because I used it on a different field but for some reason, I couldn't get the comments to work. I did find a workaround to my problem...I provided the link below:

https://community.servicenow.com/community?id=community_question&sys_id=9997c7a9db1cdbc01dcaf3231f961933&view_source=searchResult