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”

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 !!

Colourful MSD 365 Views/Grid

new things

Many times client ask to make views colourful based on some condition in MSD 365.

In earlier MSD CRM version, it was big and totally unsupported change. But now we can do the same thing in a supported way.

Here we need to create JavaScript library for this single function, as it won’t work if the same library has any other function (it’s strange, but happened with me). Well, here are the steps for it

  1. Create attribute or use existing option set, e.g. priority
    1. Option set text: Low, value: 15
    2. Option set text: Normal, value: 14
    3. Option set text: Critical, value: 12
    4. Option set text: Blocker, value: 11
    5. …and so on…
  2. Get colour images of 16X16 for each type e.g.
    1. Option set text: Low ==> Image: soft_Low
    2. Option set text: Normal ==> Image: soft_Normal
    3. Option set text: Critical ==> Image: soft_Critical
    4. Option set text: Blocker ==> Image: soft_Blocker
    5. …and so on…
    6. please no that its should be fine with all image type but i tried with PNG only 
  3. Create a JavaScript library in system keep below function
  4. Register this function on the view ==> Attribute (Priority). Here is the post for how to execute JavaScript on MSD 365 views.
  5. It will look like below …

colourful view

6. well, here is JavaScript function for your reference ….

//exe on incident view
function displayIconTooltip(rowData, userLCID) {

//alert(“..yes, its View Script..!!”);
var str = JSON.parse(rowData);
var col_data = str.soft_priority_Value; // this is the attribute name from system
var imgName = “”;
var tooltip = “{” + col_data + “}”;

switch (col_data) {
case 16: //it is optionset value
imgName = “img_VeryLow”;  // it’s image name from system
tooltip = “Very Low”;
break;
case 15:
imgName = “img_Low”;
tooltip = “Low”;
break;
case 14:
imgName = “img_Normal”;
tooltip = “Normal”;
break;
case 13:
imgName = “img_High”;
tooltip = “High”;
break;
case 12:
imgName = “img_Critical”;
tooltip = “Critical”;
break;

case 11:
imgName = “img_Blocker”;
tooltip = “Blocker”;
break;

default:
imgName = ” “;
tooltip = “N/A”;
break;

}
var resultarray = [imgName, tooltip];
return resultarray;

}

7. This same configuartion will work for MSD Gris as well..

color grid

Caution:

  1. Please note that this function will execute on each record one by one, so it may affect the performance.
  2. This configuration won’t work for Editable Grid.

Thanks!!

 

 

 

Editable Grid on Form and Workflow issue

new things

In the earlier post, it’s explained that how to make a view to be editable (Click here to explore that article). In this post, I will explain how to make any entity grid editable on form where it has been used as Sub-grid.

Its as well a simple configuration, here are the steps for it,

  1. First of all, that particulate entity must be enabled for an edit on entity level, if you don’t know how to make it, please explore it here.
  2. well, one entity is enabled for it now, open that particular form where you want make sub-grid as editable
  3. select that sub-grid and click on change property button on ribbon or simply double-click on that sub-grid. Refer below screenshot for same…..
  4. editble grid 4
  5.  once you open Sub-grid property, please click on Control tab ==> Add Control, please refer below screen shot for it…..
  6. editble grid 5
  7. It will add control, now set the properties for the sub-grid for the form, ref below screenshot …..
  8. editble grid 6
  9. Now, please save and publish the entity.

 

but there is one issue with the editable grid when we add that on from then Workflow dynamic values will be completely blank, just like below …

This slideshow requires JavaScript.

Resolution for the issue is…

  1. deactivate the editable grid form then create the workflow, re-activate the editable grid form
  2. Remove the editable grid feature from the form then create workflow and enable the editable grid feature on the form

That’s it!!

Thanks !!