- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 12:30 PM
I'm working with GlideRecord in a Script include. (Server side) The query is working correctly, and returning the expected number of results.
However, I need to get some properties of reference values. i.e. I need to dot-walk.
For example:
var rec = new GlideRecord("apm_app_indicator_score");
rec.query();
var obj;
while (rec.next()) {
obj = {
score: rec.indicator_score,
score2: rec.getValue("indicator_score"),
type: rec.apm_application_profile_indicator.apm_metric.x_acce8_workfit_workfit_heat_type,
type2: rec.getValue("apm_application_profile_indicator.apm_metric.x_acce8_workfit_workfit_heat_type")
};
gs.info(JSON.stringify(obj));
}
The code above logs: { "score":{}, "score2":"3", "type":{}, "type2":null }
It appears you need to use getValue() to get properties, but you cannot use it to dot walk.
Is there a way to get child properties or do you have retrieve them with new GlideRecord queries? I understand you cannot dot walk results client side -- but this is server side. Is there a different way to do this?
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 01:00 PM
Can you try:
type: rec.apm_application_profile_indicator.apm_metric.x_acce8_workfit_workfit_heat_type + "",

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 01:00 PM
Can you try:
type: rec.apm_application_profile_indicator.apm_metric.x_acce8_workfit_workfit_heat_type + "",
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 07:06 AM
Ah, ok. That worked. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 01:12 PM
Hi Elija
I know it's been a while since you made this post but I also had a similar problem and you solution solved my problem.
Now, can you please explain why it works? I don't understand how concatenating an empty string to the end makes it work when without that it won't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 01:25 PM
Kinda hard to explain, but I'll give it a shot.
A property (column) on a glide record is a GlideElement. When you convert a GlideElement to a string, what you get is the value of that column. Appending an empty string to an object in javascript will convert the object to a string so it can concat the 2 strings. So in this case, it convert the GlideElement to a string (which results in the value of the property). You could also call .toString() on the element. (ex: glideRecord.some_ref.another_ref.some_field.toString())
If you don't convert it to a string, JSON.stringify will try to stringify the object (GlideElement), and will result in the string "{}". (which is JSON for an empty object with no properties)