cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Can Power Automate update a generic (Variable) entity in CDS/Dataflex?

I am writing a flow to generically clean up data (for example, delete any records that have been deactivated for 90 days.)  I have a 'driving table' that I use a 'List records' action on.  Each record in this table has a Fetch XML query defined (copied from advanced find, and placed into the Query String field).  This FetchXML runs just fine inside of the List Records action, and returns the data from the entity specified in the driving table.

 

PAPic1.png

 

In the Apply to each loop, I want to update the (variable) entity, and set the status to 'Inactive'.  (Set Statecode to 1, and Statuscode to 1, e.g.)  (I realize the status codes for inactive can vary; I have another table I reference for each entity that identifies the proper code for that entity.)

 

If I 'hard-code' the Entity in the Update statement, all is well, as I can pass the GUID from the current record I am looping through, and set the status to Inactive.  This is not generic though.  (I would have to write a switch on entity, and craft a different update statement for each.... Not the end of the world, but everything else in this flow IS generic!)

 PAPic2.png

 

What I'd LIKE to do is specify the entity generically.  When I do that (and this makes perfect sense) the system doesn't know what fields to display for the (variable) entity.  I am able to specify the variable entity and the variable GUID for that entity, but I don't know what to put in "Record item" to update the statecode to 1.

image003.png

I looked at the peek code for the 'generic' and 'account' updates, (couldn't paste it in here, got an "invalid HTML" message) and see that, e.g., the non-generic one shows:

 "item/statecode"0,

 "item/statuscode"100000000

 

I tried dozens of different combinations of that, but most don't pass the expression syntax validation.  If it does, and I run the job, it hangs.  The entire Apply for loop this update statement is in is all greyed out.

 

So my asks are:

(a) Is it possible to supply a variable entity to the CDS update record action?

(b) If so, could you please provide the syntax for the "Record Item" that will set the (variable) entities statecode to 1?

 

Many Thanks in advance!

Dave

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @DavidMLCarr1 ,

 

The Record Item should be defined in JSON format as follows.

 

{
"name": "Test Name",
"statecode":1
}

 

 

Snipaste_2020-12-04_09-56-02.png 

Snipaste_2020-12-04_09-57-43.png

Hope this helps.

Sik

View solution in original post

2 REPLIES 2
Community Support
Community Support

Hi @DavidMLCarr1 ,

 

The Record Item should be defined in JSON format as follows.

 

{
"name": "Test Name",
"statecode":1
}

 

 

Snipaste_2020-12-04_09-56-02.png 

Snipaste_2020-12-04_09-57-43.png

Hope this helps.

Sik

View solution in original post

Sik!

 

Fan-freaking-tastic!  Works perfectly. I'm one step away from making this update generic, and functional.

 

If you like my Visionary Rules Power App, https://appsource.microsoft.com/en-us/product/dynamics-365/visionary-software.13646115-0934-4695-976...

I'll cut you a heckuva deal!

 

Thanks so much, and have a great weekend!

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (73,159)