Colourful MSD View

color grid

Explanation:

  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');
                break;
            case 2: //Partial
                imgName = "soft_Yellow";
                tooltip = "Fulfilled Partialy";
                $('span:contains("Partial")').closest('tr').css('background-color', 'yellow');
                break;
            case 3: //Unfulfilled
                imgName = "No_colour";
                tooltip = "No fulfilled";
                $('span:contains("Unfulfilled")').closest('tr').css('background-color', 'white');
                break;
            case 4: // Cancelled 
                imgName = "soft_Red";
                tooltip = "Fulfilment Deactived/Cancelled";
                $('span:contains("Cancelled")').closest('tr').css('background-color', 'red');
                break;
    
            default:
                imgName = " ";
                tooltip = "N/A";
                break;
    
        }
        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.

Thanks!

 

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”

Field Service: Demo data import issues

demo data

There are so many questions and problems faced by field service developers while Demo data import for field Service. So thought of let’s make write on common issues for demo data import for field service, which I faced during my demo data import.

You can download demo data from here to import into your field service environment. Microsoft already provided a detailed document on how to import demo data to Field Service. you can find that in downloaded files.  But still, while importing this demo data I faced below issues.. Continue reading “Field Service: Demo data import issues”

Field Service: Sample data installation

field service

While studying Field Service, Field Service installation is not enough,  we need to install sample data or seed data in the environment, so we will get clear idea of how its looks like and we can play with that sample data just like real one.

As well, it can be used for demo purpose.

So here are the steps to install sample data for Field Service… Continue reading “Field Service: Sample data installation”

Open create ‘Form’ from sub-grid directly by avoiding associated records between entities

In MSD 365, when we add sub-grid on form by creating relation between two entities, it will gives Create (+) button and associate view button. When we click on Create (+) button, dynamics shows already created associations between these two entities, ref below screen shots…

Association

Some time we don’t require this associated records and always want to create new record by avoiding all those clicks. We can achieve it by making relation mandetory, just as shown in below image.

make it relation required

…and you are done, now go back to the subgrid and click on the ‘Create’ (+) button, it will launch new create window and won’t ask to select existing association.

Thanks.

Editable Grid: Make it read only

new things

We have a out the box option to make editable grid read only on the from it self but its applicable only for the views not for the sub-grids. Thus, with small JavaScript we can make it read only based on our business requirements. Here is the sample code for it

function setFieldsDisabled(context) {

    context.getFormContext().getData().getEntity().attributes.forEach(function (attr) {

        attr.controls.forEach(function (c) {

            if (c.getName("name") == "soft_ownercopy") {
                c.setDisabled(false);
            }
            else {
                c.setDisabled(true);
            }

        })

    });
    
}
 

Call it on where you want to…

js call

Thanks!!

Get data from selected rows of Sub-Grid

Here is the sample code to get desired data ( sample shows about GUIDS) from selected rows from the editable grid.

function GetSelecctedGuidsFromGrid() {

//Get an array of entity references for all selected rows in the subgrid
    var selectedEntityReferences = [];
    var sGuids = "";
 //get selected rows from grid    
var sRows = Xrm.Page.getControl("booked_asset").getGrid().getSelectedRows();
    
sRows.forEach(function (selectedRow, i) {
        selectedEntityReferences.push(selectedRow.getData().getEntity().getEntityReference());
    });
 //get all required data from each selected row    
for (let i = 0; i < selectedEntityReferences.length; i++) {
        if (sGuids == "") {
            sGuids = (selectedEntityReferences[i].id.toString());        
}
        else {
            sGuids = sGuids + "," + (selectedEntityReferences[i].id.toString());
        }    
}  
//clear field value    
Xrm.Page.getAttribute("soft_selectedassetlist").setValue(""); 
//set attribute value     
Xrm.Page.getAttribute("soft_selectedassetlist").setValue(sGuids);
    Xrm.Page.data.entity.save();
}

Thanks !!

Refresh Sub-Grid based on field value

Sometimes we need to refresh (or load data) MSD 365 sub-grid data based on some condition. This can be done with small JS, here is the sample code, its applicable to the editable grid as well….

But make sure that

  • The grid you are configuring is not set to ‘Related Records only’
  • You are configuring same entity which you querying in the query

ed grid

Here is the code ….

function FilterSubgridBasedOnField() {
var sGrid = window.parent.document.getElementById("Your_Grid_Name");
if (sGrid == null) {
alert("Grid is null");
setTimeout(function () { FilterSubgridBasedOnField(); }, 2000);
return;
 }
var fetchXml = [ "Your Fetch XML Query" ].join("");
if (sGrid.control != null) {
sGrid.control.SetParameter("fetchXml", fetchXml);
sGrid.control.refresh();
alert("Sub-Grid has updated with new data.");
 }
else {
setTimeout(FilterSubgridBasedOnField, 500);
}
}

Thanks !!

bulk Create/Update/Delete for Dynamics 365

 Secret

Create / Update / Delete can be done with bulk operation, to avoid more DB hits and it will improve performance of the plugins and or code.

Here is reference MSDN URL http://msdn.microsoft.com/en-us/library/jj863631.aspx

Default max batch size is 1000, its applicable for all three create/update/delete.

  1. bulk Create can be done with following code snippet
CreateRequest createRequest = new CreateRequest { Target = 'your Entity Object' };

2. bulk Update can be done with following code snippet

UpdateRequest updateRequest = new UpdateRequest { Target = 'your Entity Object' };

3. bulk Delete can be done with following code snippet

DeleteRequest deleteRequest = new DeleteRequest { Target = 'your Entity Reference Object' };

Here are sample code blocks for bulk Update

 

Create multiple execute request

/// <summary>
 /// Create an ExecuteMultipleRequest object
 /// </summary>
 /// <returns></returns>
 private static ExecuteMultipleRequest CreateBulkExcuteRequest()
 {
 var multipleRequest = new ExecuteMultipleRequest()
 {
 // Assign settings that define execution behavior: continue on error, return responses.
 Settings = new ExecuteMultipleSettings()
 {
 ContinueOnError = false,
 ReturnResponses = true
 },
 // Create an empty organization request collection.
 Requests = new OrganizationRequestCollection()
 };
 return multipleRequest;
 }

Continue reading “bulk Create/Update/Delete for Dynamics 365”

Call action with input & output parameters

Continue reading “Call action with input & output parameters”