Only Requested by's Manager can access the Catalog Item form

Ankit Balapure
Tera Contributor

I have created the attached Catalog item form, I want to make this visible only for the user who is in the Manager variable (who is the Manager of the user which is present in the Name variable), could anyone tell me how we can do that?

catalog itemcatalog item

 

13 REPLIES 13

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Ankit Balapure 

 

https://www.servicenow.com/community/developer-forum/require-the-catalog-item-submission-to-only-be-...

 

*************************************************************************************************************
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]

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Ankit Balapure 

you can use onSubmit catalog client script and see who is the logged in user?

If logged in user is different than Manager then stop the form submission

function onSubmit() {
    if (g_form.getValue('managerVariable') != g_user.userID) {
        alert('Only managers can submit this request');
        return false;
    }
}

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Ankit Balapure 

you can also user criteria with script and add this in Available For related list in your catalog item

Only logged in users who is manager of at least 1 user will see the catalog item

Apply user criteria to items and categories 

AnkurBawiskar_0-1741614697842.png

 

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

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 Bawiskar,

 

So, if we use the above script then that form will be visible to any manager, but I only want form to be visible to the for ex. Steve Roger's manager who is Sourov as given in the above screenshot.

 

Thanks, 

Ankit