- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 10:21 AM
Hello
I have a catalog item where managers are supposed to request a PIN number for their employees.
We have an 'Employee' variable. This variable is the Employee that needs the PIN number.
We also have a 'Submitter' variable. This variable is automatically filled in based on the user who opened the form using: javascript:gs.getUser().getDisplayName()
We also have three manager fields, that are essentially looking thru the 'employees' info in the sys_user table and dot walking back to see each manager up the leadership chain for that employee (Example: manager > directory > vice pres).
'manager' variable = manager.employee
'manager2' variable = manager.manager.employee
'manager3' variable = manager.manager.manager.employee
With all this information, we want to only allow managers for that employee (manager, manager2, manager3) to be able to submit for a PIN for employee. And if that is not the case pop up an error message and do not allow the form to be submitted.
Scenario:
Employee = John Smith
Manager = Joseph Williams (manager)
Manager2 = Jane Doe (director)
Manager3 = David Duck (vp)
John Smith needs a new PIN.
John should NOT be allowed to submit for one for himself or others. And he should be shown an error message and not allowed to submit at all when he attempts to submit one.
John's direct manager is Joseph Williams. Joseph can submit for a PIN for John Smith. But Joseph CANNOT submit for other employees who are not under him.
Jane Doe and David Duck can submit a PIN for John Smith as well. Even though they are higher up in the leadership chain, they are still technically John Smith's boss.
Any ideas would be greatly appreciated.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 05:19 AM
Thanks for your thoughts and ideas Nishant8. I really appreciate it.
I did end up landing on a simple catalog client script that seems to be doing the trick when I run thru my testing.
All,
feel free to review and let me know if you see any issues with it. thanks!
function onSubmit(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var s1 = g_form.getValue('submitter');
var m1 = g_form.getValue('manager');
var m2 = g_form.getValue('manager2');
var m3 = g_form.getValue('manager3');
if(s1 != m1 && s1 != m2 && s1 != m3)
{
g_form.addErrorMessage('You are not the employees manager, so you can not submit the request');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 05:19 AM
Thanks for your thoughts and ideas Nishant8. I really appreciate it.
I did end up landing on a simple catalog client script that seems to be doing the trick when I run thru my testing.
All,
feel free to review and let me know if you see any issues with it. thanks!
function onSubmit(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var s1 = g_form.getValue('submitter');
var m1 = g_form.getValue('manager');
var m2 = g_form.getValue('manager2');
var m3 = g_form.getValue('manager3');
if(s1 != m1 && s1 != m2 && s1 != m3)
{
g_form.addErrorMessage('You are not the employees manager, so you can not submit the request');
return false;
}
}