Set only the approver groups field of list type field to read-only on Change request form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 05:43 AM
I have a list type field on a change request form. I want this field to become read only for all except change managers once the change is submitted.
I am trying to achieve this with the help of onload client script. In that script I have put all conditions and then set the field as readonly by setReadonly as mentioned below. I am not able to use ACL as I have to validate some field values before amking this field as read only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 06:01 AM
Hi @MehakA ,
Can you try with following script in you client script:
if( !gs.hasRole('change_manager') )
{
g_form.setReadonly('list_type_field', true);
}
plz mark this helpful/solution accepted, if this note will gets towards the solution.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2023 05:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 06:06 AM
Hi @MehakA
Is it typo mistake I don't know but It should be :
if (!g_user.hasRole("<role of change manager>")) {
/* make field non mandatory in case empty */
g_form.setMandatory('list_type_field', false);
/* make field read only */
g_form.setReadOnly('list_type_field', true);
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2023 05:55 AM