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

@Ankit Balapure 

check my below script

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

Ankit Balapure
Tera Contributor

Hello @Dr Atul G- LNG and @Ankur Bawiskar , 

 

By reading your reply for onSubmit() catalog client script any user can see the form but only manager can submit. However, I want the form strictly visible and submit by the user who is the present in the Manager variable (as mentioned in the above screenshot).

@Ankit Balapure 

so please use onSubmit script which I already shared so that only the manager which is the logged in user can submit

function onSubmit() {
    if (g_form.getValue('managerVariable') != g_user.userID) {
        alert('You are not present in the manager variable so you cannot submit');
        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

Hi @Ankur Bawiskar ,

 

I absolutely agree on your point but can't we do like this "I only want form to be visible to the for ex. Steve Roger's manager (who is Sourov) as given in the above screenshot."

If we use the onSubmit script it will be like change in the requirement.

 

Thanks,

Ankit

@Ankit Balapure 

is that manager variable auto populated with logged in user's manager or manually filled in?

To achieve your requirement you need to use User Criteria with script

Consider: Sourov logins and since he is manager of Steve he can see the catalog form and can submit it

If you login and you are not manager of any user then form is hidden

This solves your requirement for every user, why are you taking only Sourov as example?

Do you want form only to be seen by Sourov always?

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