Execute a client script or business rule in service operations workspace only and not in native UI?

Suggy
Giga Sage

Is it possible to execute a client script or Business Rule in service operations workspace(SOW) only and not in native UI?

 

I have seen few field messages being displayed in SOW when I am making some changes to a field, but the same in not happening in Native UI. So I thought its possible to so , but wanted to know how to do it?

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Suggy 

My thoughts

Client scripts

client script has view field when you uncheck global and you can mention the name of workspace view there, but remember the same view exists in native as well and if user switches the view in native, the script will run in native as well

So if you want to skip the client script, check the URL and see if it contains name of workspace (/now/sow/home)

Business rule

I don't think any such thing exists for business rules, although you can check what comes in url in business rule script using this but I don't think it's reliable

gs.action.getGlideURI().toString().indexOf('now/sow/home');

You can also check how the OOTB client scripts are handling this

AnkurBawiskar_0-1746780540316.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

SumanthDosapati
Mega Sage
Mega Sage

@Suggy 

Yes possible.

There is a view field on client script table.

Go to client scripts list and personalise list view and bring the 'view' field to the list.

You can filter out view is empty and see all the client scripts that are applicable for specific views. There will be few for workspace view also.

 

Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth

Santhosh_S
Tera Contributor

@Suggy 
In ServiceNow we have views to differentiate the workspace and native UI and Service operation workspace uses 
sow view for existing records and sow_new_record for new record. Native UI use default view, and you specify the view to apply client script on respective workspace.
Note:
If you change the view in classic view the script will run on classic also.

Mark helpful if it helps.