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 replace DOM manipulation technique from client script

keerthi19
Tera Guru

Hi,

Anyone have any idea about replacing DOM manipulation form script. Actually while reviewing code, servicenow asked us to replace DOM manipulation form few script. But I couldn't find any way to replace it. Can anyone aware of it.Please help.

This is Onchange client script. 

if(newValue=="rejected_solution" || newValue=="proposed_solution"){
var items1 = $$('BUTTON').each(function(item){  ///// How to replace this line and call the button
//if(item.innerHTML.indexOf('Reopen Incident') > -1){
//item.hide();
//}
if(item.innerHTML.indexOf('Resolve Incident') > -1){
item.hide();
throw $break; //Exit after hiding the first 'Resolve Incident' button
}

The above highlighted line is the problem here. How to replace that line form script and modify the code. Anyone have any idea?

2 REPLIES 2

Harsh Vardhan
Giga Patron

the only way is by using server side script. you can define the condition in your ui action this way you can avoid DOM Manipulation .

cmcclendon
Mega Guru

See if you like this technique: Styling UI Action Buttons

I store all of my UI Action properties in one section on the page. This serves as an on page load style sheet.

Chris