I have a workflow webhook with a JSON body. I...

(David Weinberg) #1

I have a workflow webhook with a JSON body. I have included fields that may or may not have a value as below:

{

“UUID”: “<<[InputID]>>”,

“Date”: “<<[CallDate]>>”,

“JobType”: <<[Job Type]>>,

“SubType”: <<[Sub type]>>, //Optional field

“Description”: “<<[Fault/Description]>>” }

The result is that the JSON sent looks like: {

“UUID”: “ABC-123”,

“Date”: “2018-05-21T11:45”,

“JobType”: 1,

“SubType”: , // Not specified number

“Description”: “” // not specified text }

But this is not being seen as valid JSON as by the receiving system since

“SubType”: , does not have a value. Is there a way to put a 0 placeholder or suppress the line when the value is blank?

Thanks,

David

(David Weinberg) #2

After working with Appsheet support I discovered that one can use expressions as part of the template as long as they are sounded by << >>. With this, I now have the following template:

{

“UUID”: “<<[InputID]>>”,

“Date”: “<<[CallDate]>>”,

“JobType”: <<IF(ISNOTBLANK([Job Type]),[Job Type],0)>>,

“SubType”: <<IF(ISNOTBLANK([Sub type]),[Sub type],0)>>,

“Description”: “<<[Fault/Description]>>” }

(Praveen Seshadri (AppSheet)) #3

Right! Expressions inside workflow templates make things much more expressive!

(David Weinberg) #4

Is there a way to make the line optional? i.e. if the value is blank, skip the whole line? I tried but came unstuck with the field name, it was coming out at litterally:

“JobType”: 123

(Praveen Seshadri (AppSheet)) #5

No, for that, we need to provide some kind of <> expression. It would be useful but we don’t have that yet.