how to validate if the Field value set/modified by Template.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 02:46 AM
Templates are applying using Apply Template option. I could see an message showing that Field modified by Template for the fields which are modified by Template . I want track those Fields. I was able to get the Template name which has applied but with this not able to confirm if Field value set/modified by Template.
Thanks,
Rajesh T

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 05:36 AM
Hi Rajesh,
The onChange client script has a parameter called isTemplate. It can tell you if a field has changed as part of a template being applied.
Client Scripts - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 10:03 AM
HI Chuck,
I have tried for Time worked field if it is modified/set by Template , but not working as expected.
It is working for other Fields like Short description etc . I have made onLoad() client script to stop Timer while Loading.
I suspect , although we stop Timer, still it is taking some time to paused Timer which is why it is not showing that modified by Template even though Template set/modified the Time.
To confirm that , made script as below.
OnChange script on Time worked Filed
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if(isTemplate || newValue !='' )
{
alert('this is alert if time worked value modified by Template');
}
}
This alert always giving me even we paused time on Loading.
Can you please check it from your end and let me know your thoughts.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 03:16 PM
Hi Rajesh,
Can you show me an example of what your timer field looks like in the template?
Whether the timer is paused or not doesn't make a difference if you are setting a value from the template, both of these conditions are going to be true, which makes the if condition true.
if (isTemplate - says 'if I set this value from a template, which you did
|| - OR
newValue != '')
You set a new value which means this is true also.
I'm not clear what the issue is so I cannot tell you if you need to modify the script or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2017 02:04 AM
Sorry Chuck if i am confused you.
Here is the Template which has Time worked value .
If i apply above Template on INC form, those Field values are setting up in the INC form including Time worked .
I wanted to check if the Time worked value set/modifed by Template. For this , i have made onChange() client script on Time Worked.
I am not getting alert when applied the Template which has Time worked value.
However, if i made same script on other Fields like Short description, able to see the alert.