Tag Archives: Dynamics 365

Enter an amount between $0.00 and $XXXX. Error for custom currency field in Dynamics 365 V9.x on-premise

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

Now this was strange. It was kind of embarrassing as well in front of the customer. So my customer had quite a number of currency fields on a custom entity form. Some were calculated and some were for entry by the user. Also the currency they created was a custom currency.

Whenever they were entering a value in those currency fields, they were getting the below error.

image

It was kind of strange since this is something I never faced. To be honest this was a project on Dynamics 365 on-premise after quite sometime and my initial hunch was this is an on-premise issue. So I replicated the whole step in a Vanilla online environment but it is working fine there. Then I checked if the currency base fields were setting correctly or not. Cross checked in advanced find and everything was fine.

Searched the heck out of Google but not to find any luck.

And finally as last measure I went ahead and dragged and dropped the Currency Lookup (transactioncurrencyid) field on the form.

Once I did that and published the form, much to my relief, everything was working fine.

image

Hope this helps!

Debajit Dutta

(Microsoft MVP)

Scope of getSharedVariable and setSharedVariable functions in Dynamics 365 Client API

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

These functions have been introduced way back in 2011 but till date I believe this is one of the least used features of Dynamics 365 Client API’s. And partly because of the fact their limited scope when it comes to sharing variables.

I wonder many may have tried it but had to move over to other methods because these methods didn’t meet their needs.

Nonetheless I get this question every time I do a technical training on Dynamics 365 – What are these API’s used for. So I decided to dedicate a blog for this. So let’s start with the Microsoft definition of setSharedVariable function to understand the scope.

Requirements Scope Statements — Business Analyst Learnings

“Sets the value of a variable to be used by a handler after the current handler completes.”

The first impression you get from this definition is – if you have multiple handlers for the onload event of a form and if I set a variable using setSharedVariable method, the other handlers for the same event shall get the value using getSharedVariable function.

function pageLoad(e) {
    console.log("Inside Page Load.");
    e.setSharedVariable("key1", "From pageLoad function.");
    console.log(e.getSharedVariable("key1"));
}

function f1(e) {
    console.log(e.getSharedVariable("key1"));
    e.setSharedVariable("key1", "From f1 function.");
}

function f2(e) {
    console.log(e.getSharedVariable("key1"));
}

So let’s look at the code above. We have three methods – pageLoad, f1 & f2. All these three functions I have registered on the onload event in order. So basically these are three handlers for the same onload event.

image

And then I set a variable using setSharedVariable function.

Now as you can see, I am trying to get the same value in functions f1 & f2.

Let’s see what’s the output.

image

As you can see, the shared variable is available inside the method pageLoad. However it is not available for functions f1 & f2.

So it’s kind of heartbreaking right! So where it is useful and what is the scope of the variable using setSharedvariable function.

I change my pageLoad function to below. As you can see, I am calling an async function to get the record details of an account. By the time, the account details are retrieved, the function have exited. However on-success of retrieve method I am trying to access the value back.

function pageLoad(e) {
    console.log("Inside Page Load.");
    e.setSharedVariable("key1", "From pageLoad function.");

   Xrm.WebApi.retrieveRecord("account", "a8a19cdd-88df-e311-b8e5-6c3be5a8b200", "?$select=name,revenue").then(
       function success(result) {
          console.log("Retrieved values: Name: " + result.name + ", Revenue: " + result.revenue);
          console.log("Printing Shared variable: ", e.getSharedVariable("key1"));

       },
       function (error) {
          console.log(error.message);
          // handle error conditions
       }
    );

}

And here is the output in the console. As you can see, I am still able to access this variable.

image

So if you have some async/ callback functions, these methods will work good for you. However if you trying to persist values across lifetime of the form or even pass data to multiple handlers of the same event, this does not work.

That limits the scope to a great extent. And now I guess you understand why it is used pretty less.

Hope this helps!

Debajit Dutta

(Microsoft MVP)

Configuring Mobile Offline profiles in Dynamics 365 for Offline Sync on mobile devices

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

Trust me we all know about the offline feature of Dynamics 365 Mobile App. And if you ask even experienced Dynamics consultants on how to enable an entity for offline, the answer you get is you need to open the entity customizations and enable the below options.

image

In organization data download filter, you can define the filter criteria for data sync in mobile offline. So for the below filter, only accounts which are active and created in last 20 days shall be downloaded and available for mobile offline.

image

Till this point, almost everyone is aware. What is missed out is the Mobile Offline Profiles. Surprisingly it’s so much less discussed that many are not aware of it. But the fact remains that you need to create mobile offline profiles for users to configure filters that determine how much of an entity’s data (and related entities’ data) will be available to the user while offline.

So let’s see, how you can accomplish the same.

Go to Advanced Settings –> Mobile Offline

image

You may already find some profiles there but let’s start with a simple profile.

I enter a name for the profile – “Sample Offline Profile” and save the record. Here I will only show for account record. However you should do the following steps for all the entities which you want to enable for mobile offline sync.

Click on plus icon in “Mobile Offline Profile Item Details” to create a new Mobile Offline Profile item.

image

Observe I am using “All Records” as option here for data which will be downloaded. However one very important point here – The actual data available for mobile offline sync shall be the intersection of the filters specified in Offline Profile + Filter in organization data filter. If you remember the screenshot above, we have specified the filter there as active accounts created in last 2o days. Hence that shall be respected.

image

You have other options like “Other data filter” and “Custom data filter” using which you can specify custom filter rules.

I save the record. Now the “Mobile Item Profile Offline Association Details” grid becomes activated. In this grid, you can define the related data for account which can be enabled for mobile offline. For example, you want to download the active contact records for each account, we can define that using the below configuration.

image

You can create additional filters on the related records as well.

So we are all set for Account Entity here.

Now the final step is to assign users to this Offline profile. You can add users using the Users grid on the right.

The user “Chandana” is added to the profile. Please note that a user can be added to only one mobile offline profile.

image

And before I end, you remember the Organization data filters that you configured using the entity customization screen. Well, the same is present on the “Mobile Offline Profile Item” record for Account Entity that we just configured.

You can manage the same from here as well. Please note that to remove an entity from Mobile offline capabilities, you need to remove them from Mobile Offline filters where it is being referred.

image

Hope this helps!

Debajit Dutta

(Microsoft MVP)

{Quick Tip} – Wanted to know whether your client code is running on-premise or online in Dynamics 365? Use the isOnPremises() method in Global context

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

Recently I faced this scenario where I needed to determine based on whether I am on-premise or online, I needed to write my logic accordingly. We have our popular Sharepoint Utility which is used by a lot of customers and we had to perform special operations depending on whether it is installed on-line or on-premise.

Xrm.Utility.getGlobalContext() gets the global context and has method to know whether your model driven app is hosted on-premise or online.

Advertisements

To get the value first the get the global context

var globalContext=Xrm.Utility.getGlobalContext();

var isOnPremises = globalContext.isOnPremises();

Simple yet effective built-in method available in global context.

Advertisements

Hope it helps!

Debajit Dutta

(Business Solutions MVP)

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

“This attachment can not be opened on your device”–error while trying to open a file using Xrm.Navigation.openFile

This is an error I was facing while trying to download file using Xrm.Navigation.openFile. I was trying on unified interface on web browser. Tried on all browsers and I was getting this error.

Advertisements

Below is my code which I was trying.

var file = {
    fileContent: “YWJjZA==”, //Contents of the file.
    fileName: “test.txt”, //Name of the file.
    mimeType: “text/plain” //MIME type of the file.
};

Xrm.Navigation.openFile(file, 2).then(
    function (s) {
       console.log(“File downloaded successfully.”);
    }, function (e) {
       console.log(e.message);
    });

And I was getting this error – “This attachment cannot be opened on your device”.

Advertisements

And then I went back to Microsoft Docs – Read carefully and came across this.

image

openFileOptions is an object. Where we need to specify openMode.

So all I did was to create openFileOptions object and set the value of openMode property.

var openFileOptions = {openMode: 2};

var file = {
    fileContent: “YWJjZA==”, //Contents of the file.
    fileName: “test.txt”, //Name of the file.
    mimeType: “text/plain” //MIME type of the file.
};

Xrm.Navigation.openFile(file, openFileOptions).then(
    function (s) {
       console.log(“File downloaded successfully.”);
    }, function (e) {
       console.log(e.message);
    });

And voila! It worked. Small trick did it.

Advertisements

Hope this helps!

Debajit Dutta

(Business solutions MVP)

For training and consulting, please write 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

Sales Team Member App in Dynamics 365

In my training sessions I have this question frequently popping up – “What is the Sales team member APP in my APP List”.

Precisely when you open up your Dynamics 365 apps section, you can see new Apps – Sales Team Member. And this one is already in general availability since April 2020.

Advertisements
image

So what is this special APP? Well there is nothing special about this APP. Team Member license is quite restrictive and there is quite a bit of restriction on access of entities when a user is having Team member license. In Microsoft’s own words – “The Sales Team Member app module enables those use cases and provides guidance and clarity on the use rights.”

Since Team members license was being used for lot of Sales Users, this APP was release to clear the air of confusion about what a user with Team member license rights can access and what they can’t.

Advertisements

Hope this helps!

Debajit Dutta

(Business Solutions MVP)

Multiple image data types with option to edit/ annotate the image in Dynamics 365/ CDS/ Model driven apps. New preview feature in Release wave 1 – 2020

With the latest preview release in Model driven apps, you are now able to create multiple fields of image data types. And guess what, you can even annotate your images. You have the option to crop your image, highlight, rotate your image as well. So let’s get started.

Before you go ahead and get started, few things you must remember.

  • The feature is supported only on UCI and not on classic web forms. With the classic web forms being removed in few months from now, it’s quite obvious.
  • This is a preview feature and like all preview features, it’s not meant to be used in your production environment.

For demo, I have created a custom entity called – “Product Entity”.

Advertisements

I have created three fields of Image data type. You can even mark any of them as the primary image.

  • Product View 1
  • Product View 2
  • Product View 3
image

And I placed them on the form. The image controls only get enabled once the record is saved. The below screenshot shows how it looks in create mode.

Advertisements
image

Once the record is saved, you can now upload images in the respective fields.

image
Advertisements

Wonderful, isn’t it? Well it’s not over.

Now let’s upload an image. As you can see from the below screenshot, I have few options like annotating, crop, rotate etc.

image

Multiple image data types was awaited a long time and I hope we shall see it soon in the general availability release.

Before I sign off, when I tried to upload a file more than 5 MB, i received an error. Seems like it’s a bug. This feature can work with up to 16 MB file in model driven apps.

Hope this info helps!

Debajit Dutta

(Business solutions MVP)