Guidance Required: Server-Side Code Execution After Client Validation in Workspace UI Action

Mark Wood
Tera Contributor

Hello Team,

I want to execute server-side code only after the client-side validation is completed.

When the user clicks on the "Request Approval" UI action, I want to first display a message asking them to fill in all the mandatory fields. Once all required fields are filled, I am using the gsftSubmit to trigger the server-side logic.

This works perfectly in the Native UI, but when I try to implement the same in Workspace, the mandatory field validation message is shown correctly, but the server-side code does not get executed.

Could you please guide me on how to achieve this in Workspace?

function checkMandatory() {
if (g_form.getValue('assignment_group') =='' ||(g_form.getValue('assigned_to') == '') || (g_form.getValue('justification') == '') || (g_form.getValue('risk_impact_analysis') == '')) {
    g_form.setMandatory('assignment_group', true);
    g_form.setMandatory('assigned_to', true);
    g_form.setMandatory('justification', true);
    g_form.setMandatory('risk_impact_analysis', true);
    g_form.addErrorMessage('Assignment Group Mandatory');
    return false; //abort submission, this is what does all of your field checking and stops the server script from moving forward if not met
    }
gsftSubmit(null, g_form.getFormElement(), 'request_approval_standard_change'); //MUST call the 'Action name' set in this UI Action
}
if (typeof window == 'undefined')
    runServerCode();
function runServerCode()
{
    current.setValue('approval','requested');
    current.setValue('state',-3);
    current.update();
    action.setRedirectURL(current);
}
2 REPLIES 2

Manoj89
Giga Sage

Hi,

 

You can add a line of code in your Workspace client script 

g_form.submit("end_work"); //end_work is an Action name of UI action

Manoj89_0-1751908464246.png

Manoj89_2-1751908525433.png

g_form.submit() will perform UI action specified by the parameter.

Manoj89_3-1751908690374.png

 

 

 

Bert_c1
Kilo Patron

OOB UI Actions have a "Workspace" tab.

Screenshot 2025-07-07 132411.png

Can you post what you have there in your UI Action? Community members can better help you.

 

next-experience-articles/how-to-use-ui-actions-in-workspaces/ta-p/2331988