The CreatorCon Call for Content is officially open! Get started here.

How can i create Ui action on incident List View that will update the record?

Ankit Kumar6
Tera Contributor

Hi 

 

I have one requirement where i want two button "ASSIGN ME" and "REMOVE ME" on incident list page.

and suppose i applied some filter condition on list page.

when i click  "ASSIGN ME"  then it will assign me as a assignee in all the record that return from the Filter condition applied on list page.

How can i do this please help me.

Thanks 

Ankit

3 REPLIES 3

Community Alums
Not applicable

Hi @Ankit Kumar6 ,

I tried your problem in my PDI and it works for me please check below stetps

I created Client callable UI Action and addded below code 

function assignIncident() {
    var selected = g_list.getChecked();
    alert('selected = ' + selected);
    var ga = new GlideAjax('assignedIncidentList');
    ga.addParam('sysparm_name', 'assignedIncidentListFunction');
    ga.addParam('sysparm_selectedIds', selected);
    ga.getXML(updateCampus);

    function updateCampus(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert(answer);
    }
}

SarthakKashyap_2-1716289993441.png

 

Script Include which is client callable 

var assignedIncidentList = Class.create();
assignedIncidentList.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	assignedIncidentListFunction: function(){
		
		var ids = this.getParameter('sysparm_selectedIds');
		gs.log("sysparm_selectedIds" + ids);
		var incGr = new GlideRecord('incident');
		incGr.addEncodedQuery('sys_idIN'+ids);
		incGr.query();
		while(incGr.next()){
			incGr.assigned_to = 'be05e21b937331100d5170918bba10c7';
			incGr.update();
		}
	},

    type: 'assignedIncidentList'
});

SarthakKashyap_3-1716290012609.png

 

Result 

SarthakKashyap_0-1716289928078.png

SarthakKashyap_1-1716289945637.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak

 

Hi @Community Alums , @Sid_Takali 

 

I think you are only updating the selected record.

But my requirement is suppose i applied a filter condition and this will return 500 records, and when i click "ASSIGN ME" button then it will add me as a assignee in all 500 records.

 

I dont want to scroll the page and select the records