Tag Archives: powerapps portals

Field level security based on security roles in Entity Form/Web Form based on User Roles in Power Apps/ Dynamics 365 Portal

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

If you are looking for a new feature that has been introduced, unfortunately it’s not. Come one Debajit! Don’t be so disappointing at the start of the  blog!

But truth needs to be told! So what are my other options?

I Was Just Laid Off From, What Are My Options? - H1B Help

Field security profiles are not available in Power Apps Portal. Instead we have Web Page Access Control Rules which will provide access to web page with read/write access. As this can be applied to the entire web page, but in our real-life implementations we need some of the attributes to be read only even for certain users in portals. This can be achieved easily using “user” liquid object.

So let me explain here.

I have contact form where in Revenue field should be editable only by Administrators users for others it should be read-only.

Go to Contact Entity Form and under that Administration tab place the custom code in Custom JavaScript area

$(window).on("load", function() {

{% if user %}

{% for role in user.roles %}

var roleName="{{ role }}";

{% if roleName != "Administrators" %}

$('#cr6b0_revenue').attr("disabled",true);

{% break %}

{% endif %}

{% endfor %}

{% endif %}

});

What I am doing here I run the for loop and if the role name is other than Administrators then Revenue field is read only

As you can see I logged in with Authenticated Users Web role and open my contact form the Revenue field is read only

clip_image002

Before I end, a quick tip here!

Do not take roles collection into a variable and implement the same code. The array of roles will be type casted to string as shown below. It would give undesired results.
var roles = "{{ user.roles }}";

and check your web page source. You will see the roles concatenated as string. And it will no longer be an array you can work with.

clip_image004

Hope this helps!

Debajit Dutta

(Microsoft Business Solutions MVP)

{Preview Feature} Create and Edit themes in PowerApps/ Dynamics 365 portals in few clicks and all using an intuitive UI. Explore the new Simplified themes feature in PowerApps portal studio

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

With every release of PowerApps and PowerApps portals, Microsoft is making the life of customizers easy. And when I saw this feature this was my reaction.

wow |

Very simple yet so beneficial and time saving. Traditionally customers always had a ask to change the theme of portals. What would we do in those scenarios?

We would open the bootstrap.min.css file and theme.css file and change it accordingly.

Advertisements

But what is the problem with that? The problem is if you want to change the OOB theme to say dark yellow, dark or orange theme, we would need to require a lot of changes. Also the fact that we have to do lot of testing on how it looks make it more time consuming.

But now you can do all of this in just one click. As of the time of writing this blog, the feature is in preview. So to access the preview feature, use the URL – https://make.preview.powerapps.com, select your Portal app and then click on edit option to open the portal in Portal editor.

Once you open the portal editor, in the themes option, you now have an option to Enable basic themes.

image

Once you enable basic theme, under Presets section you get some standard popular bootstrap themes. You can just click the theme of you choice and immediately view how your portal looks by browsing the portal.

Advertisements
image

I have selected Red theme here and when I browse the portal i can see the affect immediately.

image

Isn’t it awesome. In-fact so cool. There is so cool

Advertisements
Oh the places you'll go you go clipart - WikiClipArt

Where does portal store the theme information that we just selected? I have put my findings in this blog.

Even if you can create a new theme and change the color combinations as per your contrast and liking (on the right pane of the editor)

image

I loved it and hope you will like it too! For cool stuffs like this, please follow my blog by clicking on the follow button.

Debajit Dutta

Business solutions MVP

{QuickTip} Logout from Dynamics 365 Portals/ PowerApps portals programmatically

Seeing the title of this post, you may be wondering what’s new about this post. After all, you already have a post which shows how to put custom login/ logoff button.

What's New in Xpedition? « Xpedition Enterprise Blog

Well,  there is something new here. And that’s why this blog post.

Advertisements

The requirement this time is to logoff without user intervention. And based on certain business logic. Long story short, the user will perform some operation post which he should be signed out and signed in.

Same concept can be used to automatically sign out a user after few minutes of activity although there are other ways to do the same.

Enough of talking, let’s see the code.

image

Advertisements

var LogOff = new Promise (function(resolve, reject) {
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open("GET", "<a href="https://https://<portalurl>/account/login/logoff", true);

   xmlHttp.onreadystatechange = function () {
       if (this.readyState == 4) {
          if (this.status == 200) {
             resolve("success");
          }
          else {
             reject("failed");
          }
       }
    };

   xmlHttp.send();
});

LogOff.then(function () {
    console.log("LogOff successful.");
});

Advertisements

No matter what authentication you are using, this will work. And the user will be required to sign in again.

Hope this helps!

Debajit Dutta

(Business Solutions MVP)

Base64 encoding and Base64 decode using Liquid in Dynamics 365/ PowerApps portals

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

As I have been working on liquids a lot lately, I am amazed by the simple and yet powerful language which allows me to do so much without drop of a sweat. And then came this requirement.

Advertisements

I have to base64 encode and decode using Liquid. After having explored liquid so much, this was kind of stuff I never tried before in liquid. I thought after all with the kind of operators available in liquid, this would be a cakewalk. There must be a filter out there which allows me to do the same. Did a bit of search and surprisingly found nothing. But I was not ready to give up though.

So I started trying these constructs –

This is my base64 encoded string : {{ “abcde” | base64_encode }}

This is my base64 decoded string: {{ “YWJjZGVk” | base64_decode }}

image

Nothing worked out! I did find some references of bas64_encode and base64_decode filters in some liquid implementations but unfortunately they doesn’t work in portals.

But I have to meet the requirement. What should I do? It’s turn for me now to fall back to the good old JavaScript to do the same.

Advertisements

So I used the javascript btoa function for base64 encoding and atob function for base64 decoding.

Sample code below for reference.

{% assign account = entities.account[‘<accountid>’] %};

<div class="jumbotron" id="div_base64">

<script>

document.write(btoa("{{ account.crb08_encodefield }}")); // crb08_encodedfield is field in account entity

</script>

</div>

Advertisements

Similarly you can use atob function for decoding.

And that is where liquid failed me. Don’t worry liquid, you are still my dear friend.

image

Hope this helps!

For more interesting topics like this, follow my blog using follow button on top left of page. It’s all about Dynamics 365 and Portals.

Debajit Dutta

(Business Solutions MVP)

{Quick Tip} Display knowledge article as attachment in Dynamics 365/ PowerApps portals

For training, consulting and our products, please write to us at – info@xrmforyou.com

I got this query from one of my blog readers and hence thought of sharing it with everyone.

They were trying to display a knowledge article in portals. They were following the Microsoft guidance – “You can author knowledge articles and add them as notes attachments that can be used by users.”

Advertisements

Unfortunately they were not showing up in the portals. This is because to show the knowledge articles as downloadable attachments, you need to add the below site setting.

KnowledgeManagement/DisplayNotes and set the value to true.

Now refresh your portal cache and now knowledge articles are displayed along with their attachments, so portal users can search the attachments.

Advertisements

Hope this helps!

Debajit Dutta

(Business Solutions MVP)

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

Setting value in DateTime field in PowerApps/ Dynamics 365 Portals dynamically using Javascript

You may be wondering why this simple post? After all, setting a date value, what’s in that?

Sometimes the simplest of things takes us by surprise. Below is a screenshot of an entity form with date field.

Advertisements
image

Based on custom business logic on the client side, we have to set the value of the date field (cr6b0_datefield).

If you are thinking just setting the value of the datefield with this line –>  $(“#crb60_datefield”).val(new Date()) will work, it unfortunately won’t.

Advertisements

Below is sample function I have written to set the value of the date field.

function setDateControlFieldValue(fieldname)

{

var d=new Date();

//take the date field

var datefield = $(‘#’+ fieldname);

//take the input control for the date picker

var inputControl = $(‘#’+ fieldname +’_datepicker_description’);

//take the date format

var dateFormat = inputControl.attr(‘data-date-format’);

//set the value to control

datefield.val(moment.utc(d).format(‘YYYY-MM-DDTHH:mm:ss.0000000\\Z’));

//set the value to input control

inputControl.val(moment(d).format(dateFormat));

}

The first thing you should remember is datepicker control in bootstrap uses moment.js to set up the date value. If you just specify the date value, platform won’t detect it.

Let me explain why we need to set value input control description field. If we simply try to set the value of date field the value gets set but the date picker description is not set like

Advertisements

$(“#” +fieldname).val(new Date());

clip_image002

In order to set the description value we need to get hold of that control as well.

clip_image004

Setting the value to input control description will reflect the date in UI.

I have used date only field here, even for DateTime field as well the input control description format would be similar to date field as:

“<field_schemaname>”_datepicker_description

Advertisements

Have you ever thought a functionality as small as this can take you for a ride.

Hope this helps!

Debajit Dutta

(Business Solutions MVP)

For training and consulting, please visit info@xrmforyou.com

Azure storage integration with PowerApps/ Dynamics 365 Portals not working? Receiving “access is denied” message in portal logs. This can be a reason as well. Check this out!

Well, there can be so many reasons why Azure Storage integration with Dynamics 365 Portals/ PowerApps portals is not working. However more often than not, the most common error I see is “access is denied” message in the portal logs.

And you scramble to your portal configurations and verify the connection string to your azure storage account and find everything is alright.

Advertisements

Now what? Well you won’t believe it but in 8-10 cases so far I have seen this issue happening because of minor overlook.

I have read a detailed post on entire configuration here. However for this blog keeping it only to the error.

As per documentation, you should couple of setting record in your portal management app. They are

Advertisements

Setting 1

Name: FileStorage/CloudStorageAccount

Value: The connection string we copied in our earlier step

Setting 2

Name: FileStorage/CloudStorageContainerName

Value: You azure blog storage container name

Advertisements

You may ask what’s big in there? Nothing. But trust me in all those cases of error, administrator have create a site setting instead of a setting record. This is because we are so accustomed creating a site setting that when setting is mentioned, we perceive it as site setting itself. Precisely we need to create a setting record and not site setting record.

image

Trust me if you overlook it first time, it can take hours for you to find and rectify it.

Advertisements

Hope this helps!

Debajit Dutta

(Business solutions MVP)

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

Configure web resource in CDS/ Dynamics 365 form to show documents uploaded in Azure storage in PowerApps/ Dynamics 365 Portals

The is the second blog of this series. If you are on this blog and have missed out on the first one, I request you to go through the previous one to be  fully aware of the context.

https://debajmecrm.com/2020/06/10/want-to-leverage-azure-storage-for-your-documents-in-powerapps-dynamics-365-portals-instead-of-notes-check-this-out/

Advertisements

So now that we have configured the portal and azure storage settings in the previous blog, it’s time to make modification on the Dynamics 365/ CDS side

There is no provision in Dynamics 365 to store documents in CDS/ Dynamics 365. Hence we need to put in the some extra configurations in there.

Open the contact form of you choice that you are going to show in the portal. In there I insert a tab specifically to store the Azure documents and add a webresource – adx_annotations.html in there as show in the below screenshot.

Advertisements
image

Don’t miss out the custom parameter – azureEnabled=true

Now when we open the same record in CDS/ Dynamics 365, the file shows up. Observe the cloud icon in the file which shows that image file is being uploaded in Azure storage.

Advertisements
image

Some very cool features but again not everyone aware of it. Hope this one helps!

Advertisements

Debajit Dutta

(Business solutions MVP)

For training and consulting please reach out to us  at info@xrmforyou.com

Want to leverage Azure storage for your documents in PowerApps/ Dynamics 365 portals instead of Notes? Check this out

Storing documents from portal is fairly important task in all Portal implementations. And Powerapps portals are well equipped to provide you the flexibility to integrate with SharePoint, CDS and now Azure storage accounts as well for your documents. While SharePoint and notes integrations are quite common, integrating with azure storage account requires quite a few steps to accomplish.

In am going to divide this series into couple of blog. In this one, I am going to quickly walkthrough the Azure set-up and portal set-up. In the next blog I am going to walk over the steps needed to be completed in Dynamics 365/ CDS. Read through both the blogs for complete solution. There is a nice document right up there in Microsoft Docs but every now and then while configuring you miss some steps.

Advertisements

I have tried to get it working for myself and then mentioned the steps that I followed.

Step 1 – Set up Azure Blob storage account

You might already have this but for the sake of completion I am going to quickly walkthrough these steps.

We create an Azure blob storage account – “x4ustoragedemo” and inside it a container named  “blobstoragecontainer”.

image

Next under settings, I click on Access Keys and copy one of the access keys connection string. Either Key1 or Key2 is fine

Advertisements
image

Store the connection string we will use it later.

Advertisements

Under settings section, select the CORS option

  • Allowed origins: Specify your CRM domain. For me it is – https://xrm20206.crm.dynamics.com. Make sure you don’t have any trailing slash at the end. It won’t work
  • Allowed verbs: GET, PUT, DELETE, HEAD, POST
  • Allowed headers: Specify the request headers that the origin domain may specify on the CORS request. For example, x-ms-meta-data*, x-ms-meta-target*, or * to allow all.
  • Exposed headers: Specify the response headers that may be sent in the response to the CORS request and exposed by the browser to the request issuer. For example, x-ms-meta-*, or * to allow all.
  • Maximum age (seconds): Specify the maximum amount time that a browser should cache the preflight OPTIONS request. For example, 200.
image

We are done with all the settings from azure storage account perspective.

Step 2 – Configure the portal settings and site settings

Advertisements

Go to your portal management app and create the below settings. Thinking why the word settings is highlighted? Well we are so accustomed to create site settings, that unknowingly you may create a site setting instead of setting and then spend quite a few hours finding out why azure storage integration is not working. So it is Portal Management –> Settings

Setting 1

Name: FileStorage/CloudStorageAccount

Value: The connection string we copied in our earlier step

Setting 2

Name: FileStorage/CloudStorageContainerName

Value: You azure blog storage container name

Our settings are done. Now the below are site settings. Go to Portal Management –> Site Settings

Advertisements

Site Setting 1

Name: WebFiles/CloudStorageAccount

Value: Put the same value specified for FileStorage/CloudStorageAccount

Site Setting 2

Name: WebFiles/StorageLocation

Value: AzureBlobStorage

Site Setting 3

Name: HTTP/Access-Control-Allow-Credentials

Value: true

Site Setting 4

Name: HTTP/Access-Control-Allow-Headers

Value: *

Site Setting 5

Name: HTTP/Access-Control-Allow-Methods

Value: GET, PUT, DELETE, HEAD, POST

Site Setting 6

Name: HTTP/Access-Control-Allow-Origin

Value: <your crm url without any trailing slash>

Site Setting 7

Name: HTTP/Access-Control-Expose-Headers

Value: *

Site Setting 8

Name: HTTP/Access-Control-Max-Age

Value: 300 (it’s value in seconds, you can specify 200/ 100 as well)

Advertisements

Step 3 – Configure portal to enable Azure storage.

You can do this in couple of ways. You can enable Attach files of your entity form with Azure storage enabled or you can configure notes integration with the Azure storage account. I will show you both

To enable attach files feature of the entity, go to your entity form –> additional settings tab

image

You can also configure the Notes form metadata. Go to entity forms –> Entity form metadata. And create a notes form metadata. Your notes for metadata configuration as shown below.

image

To verify whether this configuration is working or not, I just open up a record and upload a file in the note section. As you can see the image file got uploaded.

Advertisements
image

The document is uploaded in Azure storage as well.

image

We are all done from portal side and azure storage side. We will not modify the settings the in CDS/ Dynamics 365 to complete the process. Please follow the next blog for the same.

Advertisements

Hope this helps!

Debajit Dutta

(Business solutions MVP)

For training and consulting please reach out to us  at info@xrmforyou.com

{Preview Feature} Wish you could set up portal authentication with multiple provider through an intuitive UI instead of manually creating site settings. The new simplified authentication preview feature in portals allow you to do just that. Check this out!

I was just going through this Preview feature of PowerApps portals and I could not stop myself from sharing it. If you have ever worked on Powerapps/ Dynamics 365 portals authentication, you know the pain of remembering every site setting and then working out your way to fix them. It’s kind of nightmare to configure all this.

Wished there would have an intuitive UI which would just ask for few information and then would automatically create those site settings in the portal? You wished for it and Microsoft just did that. Though in preview stage but I am quite sure this would make to General availability and even improve from the preview version.

Advertisements

The first thing is how to access the preview feature in the portals. If you go to make.powerapps.com and then navigate to your portal app, you won’t be able to see the preview features. To access the preview features, make sure you browse the URL –  https://make.preview.powerapps.com

I browse the preview URL, select the Portal App, click on the three dots and then click on Settings from the dropdown menu.

image
Advertisements

In the settings, I could see new option called Authentication Settings.

image

Trust me when I clicked on Authentication settings, it was a delight to see the page coming up.

Advertisements
image

As you can see we have all the providers supported by the portals being listed here. Local Sign and Azure active directory is already enabled.

So let’s start exploring. Well there are quite a few features of this new UI and I will be writing multiple blogs over the next few days to go through all of them. Please visit the below links for more.

1. Setting up default Identity provider using Authentication UI.

2. Setting up Google identity identity using Authentication UI.

Advertisements

Hope this helps!

Debajit Dutta

(Business Solutions MVP)

For trainings/ consulting, reach out to info@xrmforyou.com