- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2024 08:02 AM
Hello team,
I have to set the requested for variable in variable set as read only and change it to the user that is logged in and doing the request.
I have created this script, but it's not working fine, I have 3 options, the first one the user can change the requested for, but the other 2 no, so the script bellow only works when I change from the first option to the second, but if i change from the third option to the second it allows the user to change the requested for again.
Am I doing something wrong?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var user=g_user.userID;
if(newValue == 'Remove access from a Group')
{
g_form.setMandatory("requested_for",true);
g_form.setValue("requested_for",user);
g_form.setReadOnly("variables.requested_for", true);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2024 08:53 AM
Hi @rafaelalves4337 ,
Please try the below, I have tested in PDI and it is working
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var user = g_user.userID;
//Don't allow changes(opt 2)
if (newValue == 'Remove access from a Group') {
g_form.setMandatory("requested_for", true);
g_form.setValue("requested_for", user);
g_form.setReadOnly("requested_for", true);
}
//Allow changes(Option 1)
else if (newValue == '<update with opt 1>') {
g_form.setMandatory("requested_for", false);
g_form.setValue("requested_for", user);
g_form.setReadOnly("requested_for", false);
}
//Don't allow changes(opt 3)
else if (newValue == '<replace with opt3>') {
g_form.setMandatory("requested_for", false);
g_form.setValue("requested_for", user);
g_form.setReadOnly("requested_for", false);
}
}
Please mark this response correct if I've answered your question. Thanks!
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2024 09:20 AM
Thank you all!!
Already did the changes proposed and it worked!!