Urgent- How to fetch the view to determine the user is a portal user in business rule?

Ashirav
Tera Expert

I want to check whether the person's view is ess view or not. Because if it is, then that means the person who updated the field is a portal user.

If the user who updated the field is a portal user I have to fill the u_source field as 'Portal' through this business rule. I HAVE to stick to using business rule, i can t avoid them. Please help.

What I have been using is this code and it gives answer as null:-

var view_name='';
if (gs.getSession().isInteractive()) {
var map = gs.action.getGlideURI().getMap();
if (map.get('sysparm_view') != null) {
view_name= map.get('sysparm_view').toString();
}
}
gs.log('ASHI View: '+view_name);

if(view_name == 'ess' && /*Here will come the client script lines*/){
current.u_source = 'Portal';
}

9 REPLIES 9

Hi Ankur,

I finally managed to rn the script on portal. But the url i got was the entire url by this statement, and the entire url is:

https://ncrsmadev.service-now.com/servicedesk/incident.do?sys_id=f232300c1b67801072ca7550cd4bcb05&sysparm_view=ess&sysparm_view=ess&sysparm_domain=null&sysparm_domain_scope=null&sysparm_record_row=1&sysparm_record_rows=1&sysparm_record_list=u_ticket_roleINjavascript%3anew+Url().f1()%5enumberSTARTSWITHINC0223003%5eORDERBYDESCnumber

 

I need to fetch that 'servicedesk' or the view name as 'ess'. But this fetches the entire stuff..

Hi Ashirav,

so the sysparm_view parameter is present in the url; I assume this log is printed in the BR script

the below script won't work in scoped app

var map = gs.action.getGlideURI().getMap();

if you only want to know whether the view is ess then please include code as below

var url = gs.action.getGlideURI().toString();

var index = url.indexOf('sysparm_view=ess');

if(index >=0){
current.u_source = 'Portal';
}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

 I am sorry i was wrong in my answer at one point above.

The url obtained in the query is everything from incident.do below:-

 https://ncrsmadev.service-now.com/servicedesk/incident.do?sys_id=ea742907dba280148f6f1fe96896197d&sysparm_view=ess&sysparm_view=ess&sysparm_domain=null&sysparm_domain_scope=null&sysparm_record_row=8&sysparm_record_rows=39110&sysparm_record_list=u_ticket_roleINjavascript%3anew+Url().f1()%5eORDERBYDESCsys_created_on&sysparm_nameofstack=21c33cc0db0c9050f98fde82ca9619b9

 

What i need is that SERVICEDESK word. But the url obtained by the statement is starting from INCIDENT.DO and not from servicedesk. ESS can vary, servicedesk is a must.

Thank you for giving me so much of your time...i really needed it to be done by today.

Hi Ashirav,

So you have that url obtained in log; what you want to search for?

Regards
Ankur

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

@Ashirav 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

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