ENGINEERED CODE BLOG

Dynamics 365 Portal: Customizing Portal User Registration Process – Part 3

In my third post in this series on creating a custom registration form for a Dynamics 365 Portal implementation, I discuss the behind the scenes processing required to get the registered user a contact record with login credentials.

In my third post in this series on creating a custom registration form for a Dynamics 365 Portal implementation, I discuss the behind the scenes processing required to get the registered user a contact record with login credentials.

In my previous post I created a custom entity called Portal User Registration, along with a Dynamics 365 Portal Entity Form that allows users to submit their registration. Once they fill out that form, a record is created in Dynamics 365 – however that form does not ask for any authentication credentials, and it creates a custom entity, while we all know that users require a Contact record in order to be able to login to a Portal. We’ll solve both of these using a combination of the out-of-the-box Invitation Code Model and workflows.

Leveraging the Invitation Code Model

The invitation code model is used to allow existing contact records to be associated with Dynamics 365 Portal login credentials. The process is essentially the same, regardless of if you’re using local authentication or an external identity provider like Azure AD B2C. It works like this:

  1. A long, random, unique set of characters (called the Invitation Code) is generated and associated with the Contact record.
  2. The email address associated with the contact is sent a message with a link to the Portal that includes the unique invitation code.
  3. The link takes the user to a page when they can either create a new local authentication username and password, or choose any of the configured external identity providers.
  4. After “logging in”, the login credentials are joined to the contact associated with the invitation code.

Invitation Codes are often used for new Portal implementations that already have a large number of existing contacts in Dynamics 365. It allows you to invite your existing contacts to the system, as opposed to them having to register, which will lead to duplicate contacts. However, there is no reason we can’t use this model for new registration as well!

The Workflow To Tie Everything Together

We’re going to create a workflow that fires on the create of our custom Portal User Registration entity, and performs the following tasks:

  1. Create a Contact record based on the submitted details.
  2. Create an Invitation record, ensuring that:
    • Type = Single
    • Invite Contact = contact created in previous step
  3. Use the out-of-the-box Send Invitation workflow to send the user the invitation email.

As a bonus, I’ve added one extra feature, and that is to take into account the Type the user selected when they submitted the form. If they selected Gold my workflow will use the Portals:Assign Web Role Custom Workflow Activity to assign the Gold Web Role I created. This is a simple example, but there are a lot of things you can do in these workflows if your registrations process is complex.

The completed workflow looks like:

When using the Invitation Code model, you’ll need to customize Send Invitation workflow to ensure that the email is coming from an appropriate user (so that the email will actually go out), that the messaging updated, and that the URL is updated to point to your Portal.

What About Microsoft Flow?

Could you use Microsoft Flow instead of the traditional workflows? Probably. However, we’re using some of the out-of-the-box invitation code workflows, which could probably be rewritten in Microsoft Flow, but for the purpose of this series, we have not.

The End-to-end Process

Now that we’ve got our workflow setup, a user can register on our Portal using the custom registration form. Once they submit, they will receive an email inviting them to our Portal. After clicking on the link, the user will be presented will the opportunity to configure their authentication using any of the enabled options. After that, the user will be logged in and successfully joined up with the contact containing the information supplied in the initial form submission.

In the next/final post, I’ll touch on some items that can be adjusted to improve the user experience.

Dynamics 365 Portal: Customizing Portal User Registration Process – Part 2

In my second post in this series on creating a custom registration form for a Dynamics 365 Portal implementation, I discuss the custom entity and tying it to an Entity Form (or even a Web Form!).

In my second post in this series on creating a custom registration form for a Dynamics 365 Portal implementation, I discuss the custom entity and tying it to an Entity Form (or even a Web Form!).

The Custom Portal User Registration Entity

The first step is to create a custom entity you can use to capture the fields you require. In my trivial example, I’m looking to capture the user’s first and last name, along with an email address plus the type of account that they want to sign up for (either Gold, Silver or Bronze). As mentioned previously those fields (except for email address) don’t appear on the out-of-the-box registration form, and there is no simple way to add them.

So, I’ve created a custom entity called Portal User Registration with those fields, like so:

What About Just Using Contact Instead of a Custom Entity?

You might be thinking to yourself, couldn’t I just create a form that allowed the user to directly create a contact, rather than creating this new entity type? Yes, you definitely could, and I don’t think that that is a bad idea. However, there are a couple reasons I like the custom entity:

  1. There may be fields you need to capture on the registration form but aren’t necessarily fields on the contact record. For example, your registration form may have account name, account address, etc. You can include all of these fields on your registration entity, and then use workflows (or Microsoft Flow) to create the proper entities.
  2. You may have fields that you need as part of the registration, but aren’t needed after that. In my trivial example, the type of account could be considered one of those fields. As you’ll see, I use that field to determine if the user gets an additional web role, however it’s not something I need to store on the contact record. Typically contact records are complicated enough – they don’t need extra fields unless they are necessary.
  3. This approach allows you to perform business logic on the record before creating a contact, perhaps business logic that may determine the user shouldn’t get an account. If this information is stored in a separate entity, you don’t have to worry about your Contacts table getting polluted with records that never turned into real Portal users.
  4. You’ll always have a history of what the user filled out when they first registered. Unlike the contact record, which can most likely change over time, the registration record is a snapshot of what they originally submitted.

Again, all that being said, I don’t think using Contact instead of a custom entity is necessarily a bad approach.

Creating the Entity Form

Next, we’ll create a simple Entity Form that allows for the insert of our custom entity. It really doesn’t get much simpler that this:

Make sure the Mode is Insert, and that Enable Entity Permissions is unchecked, as we want anonymous users to be able to create these records.

Finally, we’ll add the Entity Form to a Web Page – in my case I called it User Registration, and we’ll get the following:

With that in place, user can submit a registration via our Portal with our own custom fields.

What about a Web Form?

Perhaps your registration form is complicated – so complicated that it should be multiple steps. Does this technique work with a Web Form instead of an Entity Form? Definitely!

If you use a Web Form, you’ll have to modify when the workflow that we’ll setup in the next post triggers, as you won’t be able to trigger on the create of the record. However, other than that, everything else should be very similar.

I definitely recommend using a custom entity in this case (as opposed to using the Contact entity), as you are likely to get abandoned records from people who don’t complete the entire form, and you don’t want those in your Contact table.

In my next post, I’ll cover the behind the scenes processing that needs to happen to create the contact, and to allow the user to associate their contact with login credentials.

Dynamics 365 Portal: Customizing Portal User Registration Process

While the Dynamics 365 Portal product offers flexibility in many areas, unfortunately the user registration process is not one of them. If you’re looking to add some fields to the form the user fills out when registering for your Portal, you’ll quickly find there is no simple way to do that. In this series, I’ll provide a different approach that might suit your needs if a custom user registration experience is required for your implementation.

Continue reading “Dynamics 365 Portal: Customizing Portal User Registration Process”

Contact

Engineered Code is a web application development firm and Microsoft Partner specializing in web portals backed by Dynamics 365. Led by a professional engineer, our team of technology experts are based in Regina, Saskatchewan, Canada.