Include first value in array of values


#1

How do I format my include parameter in a Fetch API call such that I only return the first value (latest value) in an array of values?

For context, I have a type that contains characteristics which stores history and I want to only return the 0th data element in that array.

I’ve tried doing characteristics.(name == ‘<CHAR_NAME>’)[0].value in my include parameter, but I get an error saying this operation is not supported by the include parameter. I have seen this syntax used in other cases such as stored calculations.

Thanks.


#2

Hi Andrew, have you tried the “asOf” parameter? You can populate today’s date. For example:
{“spec”: {
“filter”: “parent.id == ‘SOME ID’ && name == ‘CHAR NAME’ && value != ‘00000’”,
“asOf”: “2018-09-25T00:00:00.000”,
“include”: “value”
}}


#3

one way would be to use projections, e.g.

c3Grid(Facility.evaluate({projection: 'name, children[0]'}))

#4

Hi Sam,

Yes, totally forgot about the asOf parameter. Thanks!


closed #5