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

pranay_14
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

Ankur Bawiskar
Tera Patron

@pranay_14 

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 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?

 

 

 

@pranay_14 

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.

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.