How to open a modal popup in Dynamics 365

In one of my previous post, I explained how to use navigateTo() function to navigate to entity view. But with this function, we can do lot more like navigate to dashboards and open modal popups (html web resources) which is most awaiting feature since long back. So, finally we can open a html web resource from a ribbon button click with OOB functions.

Please follow this link to know how to use this.

Thanks Gopinath for sharing this.

How to refresh or navigate to Entity View

In some scenarios we all have to refresh or navigate to specific entity view after a particular action performed. We can use a method called navigateTo() for this requirement. This method is available under new Namespace Navigate.

Syntax:

Xrm.Navigation.navigateTo({ pageType, entityName, viewId, viewType }).then(successFunction, errorFunction);

  1. pageType: Specify “entitylist”.
  2. entityName: Provide the logical name of the entity.
  3. viewId (Optional): Provide the Guid of the view to load. If you don’t provide it, it will navigate to the default view of an entity.
  4. viewType (Optional): Provide the Type of the view to load. For ex: “savedquery” or “userquery”. It is required only if you want to navigate to a specific view.

Example:

  • Without View Id:

Xrm.Navigation.navigateTo({ pageType: “entitylist”, entityName: “account” }).then(
function (result) {
//Success code
},
function (error) {
//Error code
}
);

  • With View Id:

Xrm.Navigation.navigateTo({ pageType: “entitylist”, entityName: “account”, viewId: “4ec687fd-9858-4e8c-b267-63add9769d77”, viewType: “savedquery” }).then(
function (result) {
//Success code
},
function (error) {
//Error code
}
);

Note: At the moment, this method is supported only on the Unified Interface

Hope it is helpful…..

Call Microsoft Flow from Custom Ribbon Button

In one of my previous blog I mentioned how to use on demand flow within MS CRM. But we have some limitations with that approach

  1. we can’t apply Enable rules on the Flow button as it is OOB context menu which generates dynamically based on the number of flows.
  2. we can’t restrict a call to Flow to check the conditions whether Flow needs to run or not, I mean we can’t apply our conditions before a request goes to Flow.

the solution for the above problems is to call the Flow from custom ribbon button. To call a Flow from ribbon button, we have to create a flow on “HTTP Request” trigger. In my example I am creating a contact with First Name and Last Name fields and passing the parameters from ribbon button (as of now I am passing some constant values from my javascript). Here is the step by step process to do this

Step 1: Create a Flow with HTTP Request with proper “Request Body JSON schema” (use sample payload option to generate the schema)

Step 2: Add “Create a new record (Dynamics)” action to create a new Contact in CRM.

Step 3: Add a Response action at the end to send the response back to CRM and Save the Flow .

Step 4: Once your flow is created you will see the URL in the “HTTP Request” trigger. Use “HTTP POST URL” to trigger the Flow from ribbon button action (javascript).

Step 5: Create a ribbon button in CRM and call the below function from the ribbon button.

with this approach you can add all your validations in the java script and call the Flow once the conditions met, this way we can reduce lot of unnecessary calls to Flow. We can pass whole record context to Flow if needed. Hope it is interesting 🙂

Date filters do not work for SQL Server in PowerApps

Today I faced an issue to get the records in PowerApps from SQL database by applying date filters (From and To Dates). I spent so much time to retrieve the records by using the below command “ClearCollect(FilteredWorkReports,Filter(‘[SQL_Table_Name]’, ReportDate >= FromDate.SelectedDate && ReportDate <= ToDate.SelectedDate))“, but I didn’t get the expected result. The reason is simple “Direct date filters do not work for SQL Server” based on this link from MS. So, the solution for this issue is to create a calculated column for the date column in SQL table with Integer datatype. The formula for this calculated column is “YEAR([your_date_field]) * 10000 + MONTH([ your_date_field ]) * 100 + DAY([ your_date_field ])“. The data in your table will look like below with new field

CustomerReportDateReportDateAsInt
Cust 12019-05-0120190501
Cust 22018-11-0820181108
Cust 32015-12-1520151215
Cust 42018-06-0720180607

Finally, I applied the date filter with new column like below which is working like a charm 🙂 “ClearCollect(FilteredWorkReports,Filter(‘[SQL_Table_Name]’,ReportDateAsInt >= Value(Text(FromDate.SelectedDate,”[$-en-US]yyyymmdd”)) && ReportDateAsInt <= Value(Text(ToDate.SelectedDate,”[$-en-US]yyyymmdd”))))“.

I hope it helps…..

MS Flow is an alternative for Dialog

We all know that dialogs should be replaced with either BPF or Canvas App as dialogs were deprecated in Dynamics 365 CE, but what if we want a simple dialog which will accept some custom parameters and use those values to process the business logic? The best alternative for this scenario is MS Flows. We can create a Flow and call explicitly from “Flow” button on the CRM record. For this, we need to create a Flow with the trigger “Common Data Service –> When the record is selected”. Take an example to convert a lead to opportunity based on some parameters. The below is the Flow that I developed.

After the Flow creation, you can see this Flow from the Lead entity records like below.

The Flow will open the dialog like below with set of questions that we defined above once you click on “Qualify Lead” button.

Click on “Run Flow” button to execute the Flow

Your flow executed successfully and created an opportunity record.

With this, we can create simple dialogs very easily with out any extra efforts. Hope this will be useful for other developers.

How to find parent record with at least one child record or with no child records from Advanced Find

Now it is very easy to get the parent records with at least one child record or with no child records from Advance Find like below

Before this feature got introduced, it was not possible to query the records from Advanced Find, you have to download the fetchxml and modify the filter type to “outer” and create a view or report with the modified fetchxml.

Hope it makes easier everyone’s life……