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

Hi Ankur, 

 

Below script is working for me now, 

 

 if (GlideTransaction.get().getRequest().getHeader("referer").indexOf('/sp') > -1) {
        gs.addInfoMessage('This is portal UI');
    } else {
        gs.addErrorMessage("Assignment group cannot be empty when submitting from this interface");
        current.setAbortAction(true);
    }