We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Access data resource from script that sets the value of a component property - UI Builder

Costas Loupas
Tera Expert

I have an aggregate data resource that returns a json object:

{  "data": {    "GlideAggregate_Query": [      {        "count": 409      }    ]  }}

On my page i have a stylised text component and i can bind the output of the DR to its text property:

@Data.aggregation_query_1.output.data.GlideAggregate_Query.0.count

However i am not able to access the DR from within the scripted property value script using the api 

e.g. var val = api.data.aggregation_query_1.output.data.GlideAggregate_Query.0.count;

Intellisense gets lost after api.data.aggregation_query_1

Am i doing something wrong?(I guess so)

Is it possible? If yes how?

 

Thanks!

1 ACCEPTED SOLUTION

Costas Loupas
Tera Expert

I just realised what was wrong:

var val = api.data.aggregation_query_1.output.data.GlideAggregate_Query.0.count;

The array reference is not right, the correct syntax is:

var val = api.data.aggregation_query_1.output.data.GlideAggregate_Query[0].count;

View solution in original post

2 REPLIES 2

Costas Loupas
Tera Expert

I just realised what was wrong:

var val = api.data.aggregation_query_1.output.data.GlideAggregate_Query.0.count;

The array reference is not right, the correct syntax is:

var val = api.data.aggregation_query_1.output.data.GlideAggregate_Query[0].count;

Joseph2
Tera Contributor

Did this work?  I am trying it in a script