Posts

D365 Common Functions - Jump Start Development

function SetFormContextToTheWebResource(formContext, htmlResources) { // debugger; for ( var i = 0 ; i < htmlResources.length; i ++ ) { var wrControl = formContext.getControl(htmlResources[i]); if (wrControl) { wrControl.getContentWindow().then( function (contentWindow) { // debugger; contentWindow.setFormContext(formContext, Xrm); } ); } } }

Dynamics 365 - Xrm WebAPI

Microsoft has come up with latest Client APIs for Customer Engagement V9.0. These APIs stream line a lot of stuff we used to do with Javascript in earlier versions. Let’s look in depth into the APIs now. Create Record Update Record Delete Record Retrieve Record Retrieve Multiple Records Execute   Each function has callback functions to handle success and failures. Create Record Syntax: Xrm.WebApi.createRecord(entityLogicalName, data).then(successCallback, errorCallback); Parameters: entityLogicalName – logical name of the entity data – JSON data successCallback - success function with parameters entityType and id(entityId) errorCallback – error function with parameters errorCode and message(errorMessage) Example: var data =     {         "name" : "Chandrahas" ,         "address1_address" : "Chandrahas Address" ,         "description" : "Sample Description",     } Xrm.

Dynamics 365 - Dynamically create Custom Lookup View(JavaScript)

Image
We might have come across a requirement where we need to dynamically show users custom lookup views. We all know how we can set up views in Dynamics CRM by creating new views for an entity and updating the lookup properties to show required views. Dynamics CRM provides us with the JS method ‘addCustomView’ which will be used for approach. This method takes the following arguments.          View ID (Guid)          Entity Name (String)         View Display Name (String)         Fetch XML (String)         Layout XML (String)         Boolean (to specify if this view is a default view or not) Below is the custom JS script which can be modified as per our requirements. In my case, I needed to have a custom view for users lookup and I have run this script on form onload. Note: For this to work, we need to enable view selector in CRM Form. See below. Code: function setCustomUsersView() { var functionName = "MyCustomUsersView";