cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Julien2
Post Prodigy
Post Prodigy

CDS - Get the current comments from Portal Comments entity

Hello,

I am creating a flow that triggers on a case updates inside cases entity using CDS current environment connectors.
In the list records of the Portal Comments, I have filtered to get the case id that was updated.

What I am trying to achieve is the following:
I want to send an email that contains the current comments that were updated. The property of the comments inside the portal comments entity is called "Description". Unfortunately, when I selected from the dynamic contents it creates an apply to each action which I don't want to deal with since I just want the current value.

I have tried to use the following expression to avoid creating apply to each:

first(body('List_records_Portal_Comments')?['value'])?['description']

But also didn't work.
Besides, I cannot map the output of the compose because the send an email action is outside the apply to each action and also if the send an email action will be inside it will send multiple emails which is not a good idea. Also, I just only want the current comment was added to the case and not all of them.

Please have a look at the flow:

Capture.JPGCapture1.JPG

Can please someone provide an example and explain in detail to achieve the following scenario?

Any help will be greatly appreciated.
Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Julien2 ,

 

You could add a Filter Array action as below:

1.png

And you could also take a try with the filter query as below:

2.png

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
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
v-alzhan-msft
Community Support
Community Support

Hi @Julien2 ,

 

Please refer to my screenshot below to create the flow:

1.png

 

Please take a try with expression below:

outputs('Compose')?[0]?['description']

 

Best regards,

Alice       

 

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

Hello @v-alzhan-msft ,

Thanks for providing an example.

I have followed the steps, unfortunately, the email does not return a result using the expression you mentioned.But the compose action value returns the right results.
Please have a look at the screenshots below:

Capture.JPGCapture1.JPGCapture3.JPG
Any idea why it's not working?

Looking forward to your response.
Thank you.

Hi @Julien2 ,

 

Please check the output of the compose field to see if the first record's description is equal to null.

 

Best regards,

Alice       

 

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

Hello @v-alzhan-msft ,

I've checked the output of the compose and as a result, the value mapped inside it does not return something related to the description, so the description is not returned in the JSON result.
Here is one of the JSON results:

[
  {
    "@odata.type": "#Microsoft.Dynamics.CRM.adx_portalcomment",
    "@odata.id": "/api/data/v9.0/adx_portalcomments",
    "@odata.etag": "W/\"31608318\"",
    "@odata.editLink": "adx_portalcomments(3e30f26e-216d-ea11-a811-000d3a64931f)",
    "activityid@odata.type": "#Guid",
    "activityid": "3e30f26e-216d-ea11-a811-000d3a64931f",
    "createdon@odata.type": "#DateTimeOffset",
    "createdon": "2020-03-23T16:15:01Z"
  }
]

As you see description not found in the result.

Any other suggestions?

Looking forward to your response.
Thank you.

Hi @Julien2 ,

 

The output on my side as below:

 

[
  {
    "@odata.id": "https://org1f4c988b.crm5.dynamics.com/api/data/v9.0/adx_portalcomments(8a1b070f-a66d-ea11-a811-000d3a09153d)",
    "@odata.etag": "",
    "ItemInternalId": "8a1b070f-a66d-ea11-a811-000d3a09153d",
    "adx_portalcommentdirectioncode": 1,
    "_adx_portalcommentdirectioncode_label": "Incoming",
    "statuscode": 1,
    "_statuscode_label": "Open",
    "description": "abc",
    "leftvoicemail": false,
    "createdon": "2020-03-24T08:04:19Z",
    "statecode": 0,
    "_statecode_label": "Open",
    "isbilled": false,
    "subject": "test",
    "_ownerid_value": "8c7bffd2-d046-e911-a826-000d3a07fbb4",
    "_ownerid_type": "systemusers",
    "modifiedon": "2020-03-24T08:04:19Z",
    "versionnumber": 5529057,
    "prioritycode": 1,
    "_prioritycode_label": "Normal",
    "isregularactivity": true,
    "ismapiprivate": false,
    "_modifiedby_value": "8c7bffd2-d046-e911-a826-000d3a07fbb4",
    "_modifiedby_type": "systemusers",
    "activitytypecode": "adx_portalcomment",
    "instancetypecode": 0,
    "_instancetypecode_label": "Not Recurring",
    "isworkflowcreated": false,
    "_createdby_value": "8c7bffd2-d046-e911-a826-000d3a07fbb4",
    "_createdby_type": "systemusers",
    "_owningbusinessunit_value": "e2d2e680-fe40-e911-a991-000d3aa14791",
    "_owningbusinessunit_type": "businessunits",
    "activityid": "8a1b070f-a66d-ea11-a811-000d3a09153d",
    "deliveryprioritycode": 1,
    "_deliveryprioritycode_label": "Normal",
    "lastonholdtime": null,
    "_owningteam_value": null,
    "exchangeitemid": null,
    "seriesid": null,
    "deliverylastattemptedon": null,
    "_sendermailboxid_value": null,
    "stageid": null,
    "onholdtime": null,
    "community": null,
    "_community_label": "",
    "sortdate": null,
    "timezoneruleversionnumber": null,
    "_createdonbehalfby_value": null,
    "_transactioncurrencyid_value": null,
    "processid": null,
    "scheduledend": null,
    "_slaid_value": null,
    "_regardingobjectid_value": null,
    "_slainvokedid_value": null,
    "utcconversiontimezonecode": null,
    "exchangeweblink": null,
    "scheduleddurationminutes": null,
    "actualdurationminutes": null,
    "senton": null,
    "scheduledstart": null,
    "actualstart": null,
    "postponeactivityprocessinguntil": null,
    "_modifiedonbehalfby_value": null,
    "exchangerate": null,
    "activityadditionalparams": null,
    "traversedpath": null,
    "actualend": null,
    "_serviceid_value": null,
    "importsequencenumber": null,
    "overriddencreatedon": null
  }
]

 

 

I suggest that you could check from your side to see if the entity has the description column.

Also please take a try to delete the Fetch XML Query to see if the issue still exists.

And I see the List records action on my side is different as yours, the screenshot as below:

1.png

 

Best regards,

Alice       

 

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

Hello @v-alzhan-msft ,

After I have removed the Fetch XML, I get the same results as yours and I am able to find the description inside this entity. But unfortunately, let's suppose i add a comment, the flow fill the description but with a value that is not related to the case id that has been modified. In my fetch XML logic, I am filtering the regardingobjectid eq to caseid (That has been modified) to get the right information on the case.

So instead of FetchXMl, we can use the Filter Query but what would be this query?

Looking forward to your response.
Thank you for your support.

Hi @Julien2 ,

 

You could add a Filter Array action as below:

1.png

And you could also take a try with the filter query as below:

2.png

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
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

Hello @v-alzhan-msft ,

Thanks for providing an example.
After I have followed the steps you mentioned, I am getting now the right results of the case id but the expression is returning an old comment that was added to the case and not the current when I update the case.

Please have a look at this screenshot:
Old CommentOld CommentCurrent Comment Case updatesCurrent Comment Case updates
In these screenshots above, I have an old comment added about 17 hours ago and a comment that is added today recently at 11:33 AM.
As a flow result instead of it return "Testing FLow" it should return the latest which is "Test at 11:33".
Capture.JPG
So maybe this is because the expression is returning the first comments added? If yes, what should be the expression to get only the latest comment added?

Looking forward to your response.
Thanks.

Hi @Julien2 ,

 

Take a try with expression below:

last(outputs('Compose'))?['description']

 

Best regards,

Alice       

 

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

Hello @v-alzhan-msft ,

Using 'last' in the expression has resolved the issue.
Thank you in advance for your assistance.
Have a nice day!

Hi @v-alzhan-msft ,

I have bad news. It seems that the 'last' expression, didn't solve the issue after I have made many tests.

Please refer to the screenshots:
Capture.JPG
The last expression always showing the same result for "tESTZ" instead of "Last Test", no idea why.
Capture1.JPG
Any idea what should be the expression?

Looking forward to your response.
Thank you!

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (1,559)