Filter Lookups on MSD 365

  • Out of box filter No Code: This just configuration on form.
  • Simple Lookup filter
function AddCustomFilterToLookup(formContext, fieldName, lookuptypes) {

//below fetchxml will be a custom filter to the lookup 
    var fetchxml = "<filter type='and'><condition attribute='ownerid' operator='eq-userid'/></filter>";
    formContext.getControl(fieldName).addCustomFilter(fetchxml, lookuptypes[0]);
  • Regarding Object lookup filter

//here fieldName = "regardingobjectid";
//     lookuptypes = ["contact", "account", "soft_cust_EntityName", "incident"];
//     formContext = executionContext.getFormContext(); 
function RegardingObjectFilter(formContext, fieldName, lookuptypes) {
    var control = formContext.getControl(fieldName);

That’s it for now. Thanks!! 🙂

Open dynamics record in dialog/Modal popup using navigateTo Client API

In 2020 Release Wave 1 Update for Dynamics 365 introduced navigateTo Client API to open main form of dynamics record in dialog instead Xrm.Navigation.openForm. This helps record to open in new window or same window of browser.

Also with the help of Xrm.Navigation.navigateTo, we can open custom HTML too and we can pass some parameters or accept return values in MSD 365 JavaScript too.

Below, we have provided information about how to open the CRM record in dialog. So to open new form for the entity is by below code snippet ..

var parameters = {};
             parameters["soft_para1"] =;
             parameters["soft_para2"] = formKeyString;
             parameters["soft_para3"] = 1;

var pageInput = {
             pageType: "entityrecord",
             entityName: "soft_entityLogicalName",
             data: parameters,
             formId: "71ca9461-3209-4740-bd62-7320af2ae89c"

Xrm.Navigation.navigateTo(pageInput, { target: 2 }).then(
         function success() {
             //do something 
             //do something
         function error() { }

To open existing record use below code snippet

var pageProperty = {
                     pageType: “entityrecord”,
                     entityName: “contact”,
                     formType: 2,
                     entityId: “979dfe31-0686-ea11-a811-000d3a579c9c”//guid of record

var navigationProperty = {
                 target: 2,
                 width: { value: 80, unit: “%” },
                 position: 1
Xrm.Navigation.navigateTo(pageProperty, navigationProperty);

Now, to show some custom html page

var dialogParameters = {
 pageType: "webresource",//required
 webresourceName: "ab_/ModalDialog.html",//Html Webresource that will be shown
 data: data//optional
var navigationOptions = {
 target: 2,//use 1 if you want to open page inline or 2 to open it as dialog
 width: 400,
 height: 300,
 position: 1//1 to locate dialog in center and 2 to locate it on the side
Xrm.Navigation.navigateTo(dialogParameters, navigationOptions).then(
 function (returnValue){
 //you can add handling of resultValue here
 //put your success handler here
 function(e) {
 //put your error handler here

hope it helps.

Another good thing Navigation …..

We can show some HTML page here as well, we can pass parameters and accept some return value too using same above method.


Passing values to HTML page and accepting values in MSD 365 js which are passed from HTML page

function RestrictedCommand() {

    var pageInput = { //pass values to page 

        pageType: "webresource",
        webresourceName: "soft_modelpopup_restrict",
        data: "Incident"


    var navigationOptions = {

        target: 2,
        width: 500, // value specified in pixel
        height: 250, // value specified in pixel
        position: 1


    Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(

        function success(returnValue) { //returnValue will return value from HTML page 

            switch (returnValue.returnValue) {

                case "883990000":                
                    var ResValue = parseInt(returnValue.returnValue);
                    //your logic 

                case "0":

                    //your logic

                case "Cancel":


        function error() {
            // Handle errors


Design your HTML page and pass values like below

    <title>Restriction reason</title>
<body onload="PoppupOnload()">

        p {
            font-family: Calibri;
            font-size: 15px;

        label {
            font-family: Calibri;
            font-size: 15px;

        .select {
            font-family: Calibri;

        .button {
            background-color: #0047b3;
            border: none;
            color: white;
            padding: 12px 29px;
            text-align: center;
            font-family: Calibri;
            text-decoration: none;
            display: inline-block;
            font-size: 15px;
            margin: 4px 2px;
            cursor: pointer;
            float: right;

    <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
        function SubmitClick() {

            var e = document.getElementById("soft_reason");
            var result = e.options[e.selectedIndex].value;

            if (result == "0") {
                openAlert("Please select correct reason or click on 'Cancel' button to cancel the action.");

            } else {
                window.returnValue = result;

        function CancelClick() {
            window.returnValue = "Cancel";

        function PoppupOnload() {
            var queryString =;
            switch (queryString.split("=")[1]) {

                case "Incident":
                    document.getElementById("PersonMessage").style.display = "none";
                case "Contact":
                    document.getElementById("IncidentMessage").style.display = "none";

                default: window.close();


        function openAlert(errormessage) {

            var alertStrings = { confirmButtonLabel: "OK", text: errormessage };

            var alertOptions = { height: 175, width: 350 };

            Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(

                function success(result) {


                function (error) {



    <p id="IncidentMessage">Please note that by restricting the Case record any child records like Goal, Action taken, General Assessment etc. will also be restricted. If you would like to continue then please provide the reason for restriction below:</p>
    <p id="PersonMessage">Please note that by restricting the Person record any open Case record associated to the Person will also be restricted. If you would like to continue then please provide the reason for restriction below:</p>

    <label for="dhhs_restrictionreason">Restriction reason:</label>
    <select class="select" name="dhhs_restrictionreason" id="dhhs_restrictionreason">
        <option value="0">--Select--</option>
        <!--<option value="883990000">Person known to staff</option>-->
        <option value="883990001">Sensitive case</option>
        <option value="883990002">High profile incident</option>
        <option value="883990003">Client request</option>
    <input type="submit" class="button" value="Cancel" onclick="CancelClick()">
    <input type="submit" class="button" value="Restrict" onclick="SubmitClick()">


it will look like this …

Hope it helps

Thanks! (Client API reference) in MSD 365, errorCallback); can be used for CURD operations, also to execute workflow and action. In the above syntax ‘request’ will be a object which can have all information of the operation. The details of the request can be found here in more depth. Here is some details ..

Continue reading “ (Client API reference) in MSD 365”

Activate-Deactivate Plugins/Process with code

while deploying our customisation to target environment many times we need disable/deactivate plugins and or process. Manually, its straight forward but what about when you are working with DevOps or you cannot touch target environment. In such environment, we need to handle it with code. So for that here are the steps …

Continue reading “Activate-Deactivate Plugins/Process with code”

System jobs in Dynamics

For DevOps, we have to handle each and everything from code behind and in automated way. Thus, wrote code to create manage System jobs to delete records every night in Dynamics. Here are the main points from my understanding ..

The BulkDeleteRequest message will create a bulk delete job that will be automatically executed on a specified interval for a specified set of data.  The job will be executed by the CRM Asynchronous service.

Continue reading “System jobs in Dynamics”

Dynamics 365 Portals: Configuration

Why we need portal.. ? in short, we need it for ….

  1. Customer Engagement
  2. Customer Self-Help
  3. Partner Engagement
  4. Employee Engagement
  5. Custom Portal Framework
  6. You can configure multiple portals for same environment too..

Portal Configuration:

  1. Go to MSD’s Admin and click on Dynamics 365 link
Continue reading “Dynamics 365 Portals: Configuration”

Auto-Save Editable sub-grid

If you are working with editable grid, then there is a very common problem user faces that they always forget to save that grid and proceed further with the next business step on MSD 365 form.

The strange part is when the user makes some changes on the grid and saves the data, data won’t be saved but if they click on ‘Save and Close’ data gets saved. But with this user needs to open the same record again to proceed next. Continue reading “Auto-Save Editable sub-grid”

Colourful MSD View

color grid


  1. Create JavaScript library with below function code
  2.  Sample JavaScript Code
    function displayIconTooltip(rowData, userLCID) {
        var str = JSON.parse(rowData);
        var col_data = str.soft_fieldName_Value;
        var imgName = "";
        var tooltip = "{" + col_data + "}";
        switch (col_data) {
            case 1: //Fulfiled 
                imgName = "soft_Green";
                tooltip = "Fulfilled Completetly";
                $('span:contains("Fulfiled")').closest('tr').css('background-color', 'green');
            case 2: //Partial
                imgName = "soft_Yellow";
                tooltip = "Fulfilled Partialy";
                $('span:contains("Partial")').closest('tr').css('background-color', 'yellow');
            case 3: //Unfulfilled
                imgName = "No_colour";
                tooltip = "No fulfilled";
                $('span:contains("Unfulfilled")').closest('tr').css('background-color', 'white');
            case 4: // Cancelled 
                imgName = "soft_Red";
                tooltip = "Fulfilment Deactived/Cancelled";
                $('span:contains("Cancelled")').closest('tr').css('background-color', 'red');
                imgName = " ";
                tooltip = "N/A";
        var resultarray = [imgName, tooltip];
        return resultarray;
  3. then register that JavaScript on the view
  4.  Publish your changes  and hard refresh your browser
  5. … and done !!  🙂

Please note here is this will work only on Read Only View, not on the Editable View.



MSD 365: October ’18 release

Oct 18 Release

The October ’18 wave of business application releases from Microsoft provides you with significant capabilities to transform your business. These new services and capabilities become available starting in October 2018.  Continue reading “MSD 365: October ’18 release”

Creating empty XRM Environment in PowerApps

Good one !!

There was a one of the seminar on the same topic in CRM Saturday-Sydney by Guy Riddle.  It was awesome. As well, I was looking for that process, and this is the one.   Thanks !!

Continue reading “Creating empty XRM Environment in PowerApps”