Need help with creating my first Azure Logic App

Saurabh Dhuri (Student) 0 Reputation points
2024-08-06T09:22:16.75+00:00

I want to create new Azure Logic app with following steps: step 1- send an email action

step 2- condition to check the given email_body is empty or not

step 3- condition to check given date is greater than current date.

    concat(substring(triggerBody()?['email_date'], 6, 4), '-', substring(triggerBody()?['email_date'], 3, 2), '-', substring(triggerBody()?['email_date'], 0, 2))

step 4- add a switch case within step 2

you need to add two cases case1. email approved case2: email rejected

if case 1 is true then send an email if not then do not send an email. Initially I started with Https trigger but and outlook 365 triggers but I couldn't built it successfully can someone please guide me step by step? Also am using postman for simulating request (HTTP trigger)

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
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vlad Costa 1,565 Reputation points
    2024-08-07T10:30:37.5733333+00:00

    Hi @Saurabh Dhuri (Student)

    I can try to help you create an Azure Logic App using the steps you’ve outlined. Try this approach:

    Create a new Logic App:

    • Go to the Azure portal, navigate to “Logic Apps,” and create a new Logic App.

    Add an HTTP trigger:

    • Choose the “When an HTTP request is received” trigger. This will allow you to simulate requests using Postman.

    Step 1: Send an email action:

    • Add a new step and select the “Office 365 Outlook—Send an email” action. Configure the email details (To, Subject, Body, etc.).

    Step 2: Condition to check if the email body is empty:

    • Add a condition action.
      • Set the condition to check if the email_body is empty: @empty(triggerBody()?['email_body']).

    Step 3: Condition to check if the given date is greater than the current date:

    • Add another condition action within the “If true” branch of the previous condition.
      • Use the expression:
             @greater(concat(substring(triggerBody()?['email_date'], 6, 4), '-', substring(triggerBody()?['email_date'], 3, 2), '-', substring(triggerBody()?['email_date'], 0, 2)), utcNow())
        

    Step 4: Add a switch case within step 2:

    Within the “If true” branch of the second condition, add a “Switch” action.

    • Set the switch to evaluate the email_status (or a similar field).

    Add cases to the switch:

    • Case 1: Email Approved:
      • Add a case with the value “approved”.
      • Within this case, add an action to send an email (similar to step 1).
    • Case 2: Email Rejected:
      • Add a case with the value “rejected”.
      • No action is needed here if you don’t want to send an email.

    Test your Logic App:

    • Save and run your Logic App.
    • Use Postman to send HTTP requests to your Logic App’s endpoint to test the workflow.

    If this answers your question, please click Accept Answer and Yes if this answer was helpful. Doing so would help other community members with similar issues identify the solution. I highly appreciate your contribution to the community.

    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.