Is it possible to remove UI action for 'Add all' button on Configuration Item sys pop-up.

piyu
Kilo Contributor

Hello Everyone,

Where can I find the UI action corresponding to 'Add all' button on Configuration Item sys pop-up which was launched by clicking the 'Add' button on Affected CIs related list on a Change Request. It is basically to choose and add the CIs to a Change Request.

I come to know that there is a UI page "task_add_affected_cis.do" this page is used to create a GlideOverlay (the window that opens),and this UI page is getting call from the Script include "AssociateCIToTask".

I want to remove this "Add all" button from that popup view,can anyone please help me out with this?

Provided a screenshot of it below.

find_real_file.png

1 ACCEPTED SOLUTION

I found a way to achieve this using jQuery, after reading through the post mentioned above, Where can I find UI action for 'Add all' button on Configuration Item sys pop-up.



It involved modifying the "Add" UI Action. https://INSTANCE_NAME.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=77688cfe6f35f100e5f2b331...



Here's the code I used...



function openCmdbCIList(){


  var gajax = new GlideAjax("AssociateCIToTask");


  gajax.addParam("sysparm_name","getURL");


  gajax.addParam("sysparm_id", g_form.getUniqueValue());


  gajax.addParam("sysparm_add_to", "task_ci");



  gajax.getXMLAnswer(openList);


}




function openList(answer){


  var url = answer;



  var cmdbciOverlay = new GlideOverlay({


  id : "cm_add_affected_cis",


  title : getMessage("Add Affected Configuration Items"),


  iframe : url,


  closeOnEscape : true,


  showClose : true,


  onAfterClose: refreshAffectedCIs,


  onAfterLoad: resizeIframe, //Once PRB632264 is fixed by platform we can comment this line


  height : "90%",


  width : "90%"


  });





  cmdbciOverlay.center();


  cmdbciOverlay.render();



  cmdbciOverlay.setOnAfterLoad(replaceAddAllFunction); //Setting the On after load again replace the original one set previously


}




function refreshAffectedCIs() {


  var listId = g_form.getTableName() + ".task_ci.task";



  var list = typeof GlideList2 !== "undefined" ? GlideList2.getByName(listId) : null;


  if (list == null)


  list = typeof GlideList !== "undefined" ? GlideList.get(listId) : null;



  if (list != null)


  list.refresh();


}




function resizeIframe(){


  var x = g_glideBoxes.cm_add_affected_cis;


  x.autoDimension();


  x.autoPosition();


  x._createIframeShim();


}




function replaceAddAllFunction(){


  //Kepping what the resizeIframe was doing


  var x = g_glideBoxes.cm_add_affected_cis;


  x.autoDimension();


  x.autoPosition();


  x._createIframeShim();



  var iframe = document.getElementsByClassName("gb_iframe")[0]; //Get the iframe rendered



  var addAll = $j(iframe).contents().find("#add_all"); //Find the Add All button



  $j(addAll).remove(); //Remove the Add All button


}


View solution in original post

7 REPLIES 7

Ivano B
ServiceNow Employee
ServiceNow Employee

Hi Pryanka



This post should give the answer you need



Where can I find UI action for 'Add all' button on Configuration Item sys pop-up



The UI Page named task_add_affected_cis.do can't be edit nor the source code can be reached in SNOW.


This means that unfortunately that button can't be removed



I hope this will help/answer your question and if it does please mark it



Cheers


R0b0


I found a way to achieve this using jQuery, after reading through the post mentioned above, Where can I find UI action for 'Add all' button on Configuration Item sys pop-up.



It involved modifying the "Add" UI Action. https://INSTANCE_NAME.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=77688cfe6f35f100e5f2b331...



Here's the code I used...



function openCmdbCIList(){


  var gajax = new GlideAjax("AssociateCIToTask");


  gajax.addParam("sysparm_name","getURL");


  gajax.addParam("sysparm_id", g_form.getUniqueValue());


  gajax.addParam("sysparm_add_to", "task_ci");



  gajax.getXMLAnswer(openList);


}




function openList(answer){


  var url = answer;



  var cmdbciOverlay = new GlideOverlay({


  id : "cm_add_affected_cis",


  title : getMessage("Add Affected Configuration Items"),


  iframe : url,


  closeOnEscape : true,


  showClose : true,


  onAfterClose: refreshAffectedCIs,


  onAfterLoad: resizeIframe, //Once PRB632264 is fixed by platform we can comment this line


  height : "90%",


  width : "90%"


  });





  cmdbciOverlay.center();


  cmdbciOverlay.render();



  cmdbciOverlay.setOnAfterLoad(replaceAddAllFunction); //Setting the On after load again replace the original one set previously


}




function refreshAffectedCIs() {


  var listId = g_form.getTableName() + ".task_ci.task";



  var list = typeof GlideList2 !== "undefined" ? GlideList2.getByName(listId) : null;


  if (list == null)


  list = typeof GlideList !== "undefined" ? GlideList.get(listId) : null;



  if (list != null)


  list.refresh();


}




function resizeIframe(){


  var x = g_glideBoxes.cm_add_affected_cis;


  x.autoDimension();


  x.autoPosition();


  x._createIframeShim();


}




function replaceAddAllFunction(){


  //Kepping what the resizeIframe was doing


  var x = g_glideBoxes.cm_add_affected_cis;


  x.autoDimension();


  x.autoPosition();


  x._createIframeShim();



  var iframe = document.getElementsByClassName("gb_iframe")[0]; //Get the iframe rendered



  var addAll = $j(iframe).contents().find("#add_all"); //Find the Add All button



  $j(addAll).remove(); //Remove the Add All button


}


Hello Juabbott



I tried to do this on my dev instance and it worked.


Thank you


That's great, Priyanka! If you feel like my answer was correct, can you please mark it as such? Thanks!