- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2021 12:03 AM
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
Solved! Go to Solution.
- Labels:
-
Script Debugger
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2021 01:41 AM
setValue() is a method in GlideRecord() class. Official document is available in ServiceNow's GlideRecord api reference.
setValue(String name, Object 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2021 12:13 AM
gr.setValue('field_name','field_value');
here your A and B are actually what I have mentioned above.
Example for reference:
var gr = new GlideRecord('planned_task');
gr.setValue('state', -5);
Mark my ANSWER as CORRECT and HELPFUL fi it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2021 11:19 PM
Hi NOW,
if you need anymore help let me know , else can you Mark my ANSWER as CORRECT if it served your objective
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2022 01:27 AM
var gr =new gliderecord("incident");
gr.getvalue("state",=-3 );
this statement is not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2022 02:58 AM
There's not state = -3 by default. "On hold" is 3.
var gr =new gliderecord("incident");
gr.getvalue("state", -3); // there's no "-3" OOTB