- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 09:03 AM
Hi,
I have a catalog item that users should only be able to submit if they are a manager of the user. I want to enable a pop-up if the opened by is not the requested for's manager to tell them they can't, and cancel submission.
Can anyone help me with how to go about this?
Many thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 11:05 AM
Hi @Community Alums , please update the script as below.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var requestedFor=g_form.getValue('requested_for');
var loggedInUser = g_user.userID;
var user = g_form.getReference('requested_for',doAlert);
function doAlert(user)
{
var manager =user.manager;
if(loggedInUser != manager)
{
g_form.addErrorMessage('You are not user manager so can not submit the request');
}
}
}
Thanks,
Pooja M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 10:28 AM
Hi,
You can add alert or Error message also if the opened by/logged in user is not Requested For's manager please find below onChange client script.
Write a catalog client script Onchange of Requested For.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var requestedFor=g_form.getValue('requested_for');
var loggedInUser = g_user.getUserID();
var user = g_form.getReference('requested_for',doAlert);
function doAlert(user)
{
var manager =user.manager;
if(loggedInUser != manager)
{
g_form.addErrorMessage('You are not user manager so can not submit the request');
}
}
}
Thanks,
Pooja M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 07:59 AM
Thanks so much @Pooja Mallikarj, works great in the back end, but on the employee center I get a message saying there is a javascript error in my browser console?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 11:05 AM
Hi @Community Alums , please update the script as below.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var requestedFor=g_form.getValue('requested_for');
var loggedInUser = g_user.userID;
var user = g_form.getReference('requested_for',doAlert);
function doAlert(user)
{
var manager =user.manager;
if(loggedInUser != manager)
{
g_form.addErrorMessage('You are not user manager so can not submit the request');
}
}
}
Thanks,
Pooja M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 11:16 AM
Amazing!! Thanks so much Pooja!