Category Archives: Dynamics365 Portals

Assign default web role when a user sign in Dynamics 365 Portals/ PowerApps portals

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

PowerApps portal – A simple yet powerful customer facing portal with so many inbuilt features. And these feature list are quite extensive. So it is really difficult to actually grasp all these features while working for a project. But at the same time, if you are not aware of these features then a requirement which could have been implemented so easily, you actually take a much more complex route to meet it.

And here was one of this requirement. The requirement is whenever a user sign in the portal, the user be assigned a default Web role. And when I see how it was implemented, I could find in many cases it is being done with Plugins or workflows.

Well trust me! There is much more easier way than you can imagine. And that is the concept of “Authenticated Users Role” in Web role. If you open up a Web Role, you will see this option as highlighted in the screenshot below

image

For example – In the above screenshot, I have set this option value to Yes for this Web role. So now what happens? Because I have set this to Yes, any user once they sign in will have this role automatically assigned to them. Because the option – Authenticated Users Role is set to Yes, there is no need to even explicitly assign this role to the portal contact. It automatically becomes the default role for all users who have signed in the portal.

Detailed explanation of this feature is provided here. Easy wasn’t it?

Hope this helps!

Debajit Dutta

(Business Solutions MVP)

Authenticated Users Role and Anonymous Users role option in a Web Role in Dynamics 365 Portals/ PowerApps Portals. All you need to know about it

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

If you have worked on PowerApps portal project, you are probably aware of Web Roles. Web Roles are security roles in PowerApps portals through which you can control the access of a portal user. And whenever you try to create a Web Role, you come across the options highlighted.

image

And trust me, even among consultants experienced portals, the concept related to these options are not clear. And every training I conduct on Portals, questions on these topics are granted.

So let’s start with the first concept– Authenticated Users Role

Let me explain in very clear terms. For a Web Role, if you set Authenticated Users Role as Yes, an user when logged in to the portal will automatically have the role. In other words when a web role has the Authenticated Users Role set to Yes, any logged in user in the portal will have that role even though the Web Role is not explicitly assigned to the portal user.

Let’s see an example here

Below is an example of a Portal contact with Web Role explicitly assigned to the contact

image

I have couple of Web Roles in my environment both of which have the option – Authenticated Users Role set to Yes

image

So let’s see how it works out. To really test this, I have modified the Home Web Template to print the user roles.

<ul>

{% if user %}

{% for role in user.roles %}

<li>{{ role }}</li>

{% endfor %}

{% endif %}

</ul>

Save your changes. And then refresh your portal cache. Let’s observe when the portal contact now login to the portal.

image

Certainly not the prettiest way to test this. But certainly proves the concept.

Isn’t it great! So you have a requirement to assign a Web Role when a user sign in to the portal, all you need is to set the Authenticated Users Role set to Yes.

So let’s start with the second concept– Anonymous Users Role

Now that we understand the concept of Authenticated Users role, it’s pretty easy to understand this option. If you set a Web role with Anonymous Users Role set to Yes, anyone browsing the portal anonymously will have that Web role automatically assigned to them.

You should be extremely careful while creating a Web Role with Anonymous Users Role set to Yes. Just make sure that the web role should not have any permission which give the anonymous user access to unwanted records.

Hope this helps!

Debajit Dutta

(Business Solutions MVP)

Custom button to save a record and stay on the same step without moving to the next or previous step inside a Webform step in PowerApps portals/ Dynamics 365 Portals? Check this out!

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Few months back I posted an article on how you can develop a custom button for Save as draft functionality on an Entity form in PowerApps portals. On that post I have received multiple queries on how we can do the same inside a webform. It’s quite easy and my blog is dedicated to that.

But before I go ahead and write how I can do the same in WebForms, let’s see under what circumstances you would need that solution.

Inside a WebForm in Dynamics 365 Portals or PowerApps portals, we always have the following behavior.

The first step in the WebForm has the “Next” button. Obviously you can rename the Next button, but the behavior is always when you click that button it goes to the next step.

image

In all intermediate steps, you have the next and previous button

image

In the final step, you have the Submit button.

image

Now the issue here is whatever button you click, you are either taken to the next step or previous step. There is no button which when clicked will save the record but will not redirect you to the next page kind of “Save” button which just save the record and does not navigate.

Now that we understand the requirement, the next step is to implement the same.

The first thing is to insert the “Save” button. And let’s say we will always put it after the first button.

So to make the code generic, we write the following code.

$(window).on("load", function () {
    $fb = $("div.actions input[type='button']:first");
    $("<input type='button' id='btnSave' name='btnSave' value='Save' class='submit-btn btn btn-primary form-action-container-left' />")
       .insertAfter($fb);   $("#btnSave").bind("click", function () {

       // if you want you can perform some custom logic before you call save.
       WebForm_DoPostBackWithOptions
          (new WebForm_PostBackOptions(undefined, '', true, '', '', false, true));
    });
});

If you observe the code carefully, we are taking the first button from the action buttons and inserting our custom save button right after that. Also the trick is to call the WebForm_PostBackOptions with the name of the previous button.

And then finally use the code in the Custom javascript section of each webform step.

image

And now once you refresh the portal cache and browse the webform, you can see the Save button.

image

And now let’s see all this in action. Just observe the below video where I click on Next and it saves the record but does not move to the next step. Kind of stuff we expected right?

Hope this helps!

Debajit Dutta

(Microsoft MVP)

Query Entity Permissions for a portal user using Liquid in PowerApps portals/ Dynamics 365 Portals

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Entity permissions are a great way to control record access in your Dynamics 365 Portals. You can have fine grained control at individual record level. But ever wondered if you can determine the portal user privileges on a particular record that the portal user is viewing? Cometh the hour, cometh the champion, our very own liquid in Dynamics 365 Portals.

Using liquid you can determine the permission a portal user is having on a record they are viewing. Let’s see how we can accomplish the same.

For this demo, I have created a sample Web Template. Before I go ahead and show you the template code, below are the configurations that I made.

1. Created a portal user

2. Assigned a web role to the portal user

3. Provided Entity permission to the web role for contact entity. Screenshot below. Please note I haven’t provided “Append To” permission.

image

Below is the code for my web template

As you can see, the entity liquid tag has permissions object. And the permissions object have properties like can_create, can_read etc. to check for user privileges on the record.

When I run the page for a specific contact, below is output.

image

As you can see “Can Append To” is false because I haven’t provided append to permissions in the Entity permission.

Hope this helps!

Debajit Dutta

(Microsoft MVP)

Understanding “Restrict Read” Web Page Access control rule in Dynamics 365 Portals/ PowerApps portals

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Restrict Read” – A privilege which is perhaps most misunderstood. And every session I go when I start explaining the concept of Restrict Read, participants are like – Come on! This is not what Restrict read means.

What is ARFID? - Columbus Park

To give a quick background we have Web Page Access Control rules and under Web Page access control rules we have Grant Access and Restrict Read. The problem arises with Restrict read.

So let’s create a restrict rule for one of our webpages. The web page name is “Restricted Page”.

image

Now what happens? The moment I created this Restrict Rule, the Restricted Page along with all the web files under this page (defined by scope), are restricted for all  users in all web roles. In other words, the moment you create a restrict rule for a page, the page is blocked from all portal users. And then you have to assign webroles explicitly to this rule to enable this page only for users in the specific role.

So I go ahead and assign “Employee Web Role” to this rule.

image

The moment I do this, all users in Employee Web Role shall be able to see the Restricted page. So the gist is –

“When you create a restrict rule for a page, the page is blocked for all. And then you have to assign webroles to this rule to explicitly make this page available to users in that webrole.”

Hope things are clearer if ever you had a doubt about Restrict read.

Hope this helps!

Debajit Dutta

(Microsoft MVP)

{Solved} Web Page cannot be set to self–Error while browsing PowerApps/ Dynamics 365 Portals

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Recently we had an issue with one of our Customer portals. Everything was working fine in DEV and UAT environments. However after portal deployment in production environment, customers reported they are unable to browse the portal. Whenever they are trying to access the portal, they are getting generic portal error which displays a error code and asks to contact system administrator.

For a quick resolution, we disabled custom errors in the portal. Then when we tried to browse the portal we got the error – “Web Page cannot be set to self”.

I was kind of taken aback because I have never received this error before.

WHAT JUST HAPPENED! - Lolcats - lol | cat memes | funny cats ...

Regathering myself, I just realized then when the portal is launched, it’s the home page of the portal which is displayed. So there must be an issue with the home page.

And then I went ahead and opened the home page of the portal. And I could see as below

image

Not sure how this happened and investigation going on. But my I guess it happened during portal migration. Nonetheless, I removed the parent page, cleared portal cache and then browsed the portal.

And now to our delight, our beloved portal is back.

Hope this helps!

Debajit Dutta

(Microsoft MVP)

Where does Dynamics 365 Portals/ PowerApps portals store theme information when you change portal theme using PowerApps portal editor?

For training and consulting, write to us at info@xrmforyou.com

Recently I published a blog on the new preview feature for PowerApps portals where it allows you to change the portal theme from PowerApps portal editor. Check this here.

While I received quite a few queries on the same, one of the interesting questions I got is – “Where does Portals store the current theme that is selected? Can I change it without PowerApps portal editor?”

That left me puzzled a bit. Honestly I never thought on those lines.

question mark.jpg

Initially my hunch was Portals must be storing this internally. But somehow I kept the belief that like many other settings, this must also be a site setting which is maintained by the portal.

And finally it was there! The site setting name is “ThemeFeature”

image

To test it, I went ahead and changed the portal theme using PowerApps portal editor, the record is updated with the new “selectedThemeId”.

To me not a very useful information honestly but certainly better to know than not knowing it.

Hope this one helps!

Debajit Dutta

(Microsoft MVP)

What is Developer extensions tab in WebFormSteps in Dynamics 365/ PowerApps portals? Is there any significance to it?

For training and consulting, write to us at info@xrmforyou.com

Recently I have been conducting a lot of training on PowerApps Portals. And every time when I start teaching WebForms, I get this question – What is the significance of Developer extensions in WebForm step.

If you are not able to relate, this is what I am talking about.

image

And trust me, this is the question I get in almost every training. And if you are not sure of what is that doing there on the form, you would likely to search a lunch break and expect participants to forget it. . What more worrisome, the documentation is not there even in the Microsoft Docs.

GIVE ME A BREAK! ~ Writers Guild Chuka University

Well if you are on this blog, then no more need to take a break. Developer extension tab is an old functionality from Legacy ADX studio portals. And the documentation is still in ADX community docs right here. What you could have done their previously is define a name for the event that could later be used in asp.net code for the webform to programmatically act on the events. Wit h PowerApps portals no longer supporting asp.net code changes the feature has been deprecated.

I am not sure why it is still there on the WebForm step form. But I believe it is a legacy carry over and would be removed at some later point of time.

Hope this helps!

Debajit Dutta

(Microsoft MVP)

Convert byte array to base64 string using Liquid in Dynamics 365/ PowerApps portals

For training and consulting, write to us at info@xrmforyou.com

Liquid and PowerApps portals. I think a match made in heavens. And what can I say about Liquid, a simple yet so powerful template editing language.

And while I was singing praises for Liquid, a colleague came up to me and told that liquid does not have the capability to handle byte arrays and convert them into base64 string.

I was like – Come on! Liquid is powerful.

Quick Reference] Liquid Template - Reference Manual for Dynamics ...

So I decide to have a look into it. Before we go ahead and try for a solution let’s understand when you require to handle byte arrays in dynamics 365 portals. There can be so many scenarios but if you look into specifics when you try to query entityimage in portals you get the result as byte array. The problem is you cannot directly handle byte arrays in liquid directly. But in fact you can do it with a little trick.

What you need to do is to convert your byte content to delimited string. And like other languages, you can do this in Liquid as well.

var stringByteContent = “{{ <your byte array> | join: ‘,’ }}”;

What exactly happens when you do this? You actually convert your individual. So basically your byte array will be represented like this.

image

Okay what’s next, it’s still isn’t base64 string.

Well, the next few steps we will use the everlasting JavaScript which have withstood the test of time. Below is the function which will do the final honours.

function binaryToBase64(content) {

   if (!content) return null;

   var uarr = new Uint8Array(content.split(',').map(function (x) { return parseInt(x); }));

   return btoa(String.fromCharCode.apply(null, uarr));

}

Hope this helps!

Debajit Dutta

(Microsoft MVP)