I have built a flow that will create a Dynamics 365 task when I copy an email (the "Target Email") to a specific folder in Outlook 365. The flow is working so far, but I am trying to make 2 enhancements and am not sure how to get them done. The current, working flow is below.
I would like to check the D365 Contact entity for the presence of the Target Email's recipient, which could be in emailaddress1, emailaddress2 or emailaddress3. If the email address exists, I would like to set the task's Regarding field to the relevant Contact. I assume I need to grab the contactid of the relevant Contact to facilitate this, but I don't know how to accomplish that. Once I have the contactid, is it as simple as inserting that variable into the task's Regarding field, or is there more to it?
There is one more complication that I can't figure out. The Target Email may have multiple recipients. How do I isolate each email address so that I can create a separate task for each, and check each one against the Contact database per the paragraph above?
Thanks for the help!
Solved! Go to Solution.
Hi @GurBAL
After initialise mapping add a compose and do a split against the initialise variable.
Can we do a screen share please? That will be much easier.
Thanks
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogHi @GurBAL
To get the contact details you need to filter by email address 1, 2, and 3.
See below
Here I am assuming email address will be unique in your contact lists.
The expression I used to find the count is as follows
The expression I used for the above compose 2 is as follows:
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogThanks so much for the guidance @abm! I have tried implementing your solution but am doing something wrong. I am getting the following error: "The inputs of workflow run action 'Compose' of type 'Compose' are not valid. The variable 'EmailAddresses' must be initialized before it can be used inside action 'Compose'."
I added your 'split' subroutine first, then added the 'filter' subroutine. See steps below. I played around with the variable EmailAddress a bit but it didn't fix anything. I tried initializing it as "a@a.com;b@b.com@;c@c.com" and as the output of "Grab Recipients", and also tried Set Variable for EmailAddress to Grab Recipients.
Here is the state of that section of the flow:
Hi @GurBAL
Thanks for your reply. Looks like your Set Variable mapping to an output of some other compose. Is this need to change to the previous step which is intialise variable.
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogI'm not following that. Sounds like you're saying that I need to make the Value of the Set Variable step equal to Initialize Variable step? When I try that, I get this error: "The inputs of workflow run action 'Set_variable' of type 'SetVariable' are not valid. Self reference is not supported when updating the value of variable 'EmailAddress'."
Also, I should note that I didn't see a Set Variable step in your initial post. I added it while I was troubleshooting (although it didn't fix anything).
Hi @GurBAL
Could you post a screen shot of your full flow and run time history where which step is failing?
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogI took screenshots of the current flow, and of the results of a test run. Here is the current flow:
And here are the results of the run test:
Hi @GurBAL
Thanks for the screenshot. Could you please tell me after the initialize variable you are setting variable name value to some other output? You already initialised with certain values and replaced immediately after the next step? Which ever output you are mapping is not having a comma separated values hence its not returning as array for the split and getting the flow error.
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blog
@abm wrote:Hi @GurBAL
... Could you please tell me after the initialize variable you are setting variable name value to some other output? ...
That is set to the output of the "Grab Recipients" step. You didn't have a Set Variable step in your suggestion, and I wasn't sure if one was necessary after an Initialize Variable step. So when the flow wasn't working, I added the Set Variable step to see if it solved the problem (which it didn't).
Do I need to Set a variable after I initialize it, or should I just delete it? If not, is the string in the Initialize Variable step correct? I have "a@a.com;b@b.com@;c@c.com", which I copied from your example. The 'at' signs look oddly placed, and I don't know if this will work when I have a recipient with a domain that isn't dotcom.
Thanks!
Hi @GurBAL
You can delete this step and directly map the values under the initialise. Yes that was a typo from my side. You need to make sure Grab Recipients returns with similar format where you can split the values after using the semi-colon. If you need a screen share and fix please send me the details by email.
Thanks
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogMaking progress! I have cleaned it up, but the test is still failing at the 'split' formula. I get this error:
"ExpressionEvaluationFailed. The execution of template action 'Apply_to_each_email_address' failed: the result of the evaluation of 'foreach' expression '@outputs('Split_EmailAddress')' is of type 'String'. The result must be a valid array."
But when I change that to array, I get the following error at the step that initializes the email address variable:
"BadRequest. The variable 'EmailRecipients' of type 'Array' cannot be initialized or updated with value 'recipient@contoso.com' of type 'String'. The variable 'EmailRecipients' only supports values of types 'Array'."
Hi @GurBAL
After initialise mapping add a compose and do a split against the initialise variable.
Can we do a screen share please? That will be much easier.
Thanks
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogPMing you screenshare details now...
Hi @GurBAL
Thanks for the screen share. Hope it was useful. If you have any more questions please post it. It's an awesome community.😀
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogUser | Count |
---|---|
101 | |
36 | |
29 | |
25 | |
16 |
User | Count |
---|---|
132 | |
54 | |
53 | |
37 | |
26 |