Error when pulling package information

Options

On my gift digest, I would like to show the package id. Since every gift does not include a package, I am getting this error:

Unable to process template language expressions for action 'Condition_2' at line '0' and column '0': 'The template language expression 'first(item()['gift_splits'])['package_id']' cannot be evaluated because property 'package_id' doesn't exist, available properties are 'id, amount, appeal_id, campaign_id, fund_id'. Please see https://aka.ms/logicexpressions for usage details.'.

I tried adding in a condition that if the “package id” was blank, but I still have the above error. This is because the package ID is not a field on gifts that don't include a package.

Anyone else figure out a good way to handle this?

Comments

  • Hey @Amanda Holt, instead of using a conditional to check if the property is blank, try using an expression with an If statement that checks to see if the property is empty. The way I have it set up below returns True if the property is empty or does not exist and false if it does (you may want to reverse those). Then you can use the output of the Compose in your conditional.

    Caveat to this: we don't use that field so I just guessed on what the JSON object looks like. You'll have to construct the actual output for the package_id property.

    c152088d2e8f4145227557c674e8ad91-huge-im
  • @Matt Thacker. I tried that but can't seem to get it to work. Got the error:

    Array elements can only be selected using an integer index

    I think part of the problem is that sometimes the package ID is there and sometimes it is not.

    For example, under “get a gift" here is the result for the first gift in the list:

    2a0b23246ee383abd54a1d2ae763d035-huge-im

    But for the second gift, this is the result:

    ac1329bd30833c791bf53ed9692c4f89-huge-im

    You can see the package ID is not always listed for a gift. It is only included if the package ID has a value.

    Maybe this is unrelated to the error I receive, but it certainly is complicating the flow to account for the difference.

  • @Amanda Holt, does your expression look like this? I didn't realize you were accessing a property in the Gift Splits property. You need to use an array index to access the properties within Gift Splits.

    if(empty(outputs('Get_a_gift')?['body']?['gift_splits'][0]?['package_id']), false, true)

  • @Matt Thacker. That seemed to do the trick. I had used a similar expression but it wasn't working. Thanks so much for the help!

Categories