- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 06:43 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 07:37 AM
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
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 08:19 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 08:20 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 06:49 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 06:52 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 06:59 AM
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.