Skip to main content

Posts

Showing posts from 2017

Synchronous and asynchronous XMLHttpRequest in Javascript from Microsoft Dynamics CRM perspective

Below are the examples of Synchronous and Asynchronous XMLHttpRequest. Asynchronous request var req = new XMLHttpRequest(); req.open(requestType, serverURL + "/api/data/v8.2/" + query, false); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("Prefer", "odata.include-annotations=\"*\""); req.onreadystatechange = function () { if (this.readyState == 4 /* complete */) { req.onreadystatechange = null; if (this.status === 200) { var data = JSON.parse(this.response); fnSuccessCallback(data); } else { var error = JSON.parse(this.response).error; ...

Unable to see field on table in DB even after Synchronization in AX 2012

I was in front of an issue where new fields added on the AOT table were not visible in the database even after a successful synchronization. After some efforts, to find a solution, I found a solution below which is given in a post and it worked for me. Check below configuration 1.        Go to field properties (fields which are not able to visible in database table) 2.        Check EDT 3.        Go to EDT property 4.        Check configuration key. 5.        Go to Administration -> System -> Configuration 6.        Check configuration and Apply. thanks p.

Call javascript function on sub-grid refresh/load in Microsoft Dynamics CRM

Recently, I came across a requirement where I had to do some calculation based on records added/deleted in sub-grid on CRM form. To achieve this, I have added load event on sub-grid in javascript where I could call the method which is doing the calculations. Below piece of code will be used to add load event on sub-grid and function addEventToGridRefresh() should be registered on form load. function addEventToGridRefresh() { // retrieve the subgrid var grid = Xrm.Page.getControl('#GridControlName#'); // if the subgrid still not available we try again after 2 second if (grid == null) { setTimeout(function () { addEventToGridRefresh(); }, 2000); return; } // add the function to the onRefresh event Xrm.Page.getControl('#GridControlName#').addOnLoad(totalAssetsOfHousehold); // This is used to delay refresh by 1 second because sometimes grid takes time to load. // If you do not include below line, you may not ...

Get lookup control of editable grid in Dynamics CRM 2016 using JavaScript

A look up control value of the editable grid can be captured using JavaScript. One thing to note, always check Pass execution context as the first parameter shown in below image. Without this you won't be able to work on editable grids. Editable grids doesn't work in the Xrm.Page context. Handler properties of Editable Grid Your javascript web resource will have following code. In code below, look up value is being checked and based upon that other controls in the grid will be disabled. function gridDisableEstimatesOnStatusChange(executionContext) { var entityObject = executionContext.getFormContext().data.entity; var statusValue = entityObject.attributes.getByName('##lookup control logical name##').getValue(); if(statusValue != 0) { var estimateControl = entityObject.attributes.getByName('##control's logical name##').controls.get(0); estimateControl.setDisabled(true); // Set value of any other control ...

Bind JQuery datatable dynamically with a button in the grid

Whenever we bump into the requirement to show custom data (fetched from database or external application) on HTML using JQuery, its datatable control can be used. JQuery datatable has inbuild features like pagination and auto complete search. It's quite simple to implement them. Below sample shows how to bind dynamic data to JQuery datatable with a button control in the grid. Your HTML code: Your Javascript : Javascript Code Output: Output thanks p.