Hello,
I am facing an issue with refreshing the form after a dialog interaction. Here’s the scenario:
I have a function CaptureResponseButtonAction that initiates a dialog using Xrm.Navigation.navigateTo. At the conclusion of this dialog, I need to refresh the form. I've attempted to use formContext.data.refresh(false); in the success callback of Xrm.Navigation.navigateTo, but it doesn’t seem to function as expected.
Below is the relevant part of my code:
function CaptureResponseButtonAction(primaryControl) {
debugger;
var formContext = primaryControl;
const phoneactivityID = formContext.data.entity.getId();
var to = formContext.getAttribute("to").getValue();
var regarding = formContext.getAttribute("regardingobjectid").getValue();
const subject = formContext.getAttribute("subject").getValue();
const status = formContext.getAttribute("statecode").getValue();
if (to.length > 0) {
const contactdetailsPromise = Xrm.WebApi.online.retrieveRecord("contact", to[0].id, "?$select=emailaddress1,firstname,lastname,mobilephone,rst_mercuryid");
const campaignActivity = Xrm.WebApi.online.retrieveRecord("campaignactivity", regarding[0].id, "?$select=_regardingobjectid_value");
Promise.all([contactdetailsPromise, campaignActivity]).then((results) => {
var contactDetails = results[0];
var campaignActivity = results[1];
var data = {};
data["customer"] = [{ id: to[0].id, name: to[0].name, entityType: "contact" }];
data["firstname"] = contactDetails["firstname"];
data["lastname"] = contactDetails["lastname"];
data["telephone"] = contactDetails["mobilephone"];
data["emailaddress"] = contactDetails["emailaddress1"];
data["subject"] = subject;
data["channeltypecode"] = 2;
data["activity_ID"] = phoneactivityID;
data["client_ID"] = contactDetails["rst_mercuryid"];
data["activity_Status"] = status;
var createFromEntity = {
entityType: campaignActivity["_regardingobjectid_value@Microsoft.Dynamics.CRM.lookuplogicalname"],
id: campaignActivity["_regardingobjectid_value"],
name: campaignActivity["_regardingobjectid_value@OData.Community.Display.V1.FormattedValue"]
};
const pageInput = {
pageType: 'entityrecord',
entityName: 'campaignresponse',
data: data,
createFromEntity: createFromEntity
};
const navigationOptions = {
target: 2,
height: { value: 80, unit: '%' },
width: { value: 80, unit: '%' },
position: 1,
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success() {
console.log("Dialog completed successfully");
formContext.data.refresh(false);
},
function error() {
console.log("Error in navigating to dialog");
// Handle errors
}
);
});
}
}
also this is also not work .
