web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

How to refresh a form at the end of a dialog.

Posted on by

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 .

function CaptureResponseButtonAction(primaryControl) {
    debugger;
    var formContext = primaryControl;
    formContext.data.refresh(true);}

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans