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

Hi @Murthy Ch will your solution work in a use case where I have wm_order table that extends the sm_order table? I am attempting to create a problem from a work order then from the problem record I have added the UI action  titled "attach work order" then I would want to have the on click (not sure if I need a condition in the "on click field in the UI Action) brings up the wm_order list view to select work orders that will be added to the problem related list. 

Hi @KKrabbenhoft 

Yeah. I believe it will work. Please give a try and let me know if you need any stuck anywhere. Happy to help 🙂

Thanks,
Murthy

KKrabbenhoft
Tera Guru

Will this solution work for selecting records for any table? I have a request to use this on our wm_order table which extends the sm_order table. 

Hi @KKrabbenhoft 

I believe it should work. Please give a try and let me know if it works.

Thanks,
Murthy