ServiceNow Brings Real-time Simultaneous Updates in UI16 for Geneva (and some Interesting Results)

Realtime Update Icon

I was recently working with a colleague at Crossfuze (BIG shout out to Eric LeMonnier who found the solution for this) on a weird issue in Geneva. His onChange Client Scripts were triggering even though he wasn’t updating those fields. Upon closer examination it was because another user had modified the same record he was on for a field that his onChange Client Script was looking at (this is what triggers the blue icon seen above). This happens because ServiceNow has added a capability to handle multiple-users updating the same record at the same time, and as a result the fields will change dynamically as other users are updating the form. While this is a very nice feature, and handles the simultaneous update issue that used to occur, there may be some use cases where this is not a desired result. One of the downsides to this behavior is that ServiceNow does not upate “.modifiedFields” (g_form.modifiedFields) and thus it does not appear possible to find out if another user has changed a field using any of the g_form API “published” methods. In order to work around this, we found that it is possible to detect the change using an internal method “_internalChange”. Here is what an onChange script would look like, it will return true or false if it’s an internal or client update and if there hasn’t been a real-time update then it will return “undefined”:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '' || g_form._internalChange)
return;
}

Please Note: This script should only be used in a limited fashion as it does use a non-published/internal method of g_form, called “_internalChange”. While this does work currently (Geneva Patch 4), it is possible that ServiceNow could change this method later (perhaps publishing it and calling it “.internalChange”) and this script would need to be updated in any areas it has been used.

Please let me know your thoughts and comments. Happy Coding!

Leave a Reply

Your email address will not be published. Required fields are marked *