How to set the value in read only string field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 02:58 AM - edited 01-10-2023 03:20 AM
Hi All,
I have script include where I can get group type, group manager name in client script I am doing validation everything working fine from script include getting group manager name , I am trying to set the value in read only variable in alert it show the name but in variable it show empty.
notes: working fine in UI but in portal we face this issue
in script include:
userObj.grManagername = gr.manager.getDisplayValue();
in client script:
var name = userObj.grManagername;
alert("name :" + userObj.grManagername);
if (type == 'Security') {
//alert('inside security');
g_form.setValue('group_owner',name);
}
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 03:31 AM
@Akshaya14 Try setting the sys_id and display value for the reference variable and check.
g_form.setValue('field_name', 'sys_id', 'display_value');
#Example
g_form.setValue('location', '25ab9d720a0a0bb300793d3a6b891f82', '6304 Northwest Barry Road, Kansas City,MO');
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 04:55 AM
HI @Akshaya14
Can you share complete client script logic you tried.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 05:27 AM
why are you making it readonly first?
first set the value and then make it readonly
share complete scripts
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader