Last updated on 30/08/2023
This blog article will show you how to make a Power Automate Flow that replace the old OOTB (Out Of The Box) workflows and enable you to send portal invitation to contact with power automate flow – even to multiple contacts in one action.
First of all I just want to say that there is nothing wrong with using the OOTB workflows. They work like a charm and get you started, just follow the documentation here: Invite contacts to your portal – Power Apps | Microsoft Docs
This OOTB way will make you FIRST create invitations for each of the contacts you want to invite, and then you can send invitations with the workflow. I figured I could do this smarter using Power Automate Flow and automate the whole process into one action. This blog article will show you how.
Second remark is that you can download the Flow that I built here if you want and save yourself the trouble of making it from scratch if you like. But – you will not learn as much. I do recommend building it yourself.
Make your own Power Automate Flow (“flow” for short)
Create you flow logging in to “flow.microsoft.com” and go to “Create” in the left menu. Choose “Instant cloud flow”
Give your flow a name and choose the “When a record is selected” Common Data Service trigger (soon to be renamed “Dataverse” trigger).
At the trigger level choose “Default” environment and “Contact” table (Entity Name).
Generate the unique Invitation Code
Click “+ New Step” and search for “variable”. Select the “Initialize Variable” action:
Give the variable a name and set it to “string” type. Then click the “value” input field and select the “Expression” tab on the content panel. Type guid() and select “Update”. This expression will generate a GUID and store it as a string value in the variable.
Create the Action URL
The action URL is the URL address that the contact will use to redeem their invitation. It should have this structure: https://[YourPortalAddress]/register?invitation=[InvitationCode]
We use another variable to hold this address, so create another “Initialize variable” step, give it a good name and set it to “string” type. Paste the address to your portal and the rest of the structure, and then click the “Portal Invitation Code” variable from the content panel to add it after the “=”.
This will create a string containing the full URL the user will need to redeem their invitation. Now we need to get this URL to the contact, and we’ll get it done with the “Send Email Notification” action.
Send an email
If you have a user to use for one of the Outlook connections then that is the best option. The Email connector works fine as well.
Make sure to click the “code”-icon to be able to write HTML to format the email. Add information about expire dates and actions to take if expire date is reached. Then make sure the text match your brands tone of voice.
Then we’ll create an invitation related to that contact for the contact to redeem.
Add a step with the “Common Data Services (current environment)” (Soon to be “Dataverse”) connector with the “Create new row” action:
Choose “Invitations” table and select the contacts “Fullname” as name for the new invitation, Set Type to “single” and click “Show advanced options” to see all the columns for this table.
Set “Portal Invitation Code” to the variable we created with the GUID. Then relate “Invite Contact (Contacts)” to the selected contact. At the bottom set “Status Reason” to sent. You can extend this to include a special inviter, set expire date, workflows to trigger and account the contact should be related to on redemption.
At the bottom we terminate the Flow as successful with the “terminate” step.
When you use this flow in production environments please make sure to add some conditional steps along the way to validate your data, i.e. that the contact has email.
Save the flow, make sure it’s activated (turned on) and try it out on a contact with an email you have access to to see that the whole process works.
You can always find the invitations in your Portal Management app and follow up on contacts web roles and external identities.
I guess it’s a good idea to deactivate the legacy workflows, so you don’t end up with duplicate invitation emails.
You find the old workflows by logging into make.powerapps.com, open “Solutions”.
For the old data model (not enhanced) open the solution called
“Dyanmics 365 Portals – Portal Base Workflows” and then open “Processes”.
Open this workflow by selecting the workflow and choosing “Turn off” from the context menu bar.
Make sure to “Publish all Customizations” when you have turned the workflow off.
Customize login, register and redeem pages
Next step is to customize the login, registration and redeem pages. The pages are not available for editing – but I have found a way to get to them – check out this blog post:
Have fun and please comment on this post or reach out to me if you have questions.