- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 06:32 AM
My scenario is that I have two fields that look up to the sys_user in a variable set.
They both get populated initially using javascript:gs_getUserID();
However, I have a checkbox that indicates that they are the same (as the initial default) and if the checkbox is unchecked then the second field clears out the value, which works just fine.
However, once the second value is cleared out and the user checks the box again that indicates that both user fields are the same, I would like the second field to populate again with the get user ID function.
I was wondering if the Set Value in the Catalog UI Policy is able to accept the script? If I type in the same script in the Set Value, it literally returns the value that I typed in instead of executing any script.
Is the Set Value in a Catalog UI Policy only for literal values and not available to recognize a script?
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 05:34 AM - edited 09-21-2024 11:45 AM
To actually answer your question, yes - the new (Washington DC) Set Value feature can only accept literal values, not functions, javascript, or anything dynamic unfortunately. Since this is a new feature, hopefully that will change to become more useful! In the meantime, in the Execute if true script for the UI Policy, or if you decide to go the onChange Catalog Client Script route, you would either use
g_form.setValue('var_2', g_user.userID);
or
g_form.setValue('var_2', g_form.getValue('var_1');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 10:21 AM - edited 09-21-2024 10:23 AM
Hi @JohnnieGross ,
I tried your problem in my PDI and it works for me I create onChange Client Script on checkbox and added below code
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
alert("Outside");
if (newValue == 'No') {
alert("inside if");
g_form.setValue('user_name_2', ""); // Not Same
} else{
alert("inside else");
g_form.setValue('user_name_2', g_form.getValue("user_name_1")); // Same
}
}
Result
Initially
When I hit NO
When I again hit on YES
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 12:39 AM
Hi @JohnnieGross ,
Please create an onChange client script for the check box.
If this solution helps you then, mark it as accepted solution ✔️ and give thumbs up 👍!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 01:15 AM
Hi @JohnnieGross,
In theory, we can use the g_form.setValue () function in the UI policy. There are 2 fields for script in UI policy: "Execute if true" (run once the condition is true) and "Execute if false" (run once the condition is false). So, you can write the script on those fields based on your requirement.
However, If you want to populate some thing once the field changed, you should use the client script "on change" instead of that. Because UI policy should be used to make fields read only, visible, mandatory. Otherwise, the client script will be used to populate value for fields.
Please accept my solution and mark it helpful if it can help you. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 05:34 AM - edited 09-21-2024 11:45 AM
To actually answer your question, yes - the new (Washington DC) Set Value feature can only accept literal values, not functions, javascript, or anything dynamic unfortunately. Since this is a new feature, hopefully that will change to become more useful! In the meantime, in the Execute if true script for the UI Policy, or if you decide to go the onChange Catalog Client Script route, you would either use
g_form.setValue('var_2', g_user.userID);
or
g_form.setValue('var_2', g_form.getValue('var_1');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 10:21 AM - edited 09-21-2024 10:23 AM
Hi @JohnnieGross ,
I tried your problem in my PDI and it works for me I create onChange Client Script on checkbox and added below code
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
alert("Outside");
if (newValue == 'No') {
alert("inside if");
g_form.setValue('user_name_2', ""); // Not Same
} else{
alert("inside else");
g_form.setValue('user_name_2', g_form.getValue("user_name_1")); // Same
}
}
Result
Initially
When I hit NO
When I again hit on YES
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak