How to make a UI action not return to the list view from a form

Erik Stuer
Tera Guru

I created a UI action and am having but one issue. When on the incident form and I hit it, it executes the UI action (assigning the incident to the current user - 'Assign to me' UI Action button) but then it returns me back to the list view of the incident table. Is there a way to stop this? I want it to update the 'assigned to' field but keep me on the incident form. Similar to the 'Save' UI action vs. 'Submit'.

Thank you!

19 REPLIES 19

Joe S1
Kilo Sage

Hello Erik,

 

You can add a redirect line to the server side code of your UI Action. 

 

Something like this:

action.setRedirectURL(current);

ErikStuer_0-1682531152646.jpeg

 

That's what I tried. I added it to the end of my code but it still would return to the list view. I then commented out the return at the end of each else if because I thought that might be it, but that is causing the record to be deleted now. How would you adjust this code?

I just logged in to my PDI and took the out of the box "Assign to me" list context menu UI Action and added the Form button so that it would display on Incident forms.

JoeS1_0-1682532918581.png

I then added the action.redirect to the script and tested and it's performing as expected. If you click the button the Incident is assigned to you and you remain on the form.

assignToMe();

function assignToMe() {
    if (!current.active || !current.assigned_to.canWrite()) {
        gs.addErrorMessage(gs.getMessage('You do not have permission to update assigned to'));
        return;
    } else if (!current.assignment_group.nil() && !gs.getUser().isMemberOf(current.assignment_group.toString())) {
        gs.addErrorMessage(gs.getMessage("Assigned to user {0} must be member of Assignment group {1}", [gs.getUserDisplayName(), current.assignment_group.getDisplayValue()]));
        return;
    } else if (current.assignment_group.nil()) {
        var memberGroups = new IncidentUtils().getMemberGroups(gs.getUserID(), 2);
        if (memberGroups.length > 1) {
            gs.addErrorMessage(gs.getMessage("Assigned to user {0} is member of multiple groups, please select one as Assignment group", [gs.getUserDisplayName()]));
            return;
        } else if (memberGroups.length == 1)
            current.assignment_group = memberGroups[0];
    }
	action.setRedirectURL(current);
    current.assigned_to = gs.getUserID();
    current.update();
}

It may be your order of operations, try moving the action.redirect to occur before you set the assigned_to field.

Well, shucks. Not sure what else is screwing up my instance then. It is still kicking my back to the list view on the incident form. Any ideas of where to look for what is messing up?