Custom UI action not working on FSM workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 02:24 AM
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:
workspace client script:
please help to resolve this issue as i am unable to fix this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 06:33 AM
Hi @Ankur Bawiskar , my script seems correct as well. But, still it's not working. as i mentioned earlier, whenever there is any updates made on the form without clicking on custom UI action, it changes the status to 'request expedite required' . it should change the status only when custom UI action is clicked.
please help me to resolve this issue.
Thanks,
Abhishek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 07:14 AM
I already showcased that the UI action works as expected
without clicking UI action how is the status moving?
Did you check that?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 07:19 AM
Summary
Your custom UI action’s server code is unconditionally executed on every record save because it lacks an action.getName() guard and the script wrapper if (typeof window == 'undefined') runs on all server requests .
Problem Analysis
Unconditional server-side execution
The wrapper
if (typeof window == 'undefined') runBusRuleCode();
calls your server function on all server contexts (including OOB Save), so it fires on every form update .
Misconfigured Action name & Onclick
Your UI Action’s Action name must exactly match the string passed into gsftSubmit/g_form.submit. A mismatch causes the platform to fall back to the OOB update action, triggering your server script on every save .
Workspace-specific setup
Agent Workspace requires UI Actions marked Client and enabled under Workspace Form Button/Menu (or linked via a UX Form Action). Without proper workspace settings, your custom client-server flow won’t behave as expected (servicenow.com, servicenow.com).
Solution Overview
Gate server logic with action.getName() so it runs only when “Request raised” is clicked.
Ensure Action name is unique (e.g. req_raise) and matches client calls.
Use the Onclick field for your client function.
(Optional) Split into two UI Actions: one client-only, one server-only.
Configure workspace settings under the UI Action’s Workspace tab or via a UX Form Action (servicenow.com, servicenow.com).
Detailed Steps
1. Update the UI Action record
Action name: req_raise
Client: ☑️
Server: ☑️
Form button: ☑️
Workspace Form Button: ☑️
Onclick: raiseRequest()
2. Refactor the Script field
// Client-side function function raiseRequest() { if (!confirm("Proceed with request?")) return false; gsftSubmit(null, g_form.getFormElement(), action.getName()); } // Server-side code if (typeof window === 'undefined') { if (action.getName() !== 'req_raise') return; current.u_status = 'req expedite required'; current.update(); action.setRedirectURL(current); }
3. (Optional) Split into two UI Actions
Client-only: Active, Client ☑️, Action name req_raise, Onclick raiseRequest().
Server-only: Active, Server ☑️, Action name req_raise, Script holds only the gated server logic.
4. Configure for Agent Workspace
In the UI Action’s Workspace tab:
Available in Agent Workspace: ☑️
Workspace Form Button: ☑️
For Configurable Workspace, create a UX Form Action that links to this UI Action. (servicenow.com, servicenow.com)
Testing
Open a record and verify the Request raised button appears in both native UI and Workspace.
Click Request raised: confirm dialog shows; on OK, u_status updates and record reloads.
Click the standard Save/Update: your custom logic should not run (confirm no status change in logs).
Let me know if this resolves your issue!