- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2019 11:37 AM
Hello All,
I want to hide an UI Action button by using client script or UI policy instead of ui action condition builder?
I have created below client script and UI policy but not working as expected
note: I am working on LONDON version
function onLoad() {
//Type appropriate comment here, and begin script below
var items = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('add_to_store') > -1){ //my UI action name is "add_to_store" and also I have used front name "Add To Store" also but didn't work.
alert("true");
item.hide();
}
else{alert("false");}
});
}
Ui Policy
function onCondition() {
//$$('#add_to_store')[0].show(); //This will hide the top button
//$$('#add_to_store')[2].show(); //This will hide the bottom button as well
var buttons = document.getElemetsByClassName("form_action_button header action_context btn btn-default");
for(var i=0;i<buttons.length;i++){
if(buttons[i].id == "add_to_store"){
buttons[i].hide();
}
}
}
_______
function onCondition() {
//$$('#add_to_store')[0].hide(); //This will show the top button
//$$('#add_to_store')[2].hide(); //This will show the bottom button as well
var buttons = document.getElemetsByClassName("form_action_button header action_context btn btn-default");
for(var i=0;i<buttons.length;i++){
if(buttons[i].id == "add_to_store"){
buttons[i].show();
}
}
}
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2021 04:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2019 11:52 AM
Set Isolate Script field on client script to false
Below link might be helpful
https://community.servicenow.com/community?id=community_blog&sys_id=c5c46364dbba6b007d3e02d5ca9619cb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2021 04:53 AM
Just put the Action name in hide function
hide('btn_assess');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 08:07 AM
It solved one of my problems today, thank you.