In a workflow's JSON format, how can I use AppSheet's expression to include or exclude a JSON object? Currently, any value return by expression will be JSON stringify

Say, I want a part of JSON template to be included or excluded based on a condition and that part is a JSON object and not a simple string. Example:

<<IF(TRUE, '{"type": "text\ntext"}', '')>>

Currently, that would return a string with escaped text like
{\"type\": \"text\\ntext\"}

Note that above JSON is hand typing. So it might not have a valid format. Itโ€™s just to give you an idea.

And current workaround is create multiple workflows with different JSON template files but it is only good for templates with one or two condition checks.

One suggestion is to include a JSON type in AppSheetโ€™s column type list. Anything printed from the JSON type will not be escaped (or stringify).

Thanks.

Solved Solved
0 4 1,973
1 ACCEPTED SOLUTION

Unless I am completely misunderstanding your initial post, in your JSON body you can do things like:

{some JSON code}
<<If: (some condition in your table data)>>
{only sometimes JSON code}
<<EndIf>>
<<If: (a different condition in your table data)>>
{only sometimes JSON code}
<<EndIf>>
{more JSON code}

You donโ€™t have to use the IF() from within AppSheet. You could even have multiple different JSON templates inside one file depending on a certain value from your data.

My personal example (JSON sent to Discord):

View solution in original post

4 REPLIES 4
Top Labels in this Space