Bulk incident update with same close notes..

dev201
Tera Contributor

Hi All,

I have a requirement of Bulk incident update where I need to create a UI action in the incident_list. The UI action when clicked then it should show a popup of textbox with ok and cancel button. whatever we write in the textbox and click ok it will copy the text to the close notes and close the incident and if we cancel it will copy the text to work notes and cancel the incident. Basically the functionality is like in the list of incidents whatever is checked all the incidents gets closed with same close notes or gets cancelled with same work notes. Please help me with code and approach if somebody have come across this scenario. Thanks in advance!!!

4 REPLIES 4

Kalaiarasan Pus
Giga Sage

You will need to create a custom UI page and a UI action. The UI page will help capture user input and do the bulk processing of records.

For inspiration, take a look at the Cancel button of resource plan table.

I know the approach.. can you please provide any code snippet because I have no idea for creating a UI page since I am new to the creation of UI pages but I am familiar with Ui action.

Ian Mildon
Tera Guru

There is a great guide for this on SNGuru that I used to do something very similar. If you scroll down to the section Displaying a form popup from a list (multiple updates with one action) that is what I used.

Rajesh M1
Giga Guru

Hello,

 

Configure below steps to achieve ur requirement (some minor tweaks may be required from your end):

 

1. Create a UI page

HTML:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j2:set var="jvar_change_id" value="$[sysparm_id]" />
<input type="hidden" id="sys_is" value="$[jvar_change_id]"></input>

 

Comments:<input type='text' id='comment'> </input>
<br></br>

<button onclick = 'resolve(6)'>Resolve</button> <button onclick = 'resolve(8)'>Cancel</button>
</j:jelly>

Client Script:

function resolve(num)
{

var a1 = document.getElementById('sys_is').value;

var comments = document.getElementById('comment').value;
alert(comments);
var a = new GlideAjax('UpdateIncidents');
a.addParam('sysparm_name','resolve');
a.addParam('sysparm_ids',a1);
a.addParam('sysparm_state',num);
a.addParam('sysparm_comments',comments);

a.getXML(sendValues);

}

function sendValues(response)
{
var ans=response.responseXML.documentElement.getAttribute("answer");
alert(ans);
window.location.assign('https://instance url/incident_list.do');
}

 

2. Create a UI action (Note :Type of UI action is List Choice, It will appear at the bottom of the list)

find_real_file.png

Script:

 

function navigate()
{

/*var id = g_list.getChecked();
var url = new GlideURL('R_updateAll.do');
url.addParam('sysparm_change', id );
//url.addParam('sysparm_change1', sysId1 );
window.location.href = url.getURL();*/
var gdw = new GlideDialogWindow('R_resolve');
gdw.setTitle('Test');
gdw.setSize(750,300);
gdw.setPreference('sysparm_id', g_list.getChecked());
gdw.setPreference('title', 'Close/cancel Incident');
gdw.render();
}

 

3. Script Include:

find_real_file.png

 

Code:

var UpdateIncidents = Class.create();
UpdateIncidents.prototype = Object.extendsObject(AbstractAjaxProcessor, {

resolve: function()
{
gs.log("Inside script include");
var id = this.getParameter('sysparm_ids').toString().split(',');
var state = this.getParameter('sysparm_state');
var comment = this.getParameter('sysparm_comments');
gs.log("Comments="+comment);
for(var i=0;i<id.length;i++)
{
gs.log("Inside while loop");
var inc = new GlideRecord('incident');
inc.addQuery('sys_id',id[i]);
inc.query();
if(inc.next())
{
if(state == 6)
{
inc.state =6;
inc.close_notes = comment;
}
else{
inc.state =8;
inc.work_notes = comment;
}
inc.update();
}

}
return "Incidents updated";
},

type: 'UpdateIncidents'
});

 

Mark answer as correct if it helps.

 

Best Regards,

Rajesh M.