Need to show an error message only on the classic UI but should not appear on the Service portal sid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 10:51 AM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 12:30 PM
Its on incident record. Yes, I meant native Ui when I mentioned calssic UI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 03:33 PM
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 07:55 PM
Thank you for your reply. IF it works in client script can you give me the script for that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 10:08 PM
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
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 12:02 AM
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.