- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 02:40 PM
Hi all,
I have a requirement to populate a field - "User for whom a new signature is being requested" with the same value that is on the "Requested For" field.
Can someone please help me with the script.
Also, I have to make the field "User for whom a new signature is being requested" read only and I have used a UI Policy. However, it doesn't seem to be working correctly.
Any ideas?
Thanks,
Mallika
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 06:44 PM
Hello @Mallika Bhupath
In addition to my previous answer:
- This is because an onChange client script is in action.
- To auto-populate the requested_for field with logged in user an onload client script is required.
- If requested_for field is already populating correctly then look for onload catalog Client script and add a code in it:
g_form.setValue("user_for_whom_a_new_signature_is_being_requested",'requested_for');
Note: Add this line after the requested_for field is set.
"If you found my answer helpful, please like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 06:26 PM
Hi @Mallika Bhupath ,
you can write Onchange client script on requested for field and use below script to set the same value.
g_form.setValue(‘new field name’, newValue);
to make read only field you can write ui policy.
Accept the solution if it helped
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 07:12 PM
Hello @Mallika Bhupath
The issue is both the fields are of different type, one is reference and the other one is single line text. In this case we cannot directly set the value from "Requested for" field to "User for whom a new signature is being requested".
Steps:
- Make both the field reference type, referencing to same table.
- create an onchange client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
g_form.setValue("user_for_whom_a_new_signature_is_being_requested",newValue);
}
- Result:
Note: newvalue in client script will return the sys_id
- ReadOnly can be set in form itself
Hope this helps!
"If you found my answer helpful, please give it a like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 09:44 AM
Hi @Juhi Poddar ,
Thanks for the reply.
The script is working okay however, the field is only populating when Requested for is changed and not with the logged in user. Any way I can modify this script?
Thanks,
Mallika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 09:55 AM
Hello @Mallika Bhupath
Glad that you were able to achieve the requirements. However I have not added anything regarding logged in user as nothing was mentioned about it. If you need any help please drop your query here.
Thank you
Juhi Poddar