Skip to main content

Part 4 Automatic CE User creation, removing/assigning Dynamics License Process from Power Virtual Agent embedded in PowerApps Portal using Power Automate and Microsoft Graph API


# Part 4 – PowerApps Portals Customizations for applying/removing the license of a CE Resource

-        In Part 1, we learned how to set up Azure to use Power Automate with Microsoft Graph API for adding/removing licensing
-        In Part 2, I discussed the customizations that I did in Dynamics CRM and  
-        In Part 3, we learned how to automate a process of creating Work Order from a request is done by a Portal Bot Customer (a simple contact in CRM) from Power Virtual Agent embedded in Custom Portal and notification sent to the Primary contact of the Service Account of the WO created.
Continuing the process, we will now demonstrate the work that will be done by the Primary Contact of Service Account. I will be referring the Primary Contact here as the Resource Master and they will have access to Partner Portal.
Resource Master logs in Portal after receiving email from the Power Virtual Agent in Part 3 look for the resources as per the screenshot below:
EntityList Screenshot


The above screenshot is a simple entity list created with the view of Active Partner Contacts OOB with a filtered attribute using Company Name i.e. Primary Account.
Resource Master can search for a resource based on Current Status of On-boarding and Category as mentioned in Part 2
Let’s say Resource Master have a resource (a contact in CRM) with a category of Electrical and, Resource Master would like to enable it as a bookable resource in Field Service and assign Field Service/CE license. For our demo, we will be using CE license. Assuming, Resource Master have previously added a resource (Contact in CE), we call it as Electrical Resource with a proper verified email address. Assuming all necessary skills or characteristics have been associated to the contact already. I am not going in details for all of these setups, and will basically show how to add a CE Contact as a User in CRM using PowerAutomate and Microsoft Graph API
As per the screenshot below, I have filtered my resources with Category= Electrical. I have two options either to use Onboard9 Example9 for WO created in Part 3 or create a new resource.


We will go with creating a new resource, as per the screenshot below:

The Contact in CRM is created as:

The Email received by the user as:


The user created in Azure AD is and added to group created in Part 1




User is associated to the contact and licenses are added.


 
The above items are achieved with the following PowerAutomate
Complete Flow Explain




Get AD User


Add User to Group



Create AD User


The process of authentication is the same as shown in “Get AD User”


Remove User from Group


The process for authentication is the same as shown in “Get AD User”


User in CRM



Bookable Resource created in CRM



Bookable Resource created in CRM using PowerAutomate


Invitation Received by the CRM Contact/Bookable Resource






Note: I mistakenly used Redirect Url as the Portal Url, which may work in a situation where you don't want Field Service users to get into CRM but instead see a thank you custom page and begin the field job.




Add Security Role to the User

Two ways of doing it:
1.      Add Security role to the User during the time of licensing using PowerAutomate, as shown below

2.      Create a team in CRM of type AAD Security Group and specify the AD Group ID form Azure. Once the User logs into CRM it will automatically assign the Security Role associated to this team to the User. Screenshot of Teams created in CE is shown below







Electrical Resource now appears in the Schedule board as well

Let's book this resource now









Let's see if Resource Master, tries to set Affirm Resource to Not Allowed, then what happens from the portal.





I have used simple JQuery and Liquid Code to stop the Off-boarding resource if there is any Open WO associated with it.




Let's Complete WO in CRM now,


Now the Contact can be Off-boarded.

Let's set Affirm Resource to Not Allowed now, this will trigger the flow to remove User from Azure AD Group and thus revoke the licensing and will deactivate the bookable resource. in CRM.


Comments

Popular posts from this blog

Select Multiple Records from Entity List

Select Multiple Records from Entity List and Perform CRUD on records or related records Here I am going to demonstrate the process that can be used to select multiple records in an entity list to perform CRUD on records or related records. In this, we have one entity list which displays all the courses that are open for enrolment. CRM Contacts can log in to the portal and enrol for the desired coursed. The entity list is rendered on the portals as follows: The submit button is custom submit button which is designed to call Web API in order to perform the CRUD operation. Checkbox against each entity list item is designed using JQuery Registration Status is the Response from Web API Open means that the Registration is Currently Open for the logged-in portal contact to enrol and they can select multiple checkboxes and then click on Submit button to create their registration, In this, I am going to select : 1.  Diploma in Web Development 2.Bachelor of Applied Inf

Editable Entity List or Editable Subgrid PowerApps Portals

Editable Grid PowerApps Portal In this blog, I am going to explain how we can use PowerAutomate and old school JQuery on PowerApps portal to convert Entity List into editable entity list or subgrid. I am only using the string attributes of the Lead entity for Quick Update in this blog. The benefit of making entity list editable with this approach is that we do not loose the OOTB functionality of Search, Sorting, Grid Configuration to enable edit/view-details/delete and Filtering. How I manipulate the data attributes in entity list using JQuery is shown in the below screenshot The screenshot below shows how the code manipulates the entity list html elements using the above code. The PowerAutomate for updating the data in CRM. A success message is displayed on the portal to let user know that the update has been accomplished and the record is Updated in CRM The value retrieval on Click of custom Quick Update bu

PowerApps Portal Generic Error Feedback from Portal User

As we all know that whenever there is a server error on the PowerApps Portals we only see a generic error message. Which looks like There is a method of logging errors from the portal using Azure blob Storage, but this is something that I won’t be discussing today. I will be going ahead and asking for more information for the error on the portal from the Portal User actually experiencing it. Let’s see how we can achieve this thing. We can create Portal Generic Error in Content snippet to add custom text or information for the error message, but it is hard to get entity forms added using Content Snippet or any other HTML to be created using any bootstrap or custom css on this page. The only CSS that you get on this page is from the index page which highlights the h1 tag with bold and red color and everything that you add goes into the div with class dialog. I have made use of JavaScript to change HTML content and have added an entity form asking Portal User to submi