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!

 

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”

Web API and plural names

beware

JavaScript Plural name issue almost killed us, following post saved us. 🙂 …. CRM 2016 Web API and plural names … Thanks for the post nice post. I’m re-posting the article ..

The new Web API available for CRM 2016 is based on OData V4 protocol and the endpoint is /api/data/v8.0/

Continue reading “Web API and plural names”

Refresh roll up field from plugin

data retrival

Roll up fields are very useful, it reduce lots of manual and coding efforts. This rolls up field will auto refresh by each hour by default, off course it can be changed any time.

But what if developer wants to refresh it on fly from plugin itself to make following logic to work perfectly, which is dependent on this roll up field? Is there any way for this? or roll up fields are not useful in such a condition.

Yes, there is way we need to execute “CalculateRollupFieldRequest and CalculateRollupFieldResponce” functions to refresh roll up attributes.

Call to refresh the roll up field, here is sample code….

Entity incident = new Entity(“incident”)
{ Id = incidentId };

int refreshedExAssetRequested = RefreshRollup(context, incident, “soft_exassetrequested”);
context.Trace(“new soft_exassetrequested: ” + refreshedExAssetRequested);

Function to execute

/// <summary>
/// refresh attribute
/// </summary>
/// <param name=”context”></param>
/// <param name=”entityToRefresh”></param>
/// <param name=”fieldToRefresh”></param>
/// <returns></returns>
internal static int RefreshRollup(SelectContext context, Entity entityToRefresh, string fieldToRefresh)
{

// print the old value of the roll-up field
context.Trace(“Total Accepted Qty (updated)= ” + entityToRefresh.GetAttributeValue<int>(fieldToRefresh));
// create a request by passing an entity reference and the targeted rollup field name
CalculateRollupFieldRequest crfrRequested = new CalculateRollupFieldRequest
{
Target = new EntityReference(entityToRefresh.LogicalName, entityToRefresh.Id),
FieldName = fieldToRefresh
};

CalculateRollupFieldResponse responseRequested = (CalculateRollupFieldResponse)context.OrgService.Execute(crfrRequested);

// read the entity and value of the rollup field
entityToRefresh = responseRequested.Entity;

// print the new value of the roll-up field
context.Trace(“Total Accepted Qty (updated)= ” + entityToRefresh.GetAttributeValue<int>(fieldToRefresh));

return entityToRefresh.GetAttributeValue<int>(fieldToRefresh);
}

Also, same rollup can be refreshed from JavaScript, here is sample code for it. Only thing you need to keep in the memory is that this refresh is async call and may take 10 second to refresh.

function RefreshSHRollup(entityToRefresh, entityId, rollupField) {

    //var requestUrl = Xrm.Page.context.getClientUrl() + "/api/data/v9.0/CalculateRollupField(Target=@tid,FieldName=@fn)?@tid={'@odata.id':'" + entityToRefresh + "(" + entityId + ")'}&@fn='" + rollupField + "'";
    var requestUrl = Xrm.Page.context.getClientUrl() + "/api/data/v9.0/CalculateRollupField(Target=@p1,FieldName=@p2)?@p1={'@odata.id':'" + entityToRefresh + "s(" + entityId + ")'}&@p2='" + rollupField + "'"

    try {

        var req = new XMLHttpRequest();
        req.open("GET", requestUrl, false);
        req.send();

    } catch (e) {
        console.log(e.message);
    }   

}

That’s it!

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

Editable Views in MSD 365

In MSD 365, developer’s life is much easier than earlier. I do remember my team invested days to developer editable grids for an entity on from.

But now it’s just out of the box feature, it’s cool, isn’t it?

This feature has been introduced in MSD CRM 2015 but it was for very limited entities. But now it’s available for almost all entities including custom entities.

For this we need enable entity to be editable. Here are the steps to make it enable

  1. Go to customisation
  2. Open entity configuration
  3. editble grid 1
  4. Click on Control to add editable grid for the entity
  5. editble grid 2
  6. now  select it behaviour
  7. editble grid 3
  8. After behaviour selection, publish the entity.
  9. It will make main view as editable on the fly.
  10. You can undo this editable grid any time in future,  for that just delete added control and publish the entity
  11. That’s it.

Thanks !!

MB2-718 Certification: (Microsoft Dynamics 365 Customer Service) – Case Management (Part One)

Awesome stuff !!

Microsoft Dynamics 365

As I revised for the MB2-718 exam (Microsoft Dynamics 365 Customer Service) I’m creating blog posts detailing all aspects of my revision. I hope these posts will aid anyone who is also revising for this exam. In this post I will provide details on case management.

The skills measured statement relating to case management is shown below. From this we can see that case management covers a wide variety of capabilities;


In total I will cover quite a bit of ground! In this post I will include;

  • Cases An Overview
  • Case Views
  • Searching Cases
  • Creating Cases from Activities
  • Case Business Process Flow

The in a second post I will cover;

  • Resolving Cases
  • Routing Cases
  • Parent / Child Cases
  • Merge Cases

As already mentioned cases are a fundamental part of the service functionality in Dynamics 365, therefore I suggest you spend a significant amount of you exam preparation time creating cases…

View original post 1,816 more words

Automated UI testing API for Dynamics 365

TestingAutomation

Overview

The purpose of this library is to provide Dynamics customers the ability to facilitate automated UI testing for their projects. These API’s provide an easy to use set of commands that make setting up UI testing quick and easy. The functionality provided covers the core CRM commands that end users would perform on a typical workday and working to extend that coverage to more functionality. Continue reading “Automated UI testing API for Dynamics 365”