Name-Value Pairs field - GlideRecord call to a numbered name returns undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2019 09:27 AM
Hello all,
I have a Name-Value Pairs field set up for a custom table. The values are as follows:
When I call this particular record via GlideRecord and try to get the value of the name "1", it returns undefined. Fortunately, I can get around this by creating a variable and running a JSON.parse() on the field.
BACKGROUND SCRIPT CODE
var gr = new GlideRecord("random_table");
gr.get("4d3b6e1cdba83b0085539c78db961926");
var parsed = JSON.parse(gr.local_state_values);
gs.info("Local State Values == " + gr.local_state_values);
gs.info("Local State Values [1] == " + gr.local_state_values[1]);
gs.info("Local State Values [\"1\"] == " + gr.local_state_values["1"]);
gs.info("Local State Values [\"New\"] == " + gr.local_state_values["New"]);
gs.info("Parsed variable == " + parsed);
gs.info("Parsed variable [1] == " + parsed[1]);
gs.info("Parsed variable DOT New == " + parsed.New);
RESULT
random_table: Local State Values == {"1":"random","New":"30","In Progress":"32","On Hold":"34","Resolved":"36","Closed":"38","Cancelled":"39"}
random_table: Local State Values [1] == undefined
random_table: Local State Values ["1"] == undefined
random_table: Local State Values ["New"] == 30
random_table: Parsed variable == [object Object]
random_table: Parsed variable [1] == random
random_table: Parsed variable DOT New == 30
Is this an intended behavior? I would've thought that this Name-Value Pair field type would be an object rather than a string.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2019 04:27 PM
it works with my code even with numbered names.
What's code you are trying to execute?
Regards.
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2019 05:39 AM
Hello again, sorry for confusion, but it is only refers to dot notation and not the bracket notation. Try to check your code with different code editor and make sure all properties are inside quotes.