cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate V
Advocate V

How to write expression with multiple conditions

Hi All,

 

I have setup a flow that will update the subscriber data from mailchimp audience list to Microsoft Dynamics 365 online. 

Below are the mailchimp fields captured in Flow:

Note: When a subscriber updates his\her newsletter subscription in Mailchimp the type field has a value = profile

{
"type": "unsubscribe",
"fired_at": "2020-02-07 05:18:04",
"data[merges][CONTACTYPE]": "Individual",
"data[merges][FIRSTNAME]": "Tara",
"data[merges][LASTNAME]": "Simpson",
"data[merges][EMAIL]": "tarasimpon@yopmail.com",
"data[merges][ORG]": "Galaxy",
"data[merges][POSTCODE]": "1000"
}

 

Below are custom newsletter fields setup in Dynamics:

 

Newsletter_Fields.JPG

 

I need help on how to write an expression or setup the conditions action to update the fields in Dynamic based on the type field in mailchimp.

Condition 1 in the list below triggers when a new subscribers, subscribes to a newsletter.

Condition 2\ 3, trigger when a subscriber updates profile or unsubscribes from the newsletter.

 

1 - IF the type field has value of subscribe ("type": "subscribe") THEN Newsletter Status = subscribe AND the Newsletter Subscription Date = "fired_at": "2020-02-07 05:18:04".

 

2 - IF the type field has value of profile ("type": "profile") THEN Newsletter Status = subscribe AND the Newsletter Update Date = "fired_at": "2020-02-07 05:18:04".

 

3 - IF the type field has value of unsubscribe ("type": "unsubscribe") THEN Newsletter Status = subscribe AND the Newsletter Unsubscription Date = "fired_at": "2020-02-07 05:18:04".

 

There is a possibility that a subscriber can unsubscribe from a newsletter and might subscribe again. In this case Newsletter unsubscription date field should be reset to blank and update the Newsletter subscription date to the new fried_date.

 

Regards,

Jag

1 REPLY 1
Highlighted
Super User
Super User

Re: How to write expression with multiple conditions

Hi @jasb81 

 

First you need to Parse the JSON object (Profile) then check the type. Here are the steps:

 

image.png

 

Above schema is as follows:

{
"type": "object",
"properties": {
"type": {
"type": "string"
},
"fired_at": {
"type": "string"
},
"data[merges][CONTACTYPE]": {
"type": "string"
},
"data[merges][FIRSTNAME]": {
"type": "string"
},
"data[merges][LASTNAME]": {
"type": "string"
},
"data[merges][EMAIL]": {
"type": "string"
},
"data[merges][ORG]": {
"type": "string"
},
"data[merges][POSTCODE]": {
"type": "string"
}
}
}
 
Next step is generate the firedat value.
 
image.png
 
The expression used above is 
 
formatDateTime(utcNow(), 'yyyy-MM-dd hh:mm:ss')
 
Next check the condition
 
image.png
 
Here under the Yes/No condition you can use the Dyamics update record action and set the Fired at value under the appropriate fields. 
 
For updating a null value you can use the expression null to set against the fields.
 
image.png
 
Thanks


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (10,626)