On submit of Actions on selected rows record should be added

Samiksha2
Mega Sage

Hi,

 

I have created a UI action(Incident) in the Problem table. When Incident button is clicked then the List of Incident table is coming up. 

Now I created one more UI Action Add to Incident in the List choice.(Actions on selected rows)

Samiksha2_0-1674164789628.png

 

The requirement is that we can select the multiple choices from the incident list and once we select the Add to Incident then in all the selected Incidents Problem number should added or autopopulate.

 

Please help in this.

 

Thanks!

Samiksha

 

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

Hi @Samiksha2 

Sorry for the late reply. Got your query and just now tried in my instance and it worked as you expected.

In the Add to Incident UI action use below logic:

function downloadattachment() {
    var getSysId = g_form.getUniqueValue(); //will return current sys_id/ problem sys_id
    var getRec = g_list.getChecked();  //will return checked record sys_id's in list view
    if (getRec.length > 0) {
        var ajax = new GlideAjax("global.Newglidingabc");
        ajax.addParam("sysparm_name", "updatePRinINC");
        ajax.addParam("sysparm_arr", getRec);
        ajax.addParam("sysparm_prb", getSysId);
        ajax.getXMLAnswer(callbackdata);
    }

    function callbackdata(response) {
        var answer = response;
        if (answer == "done") {
            alert("Updated successfully");
            GlideDialogWindow.get().destroy(); //closes the dailog window after updation
        }
    }
}

Script include:

updatePRinINC: function() {
        var grI = new GlideRecord("incident");
        grI.addQuery("sys_id", "IN", this.getParameter("sysparm_arr"));  //checked list
        grI.query();
        while (grI.next()) {
            grI.problem_id = this.getParameter("sysparm_prb");  //problem sys_id
            grI.update();
        }
        return "done";
    },
    type: 'Newglidingabc'
});

(=tested)

Hope it helps.

 

 

Thanks,
Murthy

View solution in original post

8 REPLIES 8

Murthy Ch
Giga Sage

Hi @Samiksha2 
Are you using OOB Ui action or custom one which you created?

If custom one please share the script once.

Thanks,
Murthy

Hi @Murthy Ch 

I have created the UI action. 
onCLick- getIncident()

Samiksha2_0-1674197153681.png

 

Script:

function getIncident() {
var w = new GlideDialogWindow('show_list');
w.setTitle('Select Incident');
w.setPreference('table', 'incident_list');
w.setPreference('sysparm_view', 'default');
w.render();
}

 

Another UI action is 

Samiksha2_1-1674197327048.png

 

When user multiselect the incident record, problem number will update in all the selected incidents.

Samiksha2_0-1674198554368.png

 

Like this

Samiksha2_1-1674198703761.png

 

Murthy Ch
Giga Sage

Hi @Samiksha2 

Sorry for the late reply. Got your query and just now tried in my instance and it worked as you expected.

In the Add to Incident UI action use below logic:

function downloadattachment() {
    var getSysId = g_form.getUniqueValue(); //will return current sys_id/ problem sys_id
    var getRec = g_list.getChecked();  //will return checked record sys_id's in list view
    if (getRec.length > 0) {
        var ajax = new GlideAjax("global.Newglidingabc");
        ajax.addParam("sysparm_name", "updatePRinINC");
        ajax.addParam("sysparm_arr", getRec);
        ajax.addParam("sysparm_prb", getSysId);
        ajax.getXMLAnswer(callbackdata);
    }

    function callbackdata(response) {
        var answer = response;
        if (answer == "done") {
            alert("Updated successfully");
            GlideDialogWindow.get().destroy(); //closes the dailog window after updation
        }
    }
}

Script include:

updatePRinINC: function() {
        var grI = new GlideRecord("incident");
        grI.addQuery("sys_id", "IN", this.getParameter("sysparm_arr"));  //checked list
        grI.query();
        while (grI.next()) {
            grI.problem_id = this.getParameter("sysparm_prb");  //problem sys_id
            grI.update();
        }
        return "done";
    },
    type: 'Newglidingabc'
});

(=tested)

Hope it helps.

 

 

Thanks,
Murthy

Thank you so much @Murthy Ch . I was waiting for your reply.😀