I'm trying to build a condition where we check if message body contains a text.
Exception: The input parameter(s) of operation 'Condition' contains invalid expression(s). Fix invalid expression(s) for the input parameter(s) of operation 'Condition'.
I've tried the following so far and seeing the above exception.
1. triggerOutputs()?['body/body'] contains "text in quotes"
2. triggerOutputs()?['Body'] contains "text in quotes"
3. item()?['body'] contains "text in quotes"
Screenshot:
Code:
⚠️Note that I tried saving each condition in isolation but it still showed the same exception.
{
"type": "If",
"expression": {
"and": [
{
"contains": [
"@triggerOutputs()?['body/body']",
"requested your review on"
]
},
{
"equals": [
"@triggerOutputs()?['Body']",
"requested your review on"
]
},
{
"equals": [
"@item()?['body']",
"requested your review on"
]
}
]
},
"actions": {
"Get_my_profile": {
"type": "OpenApiConnection",
"inputs": {
"host": {
"apiId": "/providers/Microsoft.PowerApps/apis/shared_office365users",
"connection": "shared_office365users",
"operationId": "MyProfile_V2"
}
}
},
"Create_event": {
"type": "OpenApiConnection",
"inputs": {
"parameters": {
"table": "Yashaswi Tamta",
"item/subject": "Timeblock for PR review",
"item/start": "@addHours(triggerOutputs?['body']?['receivedDateTime'],1)",
"item/end": "@addMinutes(triggerOutputs?['body']?['receivedDateTime'],30)",
"item/timeZone": "(UTC-08:00) Pacific Time (US & Canada)",
"item/showAs": "busy"
},
"host": {
"apiId": "/providers/Microsoft.PowerApps/apis/shared_office365",
"connection": "shared_office365",
"operationId": "V4CalendarPostItem"
}
},
"runAfter": {
"Get_my_profile": [
"Succeeded"
]
}
}
},
"else": {
"actions": {}
},
"runAfter": {}
}
Hello @tamta
I am looking at it, but I see value as the Object, so you would need that in there, not simply body as body isn't (at least what you shared), the Objects, Parent.
So when I take what you gave me and put that in a variable, for me to get the bodyPreview it looks like this.
Because I use my variable, and value is the parent, and there is ONLY 1 "value instance" so its [0] in the array and then I can access the bodyPreview.
variables('varYashResponse')['value'][0]['bodyPreview']
So depending on what you have you may need
triggerOutputs()?['body/value/bodyPreview']
or if yuou get it outside the trigger something like
body[0]['bodyPreview'] or a variable of
That all being said, there is another way. Which may just help you (if the above does not, as I said I am going off of what I see)
Steps.
1. If you are certain of the Payload do this
Add a Parse JSON right after the trigger
in the Input put,
triggerOutputs()?['body']['value']
Click the button for generate Sample Schema. But instead paste this sample (I removed the value layer)
{
"id": "AQMkAGZkMWJlYWUyLTkxZWMtNDhiMC04ZWMyLTMwYjRjMDUzYjk2MwBGAAADHwv3mfjyrEiDQiARmebylgcAvO5NUuoeAU6PYn3SVy6T-QAAAgEMAAAAvO5NUuoeAU6PYn3SVy6T-QACW5pXZgAAAA==",
"receivedDateTime": "2023-09-29T22:01:20+00:00",
"hasAttachments": false,
"internetMessageId": "<SA0PR02MB7273C9BC9EB84A0F81C863AFB5C0A@SA0PR02MB7273.namprd02.prod.outlook.com>",
"subject": "Testing automation",
"bodyPreview": "someone requested your review on: this PR",
"importance": "normal",
"conversationId": "AAQkAGZkMWJlYWUyLTkxZWMtNDhiMC04ZWMyLTMwYjRjMDUzYjk2MwAQAEhnF9w-uSxOjQ5qZvVcwYc=",
"isRead": false,
"isHtml": true,
"body": "<html><head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><style type=\"text/css\" style=\"display:none\">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style></head><body dir=\"ltr\"><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:11pt; color:rgb(0,0,0)\"><span style=\"letter-spacing:normal; font-size:15px; font-weight:400; color:rgb(36,36,36); background-color:rgb(255,255,255)\">someone requested your review on: this PR</span></div></body></html>",
"from": "tamta@adobe.com",
"toRecipients": "tamta@adobe.com",
"ccRecipients": "review_requested@noreply.git.corp.adobe.com",
"attachments": []
}
Now add a compose
Click it and in the dynamic property windows you see bodyPreview
SIDENOTE: To be honest.. I am surprised you dont see value or these fields under the Trigger (as dynamic properties already). Can you take a picture of your dynamic properties available to you? Just add a compose and click.
Anyway, now in the compose click and in the Dynamic Properties, you will see bodyPreview straight up..
Click on bodyPreview
and I run my flow. and bingo your value.
There are many ways to get it.. I believe the first one I gave you by adding in value is the correct on. but this one would work too. Assuming we have the correct information
Cheers
If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
Thank You
Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
https://gernaeysoftware.com
LinkedIn: https://www.linkedin.com/in/michaelgernaey
Hi @Nived_Nambiar, thanks for your response.
The goal of this automation is to create calendar events for emails from a particular sender containing particular text.
I've added the following trigger, but the tests are failing can you help me debug this.
Trigger: triggerOutputs()?['body/bodyPreview']
Targetting the following response
{
"value": [
{
"id": "AQMkAGZkMWJlYWUyLTkxZWMtNDhiMC04ZWMyLTMwYjRjMDUzYjk2MwBGAAADHwv3mfjyrEiDQiARmebylgcAvO5NUuoeAU6PYn3SVy6T-QAAAgEMAAAAvO5NUuoeAU6PYn3SVy6T-QACW5pXZgAAAA==",
"receivedDateTime": "2023-09-29T22:01:20+00:00",
"hasAttachments": false,
"internetMessageId": "<SA0PR02MB7273C9BC9EB84A0F81C863AFB5C0A@SA0PR02MB7273.namprd02.prod.outlook.com>",
"subject": "Testing automation",
"bodyPreview": "someone requested your review on: this PR",
"importance": "normal",
"conversationId": "AAQkAGZkMWJlYWUyLTkxZWMtNDhiMC04ZWMyLTMwYjRjMDUzYjk2MwAQAEhnF9w-uSxOjQ5qZvVcwYc=",
"isRead": false,
"isHtml": true,
"body": "<html><head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><style type=\"text/css\" style=\"display:none\">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style></head><body dir=\"ltr\"><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:11pt; color:rgb(0,0,0)\"><span style=\"letter-spacing:normal; font-size:15px; font-weight:400; color:rgb(36,36,36); background-color:rgb(255,255,255)\">someone requested your review on: this PR</span></div></body></html>",
"from": "tamta@adobe.com",
"toRecipients": "tamta@adobe.com",
"ccRecipients": "review_requested@noreply.git.corp.adobe.com",
"attachments": []
}
]
}
Let me know what's the right way to run the 'contains' operation on this email body text.
Regards,
Yash
Hi @tamta
One question, why you have used item() expression, normally it is used in loop or select or filter array action to represent an iteration unit? may i know why you have used it to help to resolve the issues ?
Nived N 🚀
LinkedIn: Nived N's LinkedIn
YouTube: Nived N's YouTube Channel
🔍 Found my answer helpful? Please consider marking it as the solution!
Your appreciation keeps me motivated. Thank you! 🙌