- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2016 10:28 AM
Hello friends,
Where can I find the UI action (I assumed it must be an 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. Provided a screenshot of it below.
Thanks,
Hari
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2016 05:48 PM
Your Add button on change_request is this UI Action https://<instance_name>.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=77688cfe6f35f100e5f2b3312e3ee4e6
Which refers to the Script Include you were talking about (AssociateCIToTask) and calls the function getURL(). This function returns a UI Page URL containing the right parameters to render the list and its UI Action. The UI Page is task_add_affected_cis.do which is a page that you can't edit or see source code in SNOW. This page is used to create a GlideOverlay (the window that opens).
So the Add All button itself is contained in this page and not editable.
Depending on what you want to do, I found using my developer console, the client script being called by the add all button:
function addAllToTask() {
var g_list = GlideList2.get(NOW.task_add_affected.TABLE_NAME);
var gajax = new GlideAjax("AssociateCIToTask");
gajax.addParam("sysparm_name","addAll");
gajax.addParam("sysparm_id", NOW.task_add_affected.TASK_ID);
gajax.addParam("sysparm_query", g_list.getQuery());
gajax.addParam("sysparm_tableName", g_list.tableName);
gajax.addParam("sysparm_add_to_table", NOW.task_add_affected.ADD_TO_TABLE);
gajax.getXMLAnswer(closeWindow);
}
Depending on your goal you could try to work out the addAll function in the script include to be able to use it based on what you want to do. This would be if you would like to use it somewhere else.
If you want to change the behavior of the Add all button, you could try to rebuild the UI page to have a custom one with your custom button. Or you could modify what the addAll function does inside the Script Include by customizing it (you can't extend it or copy it as the call to the function is hard coded in the UI page you can't modify).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2016 09:43 AM
Hi Laurent,
I tested this above code of yours and seems the confirm dialog does popup the first time when you click Add All button. However, I noticed if you change the Configuration Class after the "Add Affected Configuration Items" loads, there is no pop-up.
How do I make the pop-up available when the configuration class change.
Appreciate your code on the forum.
Thanks,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2016 04:36 PM
Hi Rahul,
Your right, my code was not working when changing the class. I never really used that code but only scripted it quickly without testing much.
Here are the required adjustments:
openList becomes (I've restored the use of the resizeIframe after load to instead run the function before load):
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.setOnBeforeLoad(replaceAddAllFunction); //Setting the On before load as the iframe exist at that time to bind a on load function to the iframe
cmdbciOverlay.center();
cmdbciOverlay.render();
}
Then I updated the replaceAddAllFunction function to instead bind a call to the iframe being loaded so everytime the iframe URL changes (which is what happen when you change class) then the addAllToTask function gets replaced again:
function replaceAddAllFunction(){
$j('iframe.gb_iframe').load(function() {
var iframe = document.getElementsByClassName("gb_iframe")[0]; //Get the iframe rendered
//Replace the iframe addAllToTask function
iframe.contentWindow.addAllToTask = function(){
var numberOfItems = iframe.contentDocument.getElementsByClassName("tabs2_list")[0].getAttribute("tab_rows_v2"); //Using the list div element to get the number of item retrieving it by it's class name which is unique in the iframe
var conf = confirm("Are you sure, you want to add " + numberOfItems + " CIs to Change?");
if(conf == true){
var g_list = iframe.contentWindow.GlideList2.get(iframe.contentWindow.NOW.task_add_affected.TABLE_NAME);
var gajax = new GlideAjax("AssociateCIToTask");
gajax.addParam("sysparm_name","addAll");
gajax.addParam("sysparm_id", iframe.contentWindow.NOW.task_add_affected.TASK_ID);
gajax.addParam("sysparm_query", g_list.getQuery());
gajax.addParam("sysparm_tableName", g_list.tableName);
gajax.addParam("sysparm_add_to_table", iframe.contentWindow.NOW.task_add_affected.ADD_TO_TABLE);
gajax.getXMLAnswer(iframe.contentWindow.closeWindow);
}
else{
//Do nothing, the popup will close itself
}
};
});
}
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2017 02:59 PM
Thank you Laurent. This was indeed helpful. I was able to find some resource scripts which I reproduced and re-used it. Creates similar functionality.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2016 05:34 PM
You could also revert to the old slushbucket following this article: Disable multiple CI association
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2017 10:33 AM
Hi Laurent,
Is it possible to always defaults the list to display only CIs with Specific Status like Operational Status = Operational?
Both at the first time display and subsequent change of CI class.
Thanks,
Mahesh.