Tag Archives: powerapps

Designing Business process flows for your canvas apps

I had this requirement lately and the first time I heard this I thought, is this even possible? But then I never doubt about the every increasing capability of canvas apps. So decided to do a search.

And guess what! Found this wonderful documentation here with a complete solution.

Advertisements

https://powerapps.microsoft.com/en-us/blog/using-business-process-flows-in-a-canvas-app/

I am simply falling in love with PowerApps documentation which is so much focused on implementation and solutions rather than just theory.

Towards the end of the solution, you will find a link to download the powerapps solution sample. Link – https://github.com/microsoft/powerapps-tools/blob/master/Apps/BusinessProcessFlow/BPF_Solution_1_0_0_11.zip

Advertisements

One point to note here – The BPF Component shown in the blog is not an OOB control available but in fact it is a generic control custom built for designing a BPF. So if you are searching a control with that name in your powerapps component list, you may not get it.

Hope this small tip helps!

Debajit Dutta

Business solutions MVP

{Solved} Typing in character t automatically inserting current datetime in datepicker controls on WebForms in Dynamics 365/ PowerApps Portals

Well, this one is indeed weird when I first time saw it. So basically we set up custom datetime format in portals to dd-MMM-yyyy.

If you are unware of custom datetime format in portals, you can follow this blog here.

Advertisements

All set and done, I launch a webform and the first step of the webform is the account details page. I have field “New Date Field” on the form. Remember the format of datetime in portal is dd-MMM-yyyy.

In line with the format, I try to key in the date – 12-Oct-2020. And observe the behavior.

As you can see from the above experience, the moment in keyed in “t”, it printed the new date. Trust me this is one of the hardest bugs to catch and if I would not have faced this one, I could never know about it.

What is our way out here? Well, I am a developer by heart and whenever something like this comes up, I try to dig in to the root cause of it.

Advertisements

The first thing I wanted to check if there is any keydown handlers attached when I press the key ‘t’. To find that, I tried the below code

image

Here “cr6d3_newdatefield” is my date field logical name in CRM. So you can see there is a keydown event handler and using the developer tools I went inside that function

As you can see from the below screenshot, there is a function attached on keydown of character ‘t’ which sets the value to current datetime.

image

Awesome isn’t it, to find these little little things. So exploration is done. Now what is the next step? How to make it work.

Well the easiest option I found was to remove the keydown event altogether.

$(“#<yourdatefield>_datepicker_description”).data(“events”)[“keydown”][0].handler = null;

Well, not the most elegant but certainly it works.

Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/2019/02/28/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)



Show success and error symbol for each field on-change of field value in Dynamics 365/ PowerApps portals.

Recently I got a requirement where every time an user keys in a wrong email address, the user should get a error notification icon on the control and if the user key in the correct email address, the user should get a success notification on the control.

Very common requirement I shall say but again this is something which does not happen OOB. So let’s see how can we accomplish this.

Advertisements

For this demo I am using an Entity form for contact entity and we shall be playing with the email address of the contact.

In the Custom Javascript section of the Entity Form under “Additional Settings” tab, I write the below code.

// JavaScript source code

$(window).on(“load”, function () {

$e = $(“#emailaddress1”);

$e.addClass(“form-control”);

 

// add the has-feedback class. Without this it won’t work.

$e.closest(“div”).addClass(“has-feedback”);

// show the tick symbol.Hidden to start with.

$e.closest(“div”).append(“<span id=’emailaddress1-success-icon’ class=’glyphicon glyphicon-ok form-control-feedback’ style=’color:green;display:none’></span>”);

// remove symbol. Hidden to start with.

$e.closest(“div”).append(“<span id=’emailaddress1-error-icon’ class=’glyphicon glyphicon-remove form-control-feedback’ style=’color:red;display:none’></span>”);

$e.bind(“change”, emailAddressChanged);

});

function emailAddressChanged() {

var pattern = /^(([^<>()\[\]\\.,;:\s@”]+(\.[^<>()\[\]\\.,;:\s@”]+)*)|(“.+”))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

var inputValue = $(“#emailaddress1”).val();

$(“#emailaddress1-success-icon”).hide();

$(“#emailaddress1-error-icon”).hide();

debugger;

if ($.trim(inputValue) !== ”) {

var isInvalid = !pattern.test(inputValue);

if (isInvalid) {

$(“#emailaddress1-success-icon”).hide();

$(“#emailaddress1-error-icon”).show();

}

else {

$(“#emailaddress1-success-icon”).show();

$(“#emailaddress1-error-icon”).hide();

}

}

}

The important stuffs I have put a comment above those lines and highlighted in yellow. As you can see, I have just played around with some bootstrap elements. I save the entity form changes and I clear the portal cache.

On the contact create form below is my experience.

Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/2019/02/28/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

{Quick Tip} Redirect to edit form post creating a record in PowerApps/ dynamics 365 portals

This one is a small tip for anyone who are trying to build up their portal application and did not have much exposure to portals yet. And this is one of the most common requirement that I face in almost every portal implementation.

So you have your insert form and then when the portal user creates a record, the user should keep be on the same record in edit mode.

Actually this is quite easy but if you new to the portals it can be bit of struggle for you.

Advertisements

So here goes the configurations.

Open up the entity form for Insert and navigate to the On Success Settings tab. Make sure in the Redirect section you choose the Edit Web Page that you have configured for the record. And make sure you have the properties –

  • Append Record ID to Query String – Set this as checked
  • Record ID Query String Parameter Name – id

The last step is quite important. This is the step you will miss if you are new to portals.

Advertisements

Screenshot below for reference.

image

Refresh your portal cache. Now when you create an entity record and save the record, the edit page will load allowing you to edit the same record.

Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/2019/02/28/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Have you understood the significance of Xrm.Utility.invokeProcessAction() API in Dynamics 365? And no it’s not to execute a Global action. It has much more to it than you can imagine! Check this out!

Xrm.Utility.invokeProcessAction – A function introduced in Dynamics API for quite sometime. And frankly with the magnitude of actions being used in each project, this should have been the most widely used function by now. But unfortunately this is hardly used and the reason for that being it’s purpose is not being understood.

We may have never thought that with Xrm.WebApi.execute being already there, what is the need for a separate API to call the action? And also why it is called invokeProcessAction  and not just invokeAction? If you have just noticed what I have higlighted, may be by now you have already started guessing. And that’s why the old advice of reading in between the lines just works out everywhere and even in a function name.

Advertisements

So let’s get serious. I have gone through multiple articles on this topic and all these articles always show how to execute a global function using this API. Surprisingly there is no article which shows how to call a bound (entity) action. Microsoft documentation on this topic doesn’t help either. And if you are curios enough and tried to execute a bound action using this method, you must have received the error – “Action not supported”.

So if the capability is just limited to execute global action why a separate API. After all Xrm.WebApi.execute just works fine. As we go through the process of unravelling this method, things will become more clear.

I have created a bound action with Account entity. Below is the screenshot of the action and it has few input arguments. Also it creates a task and associates it with an account. Pretty simple right?

image

I write code to execute this action on an account entity form. And we get the below error – “The action is not supported.” This made us to believe that bound actions are not supported. Let’s burst that myth first, bound action is supported but we are not using it the correct way.

image

I then  put a lot of thought on it’s naming. Why it is called invokeProcessAction? If process something to do with it. So the next step is I went ahead and created a business process flow for the account so that any new account I create have an associated business process flow to it.

Advertisements

Now I run the same code. Error again right? But watch, the error just changed. Now it says “UciError”. Some progress right. At least we now know that bound actions are supported. Things are getting interesting here. Tighten your belt.

image

Now the next stuff I do is I check the option – “As a Business process flow Action Step” in the Action.

image

And once I do that, I add the action as Action step in the business process flow for the Account entity which I created in the earlier step. And then I update the process.

Advertisements
image

And now I run the same code on account record. And I can’t believe my eyes here. It’s in-fact hit the success callback.

image

And the action executed and created a task

image

What’s the change? The only change is the now the account record is having a business process flow with the action as an Action Step. And now I guess you started to understand what it is called invokeProcessAction.

Advertisements

So finally a breakthrough!

But wait the joyride is still not over. Let’s explore it a bit more.

Now that we understand it’s related to Business Process flows, can we execute this action from anywhere? All this time I was executing the code from entity forms. But let’s try this time to execute from a webresource.

image

Error again! So can’t it work outside an entity form. Hell yeah! it can work.

All you need to do is pass the Business Process flow id as one of the parameters. Check for the parameter “BusinessProcessFlowId” in the action call.

image

Now the question comes, how did it work on the entity form without this parameter? The reason is when we executed the code from the entity form, the business process flow was present and the context could retrieve the business process flow id of the record on the form. Now that we are executing it outside the context of form, we need to pass it explicitly.

Advertisements

Finally to end off, a question may come to your mind. Can I fire it for specific instance of Business Process Flow? Affirmative – you can. All you need to do is pass the BusinessProcessFlowInstanceId.

And below is the code to do the same.

image

Trust me, it was kind of a discovery I relished and thoroughly enjoyed writing. And I don’t want my readers to miss it too!

Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/2019/02/28/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Xrm.Utility.getResourceString in Dynamics 365. Which scenario it works and where it doesn’t? And what are the workarounds?

RESX web resources have been introduced for quite sometime but unfortunately even when I see project implementations today, I see constants file being used instead of Resource files. What more, you can even show specific values based on logged in user language. This blog post is not about how you can create a resource file and stuffs but more importantly using the Xrm.Utility.getResourceString method of WebApi both on your entity forms as well as webresources.

Advertisements

For the sake of completeness of this blog, let’s first create a resource file. Open any xml editor of your choice and let’s use the following resource content.

<root>
    <data name=”key1″>
       <value>Value 1</value>
    </data>
    <data name=”key2″>
       <value>Value 2</value>
    </data>
</root>

Let’s save the file with .resx extension.

Now let’s go ahead and create a webresource with the following content.

Webresource name – new_/strings/test.1033.resx

Type – Resource File (resx)

Observe the webresource name. I have included English language code (1033) in the file name.

Advertisements

Now let’s focus on the Xrm.Utility.getResourceString method.

1. Get Resource value on Entity Form

The first thing we will do is to use this method to get the resource value in entity form. For that we create a simple javascript webresource and add the resource file in the dependency list.

image

While this step is not mandatory, it is advised to do so. Adding the resource file in the dependency list will make sure you don’t get any reference errors while accessing resource file.

Now when you try to access the resource value based on the key, the appropriate value is received depending on the user’s language.

image

As you can see from the above screenshot, check for how I have used the resource file name. If the user language is English, it shall search for the file  ending with extension .1033.resx. If not matching file is found, it shall default to the generic file. That’s why it is always suggested to create generic resource file without any language code being mentioned in the file as fallback.

Advertisements

2. Get Resource Value on HTML webresource embedded in Entity Form

Now the next step is to access Resource file from HTML webresource embedded in entity form. It’s quite easy. Include ClientGlobalcontext.js.aspx with appropriate path in the HTML file and then use the resource file in dependency area of HTML web resource.

And the same code above shall work.

3. Get Resource Value on HTML webresource in separate window

Now let’s say you want to open a webresource in a separate window using Xrm.Navigation.openForm. And you follow the same steps as mentioned earlier. However this time, you will get an error while trying to access Xrm.Utility.getResourceString. Fortunately I came across Andew’s blog which helped me to resolve the issue. You can follow it here.

Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/2019/02/28/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Planning to show a custom multi-select lookup. Use the Xrm.Utility.lookupObjects to show a multi-select lookup control in Dynamics 365

Recently in my project I had the requirement to show up a multiselect lookup for selecting records across multiple custom entities. The customer have created a PCF control where they have designed to show the selected records spanning entities. But the issue was to show a lookup control to allow the user to select multiple records spanning entities.

Thankfully there is a method now to do exactly the same using Client API.

Advertisements

The below code shows how to show up a multiselect lookup control from account and contact entity. However you can do the same for all custom entities.

var lookupOptions = {};
lookupOptions.allowMultiSelect = true;
lookupOptions.defaultEntityType = “account”;
lookupOptions.entityTypes = [“account”, “contact”];

Xrm.Utility.lookupObjects(lookupOptions).
    then(function (s) {
       if (s !== null && s.length > 0) {
          for (var x = 0; x < s.length; x++) {
             // get the type, name and id.
             var type = s[x].entityType;
             var name = s[x].name;
             var id = s[x].id;
          }
       }
    }, function (e) {
       console.log(e.error.message);
    }
    );

Below is how it looks.

image
Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/2019/02/28/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

This entry was posted in Dynamics 365, Microsoft CRM, Microsoft Dynamics CRM and tagged Dynamics 365, powerapps, relationship behavior, rollup, rollup view on May 23, 2020.

WebForm sessions in PowerApps/ Dynamics 365 portals-All you need to know

Webforms are wonderful things in PowerApps portals. It allows you to design wizard control providing user with multiple steps to complete an operation.

And one of the wonderful things with WebForms in PowerApps portals is to maintain sessions. Say a Webform have three steps – Step 1, Step 2 and Step 3.

Say a portal user named Joe starts a webform and fills in till step 2 and then leaves the portal. When Joe again login to the portal and start web form, he will start from Step 2 instead from beginning, basically from where he left off. That’s an awesome feature.

Now the first question – Does webform always maintain session? The answer is No. It depends on the setting of the WebForm.

Advertisements

There is a field on the webform – “Start New Session on Load”. If you set this to Yes, it won’t save user’s session. If set to No, then the user’s session shall be saved.

image

Now the next question – Where are session information saved? How does Portal load session information specific to user?

Well, it’s pretty simple. On the WebForm record, there is “Sessions” tab. As you can see from the below screenshot, we can see the session saved for my login.

Advertisements
image

It’s no brainer that Portal loads session information from this record. Before we close this blog, let’s see what’s there on the session record.

image

As you can from the above screenshot, the portal user information and the entire step journey is stored in this record. And guess what, the step the user was last in, is stored in the Step History field. Below is the step history for one my sessions in json viewer.

image

As I highlighted, the IsActive: true is the step the user was last in and hence when the same portal user browse the webform, the active step shall be loaded.

And for some reason if a portal user request to start afresh a webform session, all you need to do is identify the session record for the portal user and he/ she shall start afresh.

Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/2019/02/28/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)