How to write client script and server script in a single declarative action.

pranay_14
ServiceNow Employee
ServiceNow Employee

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.

 

8 REPLIES 8

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

Amit Verma
Kilo Patron
Kilo Patron

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.

pranay_14
ServiceNow Employee
ServiceNow Employee

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?

@pranay_14 

 

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.servicenow.com/community/developer-blog/declarative-actions-in-servicenow-the-complete-g...

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.