How "Add" button is working on Incident's Affected CIs related list.

Obito
Tera Expert

Hi all,

Can anyone explain how this 'Add' button is working on Incident's Affected CIs related list. 

 

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(url){
	var cmdbciModal = new GlideModal('task_add_affected_cis');
	cmdbciModal.setTitle(getMessage("Add Affected CIs"));
	cmdbciModal.setWidth(1200);
	cmdbciModal.setAutoFullHeight(true);
	cmdbciModal.on('beforeclose', function(){
		refreshAffectedCIs();
	});
	ScriptLoader.getScripts('/scripts/incident/glide_modal_accessibility.js', function() {
		cmdbciModal.template = glideModalTemplate;
		cmdbciModal.renderIframe(url, function(event) {
				glideModalKeyDownHandler(event, cmdbciModal.getID());
			});
	});
	var link = document.createElement('link');
	link.rel = 'stylesheet';
	link.href = 'styles/incident_glide_modal.css';
	document.head.appendChild(link);
}

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();
	var modal = window.GlideModal.prototype.get('task_add_affected_cis');
	if (modal && modal.message)
		g_form.addInfoMessage(modal.message);
}

function resizeIframe(){
    var x = g_glideBoxes.cm_add_affected_cis;
	x.autoDimension();
    x.autoPosition();
	x._createIframeShim();
}

 I did not understand the flow here after clicking on the add button, pop-up is coming. Can anyone provide any information related to it. like if any UI page is getting called then which one is that?

[pop-up screenshot below]

Obito_0-1726732175570.png

 

2 REPLIES 2

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Obito openCmdbList() - This function initiates the process of opening a modal to select Configuration Items (CIs) related to a task. A new modal window is being created for adding affected CIs, and it is being called here in function "openList". This function is called with the URL returned from the AJAX call. 

 

Long Duong
Kilo Sage

Hi @Obito,

Hope you are well!

 

In that ui action, via the line "

ScriptLoader.getScripts('/scripts/incident/glide_modal_accessibility.js', function() {

", it called the script in the URL
https://your_instance.service-now.com/scripts/incident/glide_modal_accessibility.js

 

In that script, you can see some lines defined modal of the pop up with HTML... Kindly ready the script to have a better understanding.

 

Please mark my answer helpful and accept the solution if it can help you.

Thank you and have a nice day!