How to Trigger a Business rule only for a Workspace

vtred
Tera Contributor

I would like to know how I could trigger aa Business rule only for a specific workspace

 

OR

 

Is there a way to see if a record is created through workspace ?

4 REPLIES 4

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,

You can build a custom logic. I can suggest two workarounds-

1. Create a custom field suppose "UI Type" and write a onLoad Client script and check the view if it is "workspace" populate the field UI Type with an appropriate value say "Workspace".

 

2. Get the URL in the business rule and parse that because the URL from workspace is different (looks like: api/now/ui/ui_action/f4deef100b701300099a83eb37673a4d?api=api&sysparm_sys_id=ed92e8d173d023002728660c4cf6a7bc&sysparm_table=incident)

You can get the URL with the server side code: gs.action.getGlideURI()

 

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

Regards,
Saurabh


Thanks and Regards,

Saurabh Gupta

Hi Saurabh, I am able to get the exact format of URL you posted. Any idea how i could parse that and get the view out of it?

Hi,

Please refer below script to parse the URL

var tbl=gs.action.getGlideURI().getMap().get('sysparm_table');
	var url=gs.action.getGlideURI().toString();
	if(url.indexOf('api/now/ui')>=0 && tbl=='incident')
		gs.addInfoMessage("From Workspace");
	else
		gs.addInfoMessage("Not From Work Space");

 

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

Regards,
Saurabh


Thanks and Regards,

Saurabh Gupta

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

get URL and check if it's workspace or not

to get parameter from url use this

var myValue = gs.action.getGlideURI().getMap().get('URL Parameter Name');

Regards
Ankur

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