When planning for your Power Pages website deployment, one of the first questions that will inevitably be asked is-- Will your end-users be logging into the website and be treated as authenticated users, or will they be accessing anonymously as guests? Power Pages supports both scenarios, and you can even use a combination of the two. If you will be requiring or allowing users to register and login to the website, various external identity providers are available for configuration.
To recap, users of the Power Pages website are contacts in Dataverse, not users on the tenant. If you are having internal tenant users access the website, it is still their Contact record accessing, not their user. Security is therefore configured to the contact-- specifically, these are tied to the contact record's relationship to the other tables. When a user registers for the website--or signs in if they are using Azure AD-- a contact record is created in Dataverse. If the contact record already exists in Dataverse, they can be invited to the website. The contact record will then store the user's identities and web roles.
What if the Contact record already exists in Dataverse? In this scenario, you will need to invite the individual to the portal. You may also want to invite a contact to the portal if you need to turn off open registration so not just anyone can register. This will ensure that only those that have been invited to the website will be able to register.
There is currently a classic workflow included in the Power Pages solutions that will send out an invitation code to invited contacts on demand. However, as this is a classic workflow, to get the email functionality to truly work, you need to first configure Server Side Sync integration with Exchange Online, in addition to manually modifying the workflow itself - which is no longer something that many users routinely do or have the interest in since the shift to Power Automate.
For your reference, information on this workflow is available here, and information on workflows versus Power Automate cloud flows is available here.
How to recreate the Send Invitation workflow in Power Automate
Rather than having this run on demand, I'm going to streamline my process by having the flow pull Contacts to invite on a recurrence, and create send the invitations. Before I build the flow, I need a query to pull my Contacts that I want to invite to my website. I will use FetchXML in the flow to do this.
How to create a FetchXML query
- Open a Model-Driven App, and click the gear icon in the upper right corner of the screen. Select Advanced Settings to get to Classic interface.
- From the classic interface, click the funnel icon in the upper right corner of the screen to open classic Advanced Find.
- In this scenario, I set the table to query to Contacts and the filter criteria to
Username does not contain data - this is because once a Contact has signed in to a Power Pages website, a username is generated. If this value is set to null, it means they do not currently use the website. This is true even when using external authentication, as this column will populate with a GUID.
Email contains data - Users need an email address, or the send email set of this flow will fail.
- Click results to verify that this returns data, then click to Download FetchXML. Ensure the columns with the conditions (Username and Email) are included in the results view. Because I know that I want to use the Contact's First Name in the body of the invitation email, I need to also include First Name as a column.
- Copy to your clipboard.
How to build the cloud flow
Now that that is taken care of, I'm going to create a new Power Automate cloud flow within my solution. I gave the flow a name that clearly indicates what it is doing, and have labeled each step accordingly. My trigger is a recurrence, as I am running this every Sunday night outside of business hours.
Next, I need to run the FetchXML query that I just generated. I choose the action List rows using the Dataverse connector. After choosing the Contacts table, I expand advanced options to paste my FetchXML into. Test the flow to make sure this returns data.
I then initialize a variable to store a returned contact, with type set to Object. Because we are returning a list, we then must input the rest of our actions within Apply to Each.
Within Apply to Each
Use the Dataverse value as the output. Set the variable to the Current item.
 
The next step is to create the Invitation record - use the Dataverse connector. Expand advanced options and in Invite Contact (Contacts), use the dynamic content Odata Id. Populate other fields as needed.
 
Lastly, we can use the Outlook v2 connector to email the invitation code, which will allow us to bypass the need to configure Server Side Sync. For the To field, I specified the Email from the invited Contact using dynamic content. Ensure you are modifying the email body using the HTML mode.
To include a clickable link to redeem the invitation code, use the following syntax in your html link code:
https://[yourportalurlhere]/Account/Login/Register?returnUrl=/profile/&invitationCode=
Replace [yourportalurl] with your portal's URL - in my case, it's https://site-rtrju.powerappsportals.com, so mine looks like:
https://site-rtrju.powerappsportals.com/Account/Login/Register?returnUrl=/profile/&invitationCode=
After the =, without a space include the dynamic content for Invitation Code.
Save and test your flow. Well done!
Resources
 
		
 Like
Like Report
Report
*This post is locked for comments