Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Suggested answer

Custom page dialog promise

(1) ShareShare
ReportReport
Posted on by 21
With the Back() power fx function there needs to be the ability to pass variables back to the model driven app. This is when the we open the custom page via Xrm.Navigation.navigateTo() as a dialog. Is there really no ability provide context to JavaScript in the promise? I have looked into having power fx make a sesstionStorage but im trying to avoid going down the road of making a custom pcf to do this.
  • Suggested answer
    Jon Unzueta Profile Picture
    784 on at
    Custom page dialog promise

    You're absolutely right to explore this—passing data back from a custom page dialog in a model-driven app using Xrm.Navigation.navigateTo() is a common challenge, and unfortunately, Power Fx's Back() function does not support returning values directly to the calling JavaScript context.

    However, there is a workaround that developers have successfully used, and it avoids the need for a custom PCF. Here's a summary of the approach:


    Passing Data to the Custom Page

    You can pass structured data into the custom page by serializing it into the recordId field:

    const pageInput = {

      pageType: "custom",

      name: "your_custom_page_name",

      entityName: "your_entity_logical_name",

      recordId: JSON.stringify({

        recordId: "someId",

        sessionId: "uniqueSessionId",

        additionalParams: { foo: "bar", userId: "12345" }

      })

    };

    Xrm.Navigation.navigateTo(pageInput, { target: 2, position: 1, width: { value: 50, unit: "%" } });

     

    In the custom page, use Power Fx to parse the incoming data:

    Set(varInput, ParseJSON(Param("recordId")));

    Set(gblSessionId, Text(varInput.sessionId));

    Set(gblAdditionalParams, ParseJSON(varInput.additionalParams));

     Returning Data from the Custom Page

    Since Back() can't return values, you can simulate a callback using a custom Dataverse table (e.g., custompagescallback) and a session ID:

    1. Write the result to the custom table from Power Fx when the user clicks "Submit":

    Patch(custompagescallback, Defaults(custompagescallback), {

      sessionId: gblSessionId,

      resultData: JSON(gblResult)

    });

    Back();

     

    In JavaScript, after the dialog closes, poll or fetch the result using the session ID:

    Xrm.Navigation.navigateTo(pageInput, navOptions)

      .then(() => fetchCallbackData(sessionId))

      .then((cbData) => {

        if (cbData) {

          // Use the returned data

          console.log("Callback data:", cbData);

        }

      });

    🏷️ Tag me if you have any further questions or if the issue persists.
    ✅ Click "Accept as Solution" if my post helped resolve your issue—it helps others facing similar problems.
    ❤️ Give it a Like if you found the approach useful in any way.

     

Under review

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

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 770 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 494

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 399