Can I detect from client script whether someone is using the Portal?

peterdelf
Giga Expert

I'd like to add a UI Action which is only available from the normal ServiceNow view and not available if someone is using the Service Portal to view the form.   I've had a look into seeing if I can determine the URL that someone is viewing the form with a URL starting '/SP/' but didn't get far.   Anyone else got tips on how to do this?

1 ACCEPTED SOLUTION

peterdelf
Giga Expert

Actually I found out that this is far more simple than scripting.   It appears that there is now a related list of 'UI Action Visibility' that allows me to configure point-and-click not to show this button on my Service Portal view.   Thanks for your help.Capture.PNG


View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Peter,



you can use the condition field in the UI action.


Call script include, get the browser window url search for specific text and return true or false and based on that the button will be shown.



getting url from server side, below will work in both scoped and non-scoped app



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




Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

bernyalvarado
Mega Sage

Hi Peter,



Sure. You can use window.location.href to retrieve the url and perform the respective comparison.



Thanks,


Berny


I hope this helps


bernyalvarado
Mega Sage

Just in case, the following thread may also be helpful:



How to get entire URL in Client Script OR sysparm



Thanks,


Berny