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,

please don't use GlideRecord in client script as it is not best practice

Also avoid DOM as this may lead to issue going in future during upgrade etc

Regards
Ankur

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

Hi ,

I have done this disable the ui action (form link)

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);
document.getElementById('8b6441e5db629410a2c89cd5ca9619b2').disabled = true;


}

its not working

Suseela Peddise
Kilo Sage

Hi,

It is not recommended to hide UI action using client scripts or UI policies.

You can use UI action condition to show or hide button on the form. 

If you still require , see the below link

https://community.servicenow.com/community?id=community_blog&sys_id=127d6269dbd0dbc01dcaf3231f961973

 

Hope this helps!

If I have answered your question, please mark my response as correct and/or helpful.

Thanks,

Suseela P.

Hi ,

I had been thru this post unfortunately I was not able to access the class name or the action name or the id . can you please me

Hi Shruthi,

Have you tried putting any alert message to see the script is running?

Share the script that you were trying.

 

Thanks,

Suseela P.