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 10:10 PM
Hi @pranay_14 ,
Did you verify the info message : "entitySysId" and check whether you are receiving it correctly or not ?
If you are getting it correctly then use glide ajax and call script include and pass this variable to the script include as a parameter.
You can refer the below link for calling the script include using glide ajax : Link
Please mark this solution as "Helpful" and please mark it "Correct" and close the thread so that it benefits future readers.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 08:36 PM
Hi @pranay_14
Below post could be helpful:
https://www.servicenow.com/community/developer-forum/get-url-in-agent-workspace/m-p/1462606/page/2
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 10:01 PM
Thanks @Amit Verma , I was able to get the URL using a client script . Could you please help in providing a way , 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:40 PM
I am not sure on this part. Let me give it a try on my side. Parallelly, you can refer below links and see if anything works out for you:
https://www.dylanlindgren.com/2023/12/29/declarative-actions-in-servicenow-the-complete-guide/
Please mark this response as correct and helpful if it assisted you with your question.