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

Catalog Task onChange Client Script for Variable

jevans
Kilo Contributor

Is it possible to create on onChange client script for a variable included on a Catalog Task?

On a request form I have 3 variables (Assignment Group, Department, and Computer Type) which depend on each other to determine if billing is required when a request item is initially submitted. After the initial submission a technician may find information (such as computer type) was incorrectly entered, and they modify it in the task variable editor. This change may have an impact on the billing requirements, but there is no way I can think of to test for it.

I can't seem to create an onChange client script to monitor anything in the variable editor. I've also tried it with a UI policy, but it only works when the Assignment Group field is changed which is not a variable on the Catalog Task. I've even tried adding another event handler even though the Wiki says, "you are strongly discouraged from using this technique to set onSubmit(), onLoad(), or onChange() handlers. Doing so will have the effect of overriding our out-of-box handlers." I was just curious if it would work. It did not. The script always returned "undefined" for the control of the variable when trying:

var control = g_form.getControl('variables.compType');
alert("Control = " + control);

So the additional event handler had no effect.

I was basically able to accomplish what I need by using an onSubmit script. This allowed me to query the values of the necessary variables in the variable editor, so the script could determine the billing requirements. Unfortunately this is really inefficient because the individual updating the ticket will not know the billing requirements before they try to submit. Having literally hundreds of combinations to determine the requirements makes an onChange script basically a necessity.

I've spent a couple of days on this now, so I'm hoping someone may be able to point me in the right direction.

Thanks in advance!

5 REPLIES 5

jevans
Kilo Contributor

Hey tbalestreri3,

b-rad's suggestion worked for me. To access the variable value in the compType variable within the catalog task I was able to use:

var ctrl = g_sc_form.getControl('compType');

Then I was able to create an onBlur event handler the same way the wiki instructed.

I did this as a matter of necessity, but it does sound like an upgrade to Calgary would really make this easier if you're able to perform the upgrade because it allows you to apply onChange scripts to variables inside of Catalog Tasks.

-Joe