ServiceNow Record Producer Caveats

September 25, 2014 • ServiceNow

I recently ran into a problem when using Record Producers. In the script for the Record Producer I am using the applyTemplate function on the current GlideRecord. The template used varies, which is why I can’t use the template field on the Record Producer. I kept ending up with duplicate task records with the exact same value in the number field.

After some tinkering I came to the conclusion that the applyTemplate method causes an insert, and that the Record Producer also does an insert after running the Record Producer script. After a lot of frustration I was looking through the Sandbox instance of ServiceNow when I noticed that the New LDAP Server inserted the current GlideRecord and they used the setAbortAction method. So I decided to give that a try.

Here is what I ended up with at the end of my Record Producer:

current.update();
current.setAbortAction(true);

This works because the insert done by the Record Producer is aborted, and thus stops the duplicates.


Jason Butz's profile picture

Jason Butz is a software engineer and cloud architect with a strong focus on JavaScript, TypeScript, Node, and AWS. Jason has a love for open-soure software and a passion for building scalable, secure, and reliable applications.