3
votes

In Logic Apps, I have an expression:

coalesce(triggerbody().data.job_id,triggerbody().resource_id,'error')

I basically want to get the first one that is not null, however one of these does not EXIST in the json payload. I get an error:

'The template language expression 'coalesce(triggerbody().data.job_id,triggerbody().resource_id,'error')' cannot be evaluated because property 'data' doesn't exist, available properties are 'transaction_id, event_type, event_time, resource, resource_id, account_id, resource_third_party_id, request_user_type, request_user_id'. Please see https://aka.ms/logicexpressions for usage details.'.

If data doesn't exist, that value should be "null" and resource_id used. Any ideas what the expression would look like to have that behaviour?

1

1 Answers

2
votes

The problem here is that you are trying to access to a property of a null element:

coalesce(triggerbody().data.job_id,triggerbody().resource_id,'error')

As triggerbody().data is null, Logic App can't evaluate triggerbody().data.job_id, you should check first if triggerbody().data is null.