How to write client script and server script in a single declarative action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 08:04 PM
I am on the record page within the workspace and have added a button. When the button is clicked, I want to capture the current page URL.
Specifically, I need to extract the sysID
parameter from the URL:
URL Format:<Instance Id>/now/mfg/isa-equipment-model/params/sys-id/<sysID>/selected-tab-index/4/sub/record/<table-name>/<record-sysId>
The logic for this will be in client script. I need to use this sysId parameter in the server script for my usecase.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 08:33 PM
so what did you start with and where are you stuck?
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
03-02-2025 09:57 PM
@Ankur Bawiskar I have retrieved the sys_id using a client script using a declarative action.
var currentUrl = top.location.href;
g_form.addInfoMessage("currentUrl: " + currentUrl);
var entitySysId = currentUrl.split('/')[8];
g_form.addInfoMessage("entitySysId: " + entitySysId);
Now, I need to use this entitySysId in a server script within a declarative action to query a table.
How can I use both a client script and a server script within a single declarative action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 10:01 PM
where are you showing that UI action?
I am not sure if both client + Server can be combined
Is that normal UI action?
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
03-02-2025 10:08 PM
Currently I have implemented a client script using a declarative action, same would work in UI action as well.
But I am not sure how to utilise the fetched syId in a server script.