Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

ServicePortal alert messages for user's without manager

extsandhyak
Mega Contributor

Hi All,

 

 

I have  a requirement that, if user doesn't have line manager updated for him in user table, then he shouldn't be able to submit any form in service Portal.

There should be a Alert message when he opens any form there should be pop up to contact line manager to raise a request on behalf.

 

Please let me know the best way to achieve this.

 

 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@extsandhyak 

then why not hide those catalog items using User Criteria.

In User Criteria use advanced script and see if logged in user has manager or not

Then Add this User Criteria in Available for Related list of your catalog item

Apply user criteria to items and categories 

var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", user_id);
gr.addNotNullQuery("manager");
gr.query();
answer = gr.hasNext();

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Ankur Bawiskar
Tera Patron
Tera Patron

@extsandhyak 

another way is to use onSubmit + glideAjax and see if logged in user has manager or not

If not then stop form submission

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Ankur Bawiskar
Tera Patron
Tera Patron

@extsandhyak 

another way is this

1) create a hidden single line text variable with this default value in it, store logged in user's manager in that

javascript: gs.getUser().getManagerID();

2) then use onSubmit client script and check if that variable is empty, it means no manager then stop form submission

function onSubmit() {
    var hiddenVariableValue = g_form.getValue('hiddenVariableName');
    if (hiddenVariableValue == '') {
        g_form.addErrorMessage("You cannot submit form as you don't have line manager");
        return false;
    }
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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