Azure Logic App Workflow Testing

Ankit Pal 0 Reputation points
2023-03-22T11:36:38.2966667+00:00

I want to apply the condition when the output/value is null in logic app but unable to achieve please help me out

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sonny Gillissen 3,751 Reputation points Volunteer Moderator
    2023-03-29T06:44:39.1366667+00:00

    Hi Ankit Pal

    Thank you for reaching out on Microsoft Q&A!

    One way of doing this is by using the coalesce() function. This function returns the first not-null value, so if you input your object there followed by an empty string it returns an empty string when the object is empty.

    This is something you can check on using the 'Condition' action, by checking the outcome of the coalesce (your object or an empty string) and add nothing after the "is equal to" as this is an empty string. In this case, when the object is empty - thus an empty string is returned - it jumps to true. When the object is filled - thus not null - it jumps to false.

    User's image

    In the example above I've used the following code, containing the coalesce() function filled with the object I want to test for null values (in this example the ['VALUE'] attribute of the triggerBody), followed by an empty string, making it return an empty string when the value is empty:

    coalesce(triggerBody()?['VALUE'],'')

    You may need to check the 'Run after' settings of the 'Condition' action to meet your requirements, as by default it is only executed on success of the previous action. If this is not the case, because for example your previous action returned an error resulting in the null value you want to check on, you should also enable 'Failed' for the 'Run after' of the 'Condition' action.

    Please note that my answer is full of assumptions, as you did not provide many details on what you're actually try to do. My guess is you could already continu with my example above, but if not feel free to share more specific details so I can help you set up the code when necessary.

    When you find my answer useful please click 'Accept answer' and upvote it.

    Feel free to drop additional queries in het comments below!

    Kind regards,

    Sonny

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.