Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to Call UI action in client script

Shruthi2
Kilo Contributor

Hi,

I have to hide a Ui action on the change form on change of the configuration item. How do I refer to the UI action in the on change client script of the configuration item field.Please help me out

 

Thanks,

Shruthi.

1 ACCEPTED SOLUTION

Hi Shruthi,

Did you set this field to false?

Isolate Script -  false

  • This field is not on form but from list you can make it false
  • by default it is true
  • If that is true DOM won't work

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

17 REPLIES 17

Hi Shruthi,

Did you set this field to false?

Isolate Script -  false

  • This field is not on form but from list you can make it false
  • by default it is true
  • If that is true DOM won't work

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi,

I have tried this still it throws an error saying onChange script error: TypeError: document.getElementByID is not a function 

Isolate script set to false

Client Script:

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

//Type appropriate comment here, and begin script below

var data = g_form.getValue('cmdb_ci');
var agg = new GlideRecord('cmdb_ci');
agg.addQuery('sys_id', data);
// agg.addAggregate('COUNT', 'sys_class_name');
agg.orderBy('sys_class_name');
agg.query();
while (agg.next()) {
var name = agg.getValue('sys_class_name');
//alert(name);
}
//alert(data);
var link = document.getElementById('8b6441e5db629410a2c89cd5ca9619b2');
return false;


}

 

I am unable to disable it

where are you testing it ? native UI ? 

writing glide record in client script is not good approach. also i would suggest to avoid DOM as much as possible.