Update the GlideRecord object with Journal fields

General Add comments

A short while ago, while implementing Service-Now for a customer, we experienced behaviour we did not anticipated.
We were creating a mechanism where we could send and receive messages through SOAP Web Services.
While processing the received data, we had to update the work_notes field in the Incident table. In our implementation, work_notes is a ‘journal’ field. We had to loop through some data rows and it was our intention to use one update to write all found data to the record.
We updated the work_notes field directly in the GlideRecord object (as you would normally do) in a loop, using a statement like:

gr.work_note += varString;

The insert statement caused the work_notes field to show as much separate updates in the Activity log as we had loops in the program.

Since this behaviour was unwanted, we solved it by using a variable in the loop instead of the “gr” object.
So, whenever you have multiple updates to a journal field, be aware of this behaviour!

I hope this blog article is helpful. If you have questions, please let me know via email or a response below!

Good luck!
Kind regards,
Fred van der Schaar (.img[at].img)

One Response to “Update the GlideRecord object with Journal fields”

  1. Bas Welman Says:

    Hi Fred

    Just experienced the same thing using a Transform Map script after a SOAP insert from a monitoring system. Was using target.work_note += several times to keep the code tidy but needed to reduce it to a single assignment.

    Thanks for the tip


Leave a Reply