GlideRecord in Script Include - Dot walking

Justin Lee2
Tera Guru

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

 

 

1 ACCEPTED SOLUTION

Elijah Aromola
Mega Sage

Can you try: 

type: rec.apm_application_profile_indicator.apm_metric.x_acce8_workfit_workfit_heat_type + "",

View solution in original post

6 REPLIES 6

Thank's Justin

Elijah Aromola
Mega Sage

Hey, Dave. What @Justin Lee2 said is essentially what happens. If you don't specifically convert to a string through type coercion such as (value + "") or toString(), you will get an object.