PowerAutomate Approval entities in CDS

By | July 12, 2020

I was playing with the PowerAutomate approvals tonight, and, since I have not used them at all before, I am wondering if CDS is an “add on” for the approvals or if CDS is a pre-requisite?

See, when looking at the link above, it seems I don’t need CDS to work with the approvals:

image

However, all Approvals-related entities are already available in CDS:

image

It seems there is not a lot of documentation covering approval entities in CDS, but there is this support article which is interesting in a few ways – first of all, it confirms that approvals data is, in fact, stored in CDS. However, it also makes a point that “the schema is complex, not publicly documented and is subject to change”:

https://support.microsoft.com/en-us/help/4559582/guidance-for-custom-solutions-using-approvals-data-stored-in-cds

What I was interested in is: can we use CDS approval entities to create a Flow that will start once there is an approval response and what kind of information can we extract from that response in the Flow?

Turned out we can certainly create such a Flow, and, also, we can extract all the information we need.

Well, this post would not be worth much if it were all straightforward, right?

So, of course, there is a gotcha.

In the CDS environment, you will have Microsoft Flow account:

image

This account, by default, will have only one role:

image

As soon as you create a PowerAutomate Flow that is triggered on create of new Approval Response in CDS, you will suddenly lose the ability to approve all those approval requests. Even when using a full admin account, you will be getting an error:

image

This is a weird error, since there is just no way my account would not have CDS permissions. The error message is way more detailed when trying to approve a request through the web portal:

image

With that ID, I can quickly prove that it’s a permissions error for the “Microsoft Flow” user account:

image

So, in order to make this work, you will first need to create a security role that gives read access to the “Systme Job” entity and assign it to the Microsoft Flow account:

image

Why did I call it “Microsoft Flow Approvals”? Well, it’s “Microsoft Flow” account… You can call it “Power Automate Approvals”, thoughSmile

With that, everything starts working – I can continue approving all those approval requests, and, yet, the Flow I had set up to respond to new approval responses is working, too:

image

This kind of Flow allows for some interesting options. For example:

what if you had multiple approvers for a certain type of approval requests, and what if you wanted to keep sending reminders to only those of the approvers who are not very responsive? It seems PowerAutomate Approvals themselves won’t get you enough flexibility to do that – you will be able to send a reminder, but the best solution I’ve seen so far (unless I misunderstood it), even though it will allow you to send reminders to all approvers in a parallel Flow branch, still won’t be able to differentiate those approvers who actually need to be reminded from those who have already provided their approvals:

https://teylyn.com/2020/01/07/timing-microsoft-powerautomate-approval-reminders/

Once you start working with the CDS entities, each approval response will have its “Owner” set to the approver. So, if there are two required approvers for an approval, you will only need to send a reminder if there is no approval response owned by that approver for the approval request.

PS. Actually, now I’m thinking creating such a reminder might be a good exercise for the upcoming PowerStorm session on July 16: https://www.itaintboring.com/powerstorm/ At least it’s one option among a few I’ve been thinking of so far, though any suggestions you might have are welcome. And don’t forget to register while there are still a few spaces, btwSmile

One thought on “PowerAutomate Approval entities in CDS

  1. Joey

    Great article! I encountered this error and was at a loss on how to correct it. Where do I access the security roles for CDS? I can’t seem to find this area. Thanks, have a blessed day! 🙂

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *