My Photo

Microsoft Dynamics 365

Official Blog for Microsoft Dynamics Functional and Technical Solutions....

Telerik Kendo UI: Get sum and average of selected items of a grid in alert / Field / popup for specific columns


Recently we were having a requirement to get sum and average of selected items on a grid in either an alert / Field or popup
Such as in the below example I want to get the average and Sum of selected Frieght columns

And also we wanted to allow this feature only on numeric fields. 


We were able to archive the desired result by using the change event, select and the dataItem methods to get the value of the selected cells. Then we used column index to get the selected column. And to restrict the calculation only for numeric column we programmatically remove the k-state-selected class from the desired cells.

Code Snippet :

<script> $(document).ready(function () { $("#grid").kendoGrid({ dataSource: { type: "odata", transport: { read: "" }, schema: { model: { fields: { OrderID: { type: "number" }, Freight: { type: "number" }, ShipName: { type: "string" }, OrderDate: { type: "date" }, ShipCity: { type: "string" } } } }, pageSize: 20 }, height: 550, filterable: true, sortable: true, pageable: true, selectable: "multiple cell", columns: [{ field: "OrderID", filterable: false, selectable: false }, "Freight", { field: "OrderDate", title: "Order Date", format: "{0:MM/dd/yyyy}", selectable: false }, { field: "ShipName", title: "Ship Name", selectable: false }, { field: "ShipCity", title: "Ship City", selectable: false } ] }); var grid = $("#grid").data("kendoGrid"); grid.bind("change", grid_change); }); function grid_change(e) { debugger; var selectedCells =; var cellOne = selectedCells[0] var colIdx =; var colName = $('#grid').find('th').eq(colIdx).text() if (colName === "Freight") { // execute only for number columns var selectedDataItems = []; var sumOfSelectedItems = 0; var averageOfSelectedItems = 0; for (var i = 0; i < selectedCells.length; i++) { var dataItem = this.dataItem(selectedCells[i].parentNode); if ($.inArray(dataItem, selectedDataItems) < 0) { selectedDataItems.push(dataItem); } } for (let i = 0; i < selectedDataItems.length; i++) { sumOfSelectedItems += parseFloat(selectedDataItems[i].Freight); } averageOfSelectedItems = sumOfSelectedItems / (selectedDataItems.length); averageOfSelectedItems = parseFloat(averageOfSelectedItems); alert("Sum : "+ sumOfSelectedItems.toFixed(2)); alert("Average : " + averageOfSelectedItems.toFixed(2)); $("#sumvalue").empty(); $("#sumvalue").append(sumOfSelectedItems.toFixed(2)); $("#Averagevalue").empty(); $("#Averagevalue").append(averageOfSelectedItems.toFixed(2)); $("#calculatedFields").show(); } } </script> </head> <body> <div class="container-fluid"> <div class="row k-header"> <h1> My App</h1> </div> </div> <div class="container-fluid"> <div class="demo-section k-content"> <div id="calculatedFields" style='float: left; display:none;'> <div style='float: left; margin-right: 30px;'> <span id="lblSum"> Sum : </span> <label id="sumvalue"></label> </div> <div style='float: left; margin-right: 30px;'> <span id="lblAverage">Average : </span> <label id="Averagevalue"></label> </div> </div> </div> <div> <div class="row"> <div class="col-xs-18 col-md-12"> <div id="grid"></div> </div> </div> </div> </div> <div class="container-fluid"> <div class="row"> <div class="col-xs-18 col-md-12"> <div id="grid"></div> </div> </div> </div> </body> </html>

Demo URL :

For your reference I made an example demonstrating this requirement :

Other Useful URLs:

Hope It Helps 😊

Happy Coding ✌

Error: NuGet Package Manager 2.8.50126.400 or later is required

 For Visual studio 2013, when I try to create a new project either for Kendo UI ASP .NET MVC 5 Application or for Telerik ASP .Net MVC Application, I get this error message "NuGet Package Manager 2.8.50126.400 or later required".


NuGet Package Manager 2.8.50126.400 or later is required


Download and Install the latest NuGet Package manager for visual studio 2013 from here 

Dynamics CRM V9 / D365 Connection through Console without Prompt

There are 2 major steps involved in the process.
  • Register the application with your Azure subscription
  • Build the Console Application
Register the application with your Azure subscription

Build the Console Application 

You need to change only the below authentication method in step 3 rest remains same

Pass user credentials with service URL and client id in Authentication Context

string authority = "";
AuthenticationContext authContext = new AuthenticationContext(authority, false);
var credentials = new UserCredential("", "pas@wrd1");
//without prompt
AuthenticationResult authResult = authContext.AcquireToken(serviceUrl, clientId, credentials);
authHeader = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
You can have a look at my code here :Sample Code

Happy Coding and CRMing 😊


Host free website on free server and domain (Host website on windows server for free No credit card required)

If you wanna test you website on public domain without purchasing an website hosting , you can register on below website : Click Here  (On Azure we get 30 days trail and it require credit card )

once registered Login and find you FTP details , you can also map you custom domain to the hosting.

You will get an free domain to view your website. Hope this was helpful. thanks


Dynamics 365 V9 : New feature lookupObjects (Xrm.Utility.lookupObjects)

Opens a lookup control to select one or more items.
Microsoft dynamics 365 V9.0 has enhanced many existing features in CRM online and has also introduced new features. Xrm.Utility namespace has also been enhanced with new feature like
and LookupObjects.

Lets take an example creating new field in account "new_lookupfilter"  when write js on change of this field (if we enter 'admin' it will open an lookup dialog of contact entity and we can modify it i.e multi-select E.T.C )

Now  selected record can be set to any other field.


function lookUpobjectTest() {
    // Set properties here
    var lookupOptions = {
        defaultEntityType: "contact",
        defaultViewId: "{608861bc-50a4-4c5f-a02c-21fe1943e2cf}", // GUID of the View
        viewIds: ["{00000000-0000-0000-0000-000000000000}",
                        "{00000000-0000-0000-0000-000000000000}"], // GUID of the View
        entityTypes: ["contact", "incident"],
        allowMultiSelect: true

Hope this was Helpful. Thanks


Show Progress Indicator (Out of the box) Microsoft Dynamics 365 CRM V9

Yesterday used a nice feature progress indicator, before we use to write custom JS to show loading progress image but now we can use new JavaScript function of the Xrm.Utility namespace : showProgressIndicator.

  • showProgressIndicator
  • closeProgressIndicator

show progress indicator (loading image)


function setFaxNumber() {
    Xrm.Utility.showProgressIndicator("Loading contact Info..");
    setTimeout(setFaxNumberafterdelay, 3000);
function setFaxNumberAfterDelay() {
    var phoneNumber = Xrm.Page.getAttribute("telephone1").getValue();
    if (phoneNumber != null) {