Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

I want to hide an UI Action button by using client script or UI policy instead of ui action condition builder????

Shantharao
Kilo Sage

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");}
});
}

 

find_real_file.png

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

1 ACCEPTED SOLUTION

Prabhjot3
Kilo Expert

Just put the Action name in hide function

hide('btn_assess');

View solution in original post

3 REPLIES 3

dvp
Mega Sage

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

Prabhjot3
Kilo Expert

Just put the Action name in hide function

hide('btn_assess');

It solved one of my problems today, thank you.