Skip to main content

Posts

Showing posts from June, 2021

D365 Calculate unitwise product quantity into Opportunity field using javascript

  function CalculateOpportunityProductQuantity(executionContext) { var formContext = executionContext.getFormContext(); var opportunityRecordId = formContext.data.entity.getId().slice(1, -1); var globalContext = Xrm.Utility.getGlobalContext(); // Retrive unitwise product quantity data var fetchXml = "<fetch mapping='logical' >" + "<entity name= 'opportunity' >"+ "<link-entity name='opportunityproduct' from='opportunityid' to='opportunityid' alias='opportunityprod' >"+ "<attribute name='quantity' />"+ "<filter>"+ "<condition attribute='opportunityid' operator= 'eq' value='" + opportunityRecordId + "' uiname='Will be ordering' uitype='opportunity' />"+ "</filter&

Dynamics 365 Set a Lookup Field Using JavaScript from another lookup selection change

 In my case, I will select a contact from lookup and it will fill the account lookup field. function OnContactChange(executionContext) { var formContext = executionContext.getFormContext(); if (formContext.getAttribute("parentcontactid").getValue() != null) { var CustomerId = formContext.getAttribute("parentcontactid").getValue()[0].id.slice(1, -1); var CustomerName = formContext.getAttribute("parentcontactid").getValue()[0].name; var CustomerType = formContext.getAttribute("parentcontactid").getValue()[0].entityType; // Call contact API Xrm.WebApi.retrieveRecord("contact", CustomerId, "?$select=_parentcustomerid_value").then( function success(contactresult) { // Call Account Xrm.WebApi.retrieveRecord("account", contactresult._parentcustomerid_val