Working with Dynamics 365 and Power Platform design and development? Then keep reading. In this blog post I will show you the power of Dynamics 365, Power Apps portal and Power Automate together and I will also demonstrate the low code solution for complex integrations by using Power Automate.
The process starts by the external users that are not Dynamics 365 users. The users click on a link that they get through emails or events. Power Apps portal checks the user’s security number and gets the address and other relevant information from Dun&Bradstreet (Bisnode) by invoking Power Automate through web forms. If the users pass the validations and the information entered in the web forms are correct, then the users will be added as project members in Dynamics 365 CRM. The link that the users receive is shortened by Bitly through Power Automate connector.
Customer Request:
Tools, apps and programming languages used to fulfill the customer requirements:
I started the process in Dynamics 365, below the list of new components that I created in different systems.
Original link is a text field that will hold record of the unique link in Dynamics 365 case (incident) entity. The link holds the GUID for the case entity and it is used by Power Apps portal to find the case in Dynamics 365.
Shortened link is also a text field in the case entity, which will hold the link created in Bitly, and the Power Apps external users will get this link via events or emails. When the users click on this link it will go to the original link. Note: when we say users, we mean Power Apps external users.
ActivateOrDeactivate field, this is a two optionset field in the case entity that is used to activate and deactivate the original link in Power Apps portal. A Power Automate is triggered once this field is updated in the case entity.
To integrate the Power Apps portal with Dynamics 365, I created a new entity (Link Entity), which holds some important information such as the information gathered from Power Apps portal during the registration process before submitting to Dynamics 365 and information about the case linked to the information gathered during the process.
The custom link entity holds some important fields: Case incident Id (GUID), Case original link, Does not exists in Dun&Bradstreet, Protected Identity, Dun&Bradstreet errors, Security Number, Inactivate the link, Plus many other fields to gather the personal information for the registration process such address, names, phones, email etc.
A new button (Create access link) on the main Case form. The button was created by Ribbon Workbench. Once clicked a new record is created in the new custom link entity. The code behind the button is based on TypeScript, which we are using in this project, but JavaScript can also be used.
A new main form for Power Apps portal web form with tabs was created in Dynamics 365. The tabs are used as web form steps in Power Apps portal.
A Power Automate will trigger when the field ActivateOrDeactivate in the case entity is updated. If the value is true, the field “Inactivate the link” in the link entity is set to true. If the value is false, then “Inactivate the link” is set to false. On the Power Apps portal web form, we check this field value and if it’s true we will proceed with the registration, but if not, we will tell the external user that the link is inactive.
A Power Automate triggers directly from the advanced form, also called web form “Form Options” in the JavaScript/jQuery section. We need to invoke the flow directly to get the details from Dun&Bradstreet to the web form in real time. The flow is triggered when a HTTP request is received.
In make.powerapps.com, I created a new flow with the trigger “When a HTTP request is received”. The input for the flow had three fields and I used the Json below in “Use Sample payload to generate schema” to generate the input as objects.
{
”securityNumber”: ”value”,
”linkEntityId”: ”value”,
”caseOriginalLink”: ”value”
}
”value”, this is to indicate to the payload generator that it is a string json element. You can use which value you want here. For example, ”test” will also be considered as a string. You can also use an empty string like this, ”securityNumber”: ””, it will also work.
As explained above, the Power Automate will have 3 inputs in this case.
The code to invoke the Power Automate has been written in web form “Form Options” for the step used in that regard. Note: the code starts with “$(document).ready(function(){“ because it is written in jQuery.
$(document).ready(function(){
/*
Here you can have your code and call other functions.
In this case we are getting values for securityNumber, linkEntityId and doing other stuff and after that we call the function callFlow to trigger the Power Automate in Power Platform.
callFlow(securityNumber, LinkEntityId, caseOriginalLink);
Note: We had three inputs for the flow, so we are sending the values for the three inputs in Power Automate.
*/
});
How to call the flow from web form “Form Option” with jQuery directly, see below:
function callFlow(securityNumber, linkEntityId) {
var caseOriginalLink = We are getting the case original link
//We are creating a json string here, which will be the input for the Power Automate flow.
Var httpTriggerUrl = your HTTP Post URL from the Power Automate
var objDun&BradstreetSearch = {};
objDun&BradstreetSearch.securityNumber = securityNumber;
objDun&BradstreetSearch.linkEntityId = linkEntityId;
objDun&BradstreetSearch.caseOriginalLink = caseOriginalLink;
var stringJSON = JSON.stringify(objDun&BradstreetSearch);
$.ajax({
url: httpTriggerUrl,
contentType: ”application/json; charset=utf-8”,
type: ”POST”,
async: false,
dataType: ’json’,
contentType:”application/json; charset=utf-8”,
data: stringJSON
})
.done (function(data, textStatus, jqXHR) {
// Do your Done stuff here
})
.fail (function(jqXHR, textStatus, errorThrown) {
// Do your fail stuff here
})
.always (function(jqXHROrData, textStatus, jqXHROrErrorThrown) {
// Do your always stuff here
});
};
In our case, the most important task is to invoke the Power Automate with the inputs in real time and in the Power Automate steps to update the custom Link entity with real data from Dun&Bradstreet. After that we need to show the result for the user in the web form step in real time. The time was an important factor, the user should not wait for more than a few seconds. The Power Automate will need to search for the user’s security number in Dun&Bradstreet through the HTTP request in Power Automate and based on the response from Dun&Bradstreet update the link entity.
To fulfill the requirements, I created three pages, a list and two web forms (advanced form).
A landing page:
When Power Apps external users click on the link that they get through emails or events, it will open this page in the Power Apps portal. This is the same link that is saved in the case entity field “Original link”. The landing page can be opened either by the “Original link” or the “Shortened link” (Bitly link). The landing page is using a web form (advanced form). This web form is validating the field “Inactivate the link” on the link entity. If the value is true, which means it is active, it goes to the next web form to follow the registration steps, but if it is false, it will go to a page saying that the link is not available anymore and that they can contact us. The validation is done through “Form Options” on the web form step on the ”Link control webform” web form.
A list:
A new list shows all the active links in the Link entity. The landing page opens the record based on the field name in the custom link entity. The field name holds the same value as the link (Original link) from the case entity. When opening a record in the list, it will open the web form “”Link control webform”. This web form is used to control if the link is active or inactive. As I also mentioned before, each link has a unique GUID for the case that is used to find the case in Dynamics for the updates through the web form steps.
Two web forms:
When the Power Apps portal external users open the link, they have received, it will first go through the web form ”Link control webform” which is linked to the list in Power Apps portal. As mentioned under the list section above, it will validate the link and if active it will go to the next web form, ”Registration of interest webform”. This web form has many steps, and it uses Form Options sections for each step to do validations and invoke Power Automate processes as mentioned above.