Convert return format query to DOCUMENT type

Good morning,

I’m using Apex Chart to show data and I have some problems trying to populate data series with a query.

If I use a Tag History I’m able to show it selecting the tag, setting to Value Format to “DOCUMENT” and add a configure trasform for having as result t_stamp as 0 index and tag_name as 1 index.

Annotation 2022-08-12 112932

The “problem” is that if I bind the data property to a Query I’m not able to select DOCUMENT as Return format.

Is there any way to convert a dataset to a document and have the same result as with Tag History?

Thank you for the help

Have you tried using the json format?

return [[row['t_stamp'], row['otherColumn']] for row in system.util.jsonDecode(value)]
1 Like

Thanks for the reply… I’ve just tried, but it returns this error:

TypeError: jsonDecode(): 1st arg can’t be coerced to String

Force the value to a string type.

return [[row['t_stamp'], row['otherColumn']] for row in system.util.jsonDecode(str(value))]

Document and JSON return format should be equivalent; I don’t think you need to manually encode or decode, or at least you shouldn’t.

1 Like

I don’t know what I was looking at, you are right because actually the chart works good with JSON return format, I do apologize with all of you for the mistake.

1 Like