JS web resource Archives -

Tag Archives: JS web resource

Auto Refresh Subgrid in Dynamics 365 CRM Based on Changes in Another Subgrid

In Dynamics 365 CRM implementations, subgrids are used extensively to show related records within the main form. But what if you want Subgrid B to automatically refresh whenever a new record is added to Subgrid A, especially when that record triggers some automation like a Power Automate flow or a plugin that creates or updates related data? In this blog, I’ll walk you through how to make one subgrid refresh when another subgrid is updated — a common real-world scenario that enhances user experience without needing a full form refresh. Let’s say you have two subgrids on your form: Whenever a new record is added in the Chargeable Categories subgrid, a Power Automate flow or backend logic creates corresponding records in Order Line Categories. However, these new records are not immediately visible in the second subgrid unless the user manually refreshes the entire form or clicks on the refresh icon. This can be confusing or frustrating for end-users. Solution Overview To solve this, we’ll use JavaScript to listen for changes in Subgrid A and automatically refresh Subgrid B once something is added. Here’s the high-level approach: Implementation Steps 1. Create the JavaScript Web Resource Create a new JS web resource and add the following code: How It Works To conclude, this simple yet effective approach ensures a smoother user experience by reflecting backend changes instantly without needing to manually refresh the entire form. It’s particularly helpful when automations or plugins create or update related records that must appear in real-time. By combining JavaScript with Dynamics’ form controls, you can add polish and usability to your applications without heavy customization. I hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com.

Passing parameters to JavaScript Web Resource function in Dynamics CRM

Introduction: In this blog we will see how we can pass parameters to a JavaScript function where the function is generic and can be reused. Implementation: Let’s take an example where you would check if account number is present or not in the account field. 1. Create a JS function to check if account number is present in the Account field. 2. Add function to the Web Resource library in solution. 3. Adding it to the form of the Account entity to reflect the output on load of the page. 4. Checking for the result on load of Account. Hope this helps …

Create, Update, Delete data Client side using XRM Web API in Dynamics 365 (Client API Reference)

Introduction Below is the Syntax that’s available to create, delete, update a record in Dynamics 365 Online V9.X using JavaScript. Create record (Client API Reference) Below is the Syntax that’s available to create a record in Dynamics 365 Online V9.X using JavaScript Syntax : Xrm.WebApi.createRecord(entityLogicalName, data).then(successCallback, errorCallback); Implementation : Let’s take an example where you would like to Create the Account record. // define the data to create new accountvar data = { “name”: “Sample Account”, “creditonhold”: false, “address1_latitude”: 47.639583, “description”: “This is the description of the sample account”, “revenue”: 5000000, “accountcategorycode”: 1 }// create account recordXrm.WebApi.createRecord(“account”, data).then( function success(result) { console.log(“Account created with ID: ” + result.id); // perform operations on record creation }, function (error) { console.log(error.message); // handle error conditions }); Update record (Client API Reference) Below is the Syntax that’s available to update a record in Dynamics 365 Online V9.X using JavaScript Syntax :  Xrm.WebApi.updateRecord(entityLogicalName, id, data).then(successCallback, errorCallback); Implementation : Let’s take an example where you would like to Update the Account record. // define the data to update accountvar data = { “name”: “Updated Sample Account “, “creditonhold”: true, “address1_latitude”: 47.639583, “description”: “This is the updated description of the sample account”, “revenue”: 6000000, “accountcategorycode”: 2}// update the recordXrm.WebApi.updateRecord(“account”, “5531d753-95af-e711-a94e-000d3a11e605”, data).then( function success(result) { console.log(“Account updated”); // perform operations on record update }, function(error) { console.log(error.message); // handle error conditions }); Delete record (Client API Reference) Below is the Syntax that’s available to delete a record in Dynamics 365 Online V9.X using JavaScript Syntax : Xrm.WebApi.deleteRecord(entityLogicalName, id).then(successCallback, errorCallback); Implementation : Let’s take an example where you would like to Delete the Account record. Xrm.WebApi.deleteRecord(“account”, “5531d753-95af-e711-a94e-000d3a11e605”).then( function success(result) { console.log(“Account deleted”); // perform operations on record deletion }, function (error) { console.log(error.message); // handle error conditions }); Hope this Helps ….

SEARCH :

FOLLOW CLOUDFRONTS BLOG :

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange