Custom UI action not working on FSM workspace

AbhishekK512254
Tera Contributor

I created a custom UI action: requested raised and configured in both workspace and native UI. but the custom ui action is not working either on workspace/native UI.
issue: even after clicking OOB 'save' or 'update' action on workspace, the server side of custom UI action runs every time whenever there is any updates made to the form.

expected: custom UI action should work both on client side and server side only when it is clicked.

UI action: 'Request raised'
client : true
server(insert/update) - true
script:

function poincrease() {
    var ans = confirm("Do you want to move ahead?");
    if (ans == false)
        return false;
    else
        gsftSubmit(null, g_form.getFormElement(), "req_raise");
}
if (typeof window == 'undefined')
    runBusRuleCode();

function runBusRuleCode() {
 
    current.u_status = 'req expedite required';
    current.update();
    action.setRedirectURL(current);
}

workspace client script:
function onClick(g_form) {
    var ans = confirm("Do you want to move ahead?");
    if (ans == false) {
        return false;
    } else {
        // Trigger the UI action's server-side logic.
        g_form.submit('req_raise'); // matching the UI action name
    }
}

please help to resolve this issue as i am unable to fix this issue.
 
Thanks,
Abhishek


7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@AbhishekK512254 

what debugging did you do?

share your UI action configuration screenshots

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur  I have added logs in server script of above UI action. but it's still getting executed every time any updates/changes made on the form.
I also added 'g_form.getActionname() === 'request_raised' but still having the same issue.

AbhishekK512254_0-1746439245249.pngAbhishekK512254_1-1746439438426.png

thanks,

Abhi



@AbhishekK512254 

did you check any OOTB UI actions?

Ideally your script should work fine

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@AbhishekK512254 

it worked for me in both native + workspace, see below I got info message present in server side both the times.

Script:

function showFunction() {
    alert('inside normal client script');
    var url = '/' + 'incident' + '.do?PDF&sys_id=' + g_form.getUniqueValue() + '&sysparm_view=workspace';
    alert(url);
    top.window.open(url, "_blank");

    gsftSubmit(null, g_form.getFormElement(), "export_pdf");
}

if (typeof window == 'undefined')
    runBusRuleCode();

function runBusRuleCode() {
    gs.addInfoMessage('server side');
}

Workspace client script:

function onClick(g_form) {
    var ans = confirm("Do you want to move ahead?");
    if (ans == true) {
        alert('inside workspace client script');
        var url = '/' + 'incident' + '.do?PDF&sys_id=' + g_form.getUniqueValue() + '&sysparm_view=workspace';
        alert(url);
        open(url, "_blank");
        g_form.submit(g_form.getActionName()); // matching the UI action name
    }
}

AnkurBawiskar_0-1746441896357.png

 

AnkurBawiskar_1-1746441904725.png

 

Output:

workspace custom UI action client and server.gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader