How do I use gr.setValue();?

NOW
Kilo Contributor

Hi,all

I would like to add a process to insert a record into the description field of an incident in a script.
I understand that I can write the script using the following, but there are two things I would like you to tell me.

1) gr.setValue("A", "B"); ⇐ Please let me know if there is a docs URL that explains this expression. I looked for it, but couldn't find it.

2)I'm not sure what I should put in A and B, so please let me know.

 

Best Regard

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

setValue() is a method in GlideRecord() class. Official document is available in ServiceNow's GlideRecord api reference.

setValue(String name, Object value)

Sets the specified field to the specified value.

Normally a script would do a direct assignment, for example, now_GR.category = value. However, if in a script the element name is a variable, then now_GR.setValue(elementName, value) can be used. When setting a value, ensure the data type of the field matches the data type of the value you enter.

https://developer.servicenow.com/print_page.do?release=paris&category=null&identifier=c_GlideRecordA...

 

View solution in original post

7 REPLIES 7

Vinayak Belgaon
Mega Guru
Mega Guru

You can find all the APIs on developers website.Link below

https://developer.servicenow.com/dev.do#!/learn/learning-plans/quebec/new_to_servicenow/app_store_learnv2_scripting_quebec_gliderecord

 

 

Kindly mark helpful/correct if this resolved your query.

 

Regards

Vinayak

Hitoshi Ozawa
Giga Sage
Giga Sage

setValue() is a method in GlideRecord() class. Official document is available in ServiceNow's GlideRecord api reference.

setValue(String name, Object value)

Sets the specified field to the specified value.

Normally a script would do a direct assignment, for example, now_GR.category = value. However, if in a script the element name is a variable, then now_GR.setValue(elementName, value) can be used. When setting a value, ensure the data type of the field matches the data type of the value you enter.

https://developer.servicenow.com/print_page.do?release=paris&category=null&identifier=c_GlideRecordA...

 

Gaurav Shirsat
Mega Sage

Hello

gr.setValue("A", "B"); for this gr.setValue("Field Name", "Backend Value");

 

https://community.servicenow.com/community?id=community_question&sys_id=44b3cf65dbd8dbc01dcaf3231f96...

https://community.servicenow.com/community?id=community_article&sys_id=e047d880db8c245466f1d9d9689619...

Mark my Response as Correct or Helpful, if you find it Appropriate.
Gaurav Shirsat
https://www.linkedin.com/in/gauravshirsat/