Tag Archives: javascript
Disable field on change of tab in D365 CE
Use case – Our requirement is to enable field description field on invoice line form on clicking of tab General. Let’s see how we can achieve this Solution – Step 1 – Create web resource with below function- var invoiceLineCustomization = { unlockField : function(executionContext) { var formContext = executionContext.getFormContext(); formContext.getControl(“description”).setDisabled(false); }, } Step 2: Add this web resource on tab property event TabStateChange and try. (path to go to event tab – Click on tab -> change properties -> event) Output – Hope this helps !
Disable field in Business Process Flow in D365 CE using JavaScript
Use case – Our requirement is to mark field Purchase time Frame disabled in Business process flow on change of disable field(custom field) on opportunity form. Let’s see how we can achieve this Solution – Step 1 – Create web resource with below function- Add header_process before schema name of field. Here schema name of purchase time frame field is purchasetimeframe. And after adding header_process_purchasetimeframe var opportunityCustomization = { //opportunityCustomization.disableField disableField : function(executionContext) { var formContext = executionContext.getFormContext(); var disable = formContext.getAttribute(“cf_disable”).getValue(); if (disable == true) { formContext.getControl(“header_process_purchasetimeframe”).setDisabled(true); } } } Step 2: Add this web resource on form load, on Save and on change of the field. And try Output – Hope this helps !
Xrm.Panel in D365
Overview Xrm.Panel is a new additional to the client-side scripting in Dynamics 365. This feature is still in preview in the D365 December 2016 update. Panel is a simple static place on your D365 web client which loads a Web Page inside it. Perhaps, the best use of the same could be a Web Chat application implementation. Implementation Simple – I’ve made a JS Web Resource that has a function to call the Xrm.Panel.loadPanel(url, title); method and I’ve invoked the same on change of a Phone Number. Here’s a simple JS snippet I’ve written: oAccountCustomization = { loadPanel: function() { “use strict”; Xrm.Panel.loadPanel(“https://cft89.crm.dynamics.com//WebResources/new_SamplePage”, “Hello”); } }; And redirected it to another HTML page in my own D365. Then, I’ve added this to the onChange of the PhoneNumber on the Account record. And saved and Published the customization. Seeing it work: Now, when I change the Phone Number field on the Account, the slider appears on the right hand side of the page. You can click on the arrow to bring it in focus. Here we go! The Panel is now seen. Remember, this works only on the Web Client.