The CreatorCon Call for Content is officially open! Get started here.

Template fields values are getting overridden by onchange client script

Dhodda Nagasre1
Tera Contributor

Hi All,

We have templates created for incident table and whenever we select template field values are getting overridden (like assignment group) by Onchange client script.

We have assignment group values set on incident template but assignment group value is not updating from the template when we apply the template and the value getting updated from the client script.

Note:Onchange client script is written on configuration item and script will update the assignment group  whenever there is a change the CI.

Can you please help me to fix this issue.

Thanks in advance.

 

3 REPLIES 3

Yousaf
Giga Sage

Hi,

Did you try to use isTemplate in Client script? 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
...
}

Maybe you can set the condition for client script to run only when
!isTemplate == {Your Template}


Mark Correct or Helpful if it helps.


***Mark Correct or Helpful if it helps.***

Michael Jones -
Giga Sage

Templates are applied once and then done - client scripts will always occur on the specified event, unless you build them in such a way that they are conditional. 

There isn't an easy, out of the box way to do this, but there are some simple work-arounds you could use. 

You would need to either create a new Column on the Incident table, or select an existing one and repurpose it for this, but at a high level I've used something like this in the past. 

Create a true/false field on Incident, named Template Applied, add it to the form, hidden and read-only. 

In your template, set the value of the field Template Applied to be true. 

In whatever client scripts you don't want to trigger once a template is applied, adjust the conditions at the top to something like this: 

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

   //script
   
}

I hope this helps!

If this was helpful, or correct, please be kind and mark the answer appropriately.

Michael Jones - Proud member of the GlideFast Consulting Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Thank you Michael.

I will work on it.