Guidance Required: Server-Side Code Execution After Client Validation in Workspace UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 04:41 AM - edited ‎07-07-2025 04:42 AM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 10:16 AM - edited ‎07-07-2025 10:18 AM
Hi,
You can add a line of code in your Workspace client script
g_form.submit() will perform UI action specified by the parameter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 10:26 AM - edited ‎07-07-2025 01:26 PM
OOB UI Actions have a "Workspace" tab.
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