Automatic setting of List type field (ReadOnly) by Client Script OnChange
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 01:05 AM
Hi.
I created a "u_Assigned to (TLAgent)" field in the Change Request table with the following content:
・Label:u_Assigned to (TLAgent)
・Value:u_assigned_to_tl_agent
・Type: List
・Read Only: True
"u_Assigned to (TLAgent)" field is automatically set, Created a Client Script "Set Assign" (On Change).
The content is the user in the "u_TLAgent" field of the Group registered in the Assignment Group,
It is set automatically.
If you set the "u_Assigned to (TLAgent)" field to ReadOnly,
If you do not save the record, the OnChange Client Script will not run,
Setting ReadOnly to False will automatically set the "u_TLAgent" field as expected.
Is this a characteristic of List type fields?
Thank you!
Client Script「Set Assign」(OnChange, trigger:Assignment Group)
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var tlSet = g_form.getReference('assignment_group', callback);
function callback(tlSet) {
g_form.setValue('assigned_to', tlSet.u_tl);
g_form.setValue('u_assigned_to_tl_agent', tlSet.u_tl_agent);
g_form.setReadOnly('u_assigned_to_tl_agent', true);
}
}
Before Record Submit:
Affter Record Submit:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 01:20 AM
you are setting the value and making it readonly and after saving the value is present
Didn't get your exact question
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 02:05 AM
Thank you for your response, Ankur.
I apologize for the poor wording and lack of explanation.
The "u_Assigned to (TLAgent)" field references the User table.
When the ReadOnly property of the "u_Assigned to (TLAgent)" field is set to False, it will behave as shown in the "After Record Submit" screenshot.
However, when the ReadOnly property of the "u_Assigned to (TLAgent)" field is set to True, it will take the form as shown in the "Before Record Submit" screenshot.
I would like to know if this limitation is due to the List type or if it can be resolved through customization.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 02:06 AM
See the below responses I shared with example
That should help you understand the usecase
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 02:14 AM
Thank you for your response.
Could you please specify what you mean by "responses I shared with example"?
Could you also post the URL in this thread?
Thank you very much.