How to set the value in read only string field?

Akshaya14
Tera Contributor

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);

}

Akshaya14_0-1673349555968.pngAkshaya14_1-1673349609080.png

 

Thanks

 

@Ankur Bawiskar , @Mitul , 

3 REPLIES 3

Vasantharajan N
Giga Sage
Giga Sage

@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

Voona Rohila
Kilo Patron
Kilo Patron

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Akshaya14 

why are you making it readonly first?

first set the value and then make it readonly

share complete scripts

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader