cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GurBAL
Advocate I
Advocate I

Search For Text in Outlook 365 Task Description

I am trying to write a flow that will return Outlook 365 tasks whose Description field contains a specific text string.  So far, no luck.  The flow doesn’t fail, but it also doesn’t return the matching task (which I know exists). 

See screenshot below.  This is just a section of the flow.  It triggers when a new email is received in the Inbox, and then checks to see if the sender is a Contact in Dynamics 365.  If so, it looks for a matching task in Dynamics using the text string.  That side of the flow is working fine.  If the sender is not in D365, it looks for a matching task in Outlook 365.  The string variable “Hash” is just a concatenation of the email’s Conversation ID and sender, which was placed in the task’s body when the task was created by a separate flow (if it matters, the string is about 95-125 characters long and has no spaces). 

The “List all tasks” action returns all tasks, but the Condition “Body contains Hash” returns false for every task record.  And I know that the string exists in one of the tasks.  Any suggestions as to what I am doing wrong, and how to fix it?  Or if there is a better way to identify tasks in Outlook 365 that have a specific text string somewhere in the Description/Body field?  Thanks!

Flow monitor Outlook 20200319-1.png

2 ACCEPTED SOLUTIONS

Accepted Solutions
abm
Super User III
Super User III

Hi @GurBAL 

 

Thanks for the screen share. Following are the steps we did to achieve your solution.

 

1. Use Parse JSON object to extract the schema details.

2. Change the hashtag and content text to lowercase for comparison. 

 

If you have anymore questions please let me know.

 

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 blogPower Automate Video Tutorials

View solution in original post

Hi @GurBAL,

 

Are you case-sensitive of the hashtag? There is my test instance, "This is a test hashtag":Annotation 2020-03-23 154326.png

 

If I set the Hash variable to "hash", the condition could find the task, and it works perfectly. But if the is A capital "Hash", it won't work:

Annotation 2020-03-23 154327.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

11 REPLIES 11
abm
Super User III
Super User III

Hi @GurBAL 

 

Change the condition mapping from Body to Body content

 

image.png



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 blogPower Automate Video Tutorials

What's up @abm!  Thanks for chiming in again.  I made that change, but the result was the same.  The flow runs successfully, but the Condition returns False for every task.  I checked the Body of the "List all tasks" step, and the Hash is in there. 

abm
Super User III
Super User III

Hi @GurBAL ,

 

Could you please check your run history and make sure the hash content is there? Also if you could post a screenshot of the hash and body content text that will be helpful.

 

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 blogPower Automate Video Tutorials

Also, I can't select "Body Content" in the "Apply to each" step, only in the "Condition" step.  

abm
Super User III
Super User III

Hi @GurBAL 

 

Think that's correct because body has content and type. So when you select body in apply to each you can get body content and type.

 

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 blogPower Automate Video Tutorials


Could you please check your run history and make sure the hash content is there? Also if you could post a screenshot of the hash and body content text that will be helpful.

From the run history, here is the Hash:

AAQkAGNkZGE3YmM3LTFhOGQtNGY5YS04NTY1LTMxMDE3YzY5ZjU4MgAQABszsJ39c024i9wIXhK5hxM=xxxx@xxxx.com

 

And here is an excerpt of the "List all tasks" action, which includes the Hash text:

  {

    "@odata.id": "https://outlook.office.com/api/v2.0/Users('a2ba06e1-f27a-4a89-8e1f-366aa1de6350@3575f9a1-6876-4442-a...')",

    "@odata.etag": "W/\"LmtxOxy4u0yqeqS5OdWN1wAA3ggKgg==\"",

    "Id": "AAMkAGNkZGE3YmM3LTFhOGQtNGY5YS04NTY1LTMxMDE3YzY5ZjU4MgBGAAAAAAAjctzodOlzRJmL-zntuYUiBwAua3E7HLi7TKp6pLk51Y3XAAAAAAESAAAua3E7HLi7TKp6pLk51Y3XAADeUNmfAAA=",

    "CreatedDateTime": "2020-03-19T20:26:27.0867035Z",

    "LastModifiedDateTime": "2020-03-19T20:26:27.5267652Z",

    "ChangeKey": "LmtxOxy4u0yqeqS5OdWN1wAA3ggKgg==",

    "Categories": [],

    "AssignedTo": "",

    "HasAttachments": false,

    "Importance": "Normal",

    "IsReminderOn": true,

    "Owner": "JoeUser",

    "ParentFolderId": "AQMkAGNkZABhN2JjNy0xYThkLTRmOWEtODU2NS0zMTAxN2M2OWY1ODIALgAAAyNy3Oh06XNEmYv-Oe25hSIBAC5rcTscuLtMqnqkuTnVjdcAAAIBEgAAAA==",

    "Sensitivity": "Normal",

    "Status": "NotStarted",

    "Subject": "Email follow-up: xxxx@xxxx.com (Testing task: BAL to VICR and HoG 3:24ct)",

    "Body": {

      "ContentType": "HTML",

      "Content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\n<p>This is an automated task created by Flow. &nbsp;If a response is received to your email before you have marked this task complete, this task will be marked complete and notated. &nbsp;<br>\r\n<br>\r\nRecipient: xxxx@xxxx.com<br>\r\nSubject: Testing task: BAL to VICR and HoG 3:24ct<br>\r\nEmail Sent: 2020-03-19T20:25:00&#43;00:00<br>\r\nAll Recipients: xxxx@xxxx.com;zzzz@zzzz.com<br>\r\nConversation ID: AAQkAGNkZGE3YmM3LTFhOGQtNGY5YS04NTY1LTMxMDE3YzY5ZjU4MgAQABszsJ39c024i9wIXhK5hxM=<br>\r\nHash (ID&#43;Recipient): AAQkAGNkZGE3YmM3LTFhOGQtNGY5YS04NTY1LTMxMDE3YzY5ZjU4MgAQABszsJ39c024i9wIXhK5hxM=xxxx@xxxx.com</p>\r\n</body>\r\n</html>\r\n"

    },

    "CompletedDateTime": null,

    "DueDateTime": {

      "DateTime": "2020-03-22T00:00:00Z",

      "TimeZone": "UTC"

    },

    "Recurrence": null,

    "ReminderDateTime": {

      "DateTime": "2020-03-22T20:25:00Z",

      "TimeZone": "UTC"

    },

    "StartDateTime": {

      "DateTime": "2020-03-19T00:00:00Z",

      "TimeZone": "UTC"

    }

  },

abm
Super User III
Super User III

Hi @GurBAL 

 

Thank you for the run history. 

 

Could you cleanup the Body Content using HTML to Text Power Automate action step and compare?

 

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 blogPower Automate Video Tutorials

I inserted the HTML to Text action after the List all tasks, but it did not change the outcome.  The second task still contains the Hash, but the condition "Does body contain hash" still returns false for all tasks. 

Below is the updated flow.  The reference in "Clean Tasks" is to body('List_All_Tasks').  The reference in "HTML to text" and "Does Body Contain Hash" is to items('Clean_Tasks').  

Flow monitor Outlook 20200322-1.png

abm
Super User III
Super User III

Hi @GurBAL 

 

Thanks for the screen share. Following are the steps we did to achieve your solution.

 

1. Use Parse JSON object to extract the schema details.

2. Change the hashtag and content text to lowercase for comparison. 

 

If you have anymore questions please let me know.

 

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 blogPower Automate Video Tutorials

View solution in original post

Hi @GurBAL,

 

Are you case-sensitive of the hashtag? There is my test instance, "This is a test hashtag":Annotation 2020-03-23 154326.png

 

If I set the Hash variable to "hash", the condition could find the task, and it works perfectly. But if the is A capital "Hash", it won't work:

Annotation 2020-03-23 154327.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thank you @abm!  I learned a ton during that troubleshooting session.  Let's hope I can retain some of it!

 

@v-litu-msft, you nailed 50% of the problem.  It appears that when Flow grabs the recipient of an email, it retains upper/lower case characters.  But when Flow grabs the sender of an email, it flattens everything to lower case.  In my use case, the Hash that was originally inserted into the task body was created by Flow based on an outbound email using the recipient's email address.  But when the current flow is triggered by inbound email and uses the sender's email address.  So when trying to match a task that was sent to someone with a capital letter in their email address, the condition would fail.  The solution for the inbound-flow was to use the tolower formula on the Hash and the body content from the task to test the condition.  

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Users online (44,931)