Need to show an error message only on the classic UI but should not appear on the Service portal sid

prasannasan
Tera Contributor

Hi,

 

I have a requirement to display the error message if the assignment group is empty only on the classic UI but to hide it on the Service Portal.

 

Will the below logic work?

 

if (gs.isInteractive() && gs.getSession().getStackName() !== 'Service Portal') {
gs.addErrorMessage('There is no assignment group');
current.setAbortAction(true);
}

10 REPLIES 10

prasannasan
Tera Contributor

Its on incident record. Yes, I meant native Ui when I mentioned calssic UI

 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @prasannasan 

Native view means on the form, and if you use a client script, it will work but won't show on the portal. Are you referring to Workspace as well?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Thank you for your reply. IF it works in client script can you give me the script for that?

Ankur Bawiskar
Tera Patron
Tera Patron

@prasannasan 

in your business rule you cannot determine the URL as it's not a reliable way and may work sometime and may not work

Why not use onChange on Assignment Group field and make it mandatory if somebody clears that field ensure your script works only for native?

Set UI Type - Desktop so that it runs only in native and not in portal

AnkurBawiskar_0-1742965679813.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

Hi Ankur, Thanks for the response. But this is on a business rule. It should check everytime there is an update on the record, if the update happened and there is no assignment group at that time it should trigger this error message.