Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
Unanswered

Pass value from main form to quick create form in Model Driven Apps

(0) ShareShare
ReportReport
Posted on by

Hello,

i am creating a model driven app and I want to pass a value form the main form to the quick create form. This value is really just the selected field the main form is currently showing. 

 

I have tried executionContext.setSharedVariable on the main form and am trying to pass this via formContext.ui.setFormNotification to test if it is working, but the notification is empty (the notification appears when i pass a given string). Below is my code:


var RelationSetVarForQuickCreate = window.RelationSetVarForQuickCreate || {};
(function RelationSetVarForQuickCreate(){
 
    this.formOnLoad = function (executionContext) {

        var formContext = executionContext.getFormContext();

        var mySharedVariable= formContext.getAttribute("logical column name of mySharedVariable").getValue();
       
        formContext.ui.setFormNotification(mySharedVariable, "INFO", 1);

        executionContext.setSharedVariable("mySharedVariable", mySharedVariable); 
       
       }
}).call(RelationSetVarForQuickCreate);

 

Categories:
  • Jonathan Manrique Profile Picture
    2,678 on at
    Re: Pass value from main form to quick create form in Model Driven Apps

    Hi @MVersantsund 

     

    The first thing I would look for is to make the mapping between the parent table (main form) and the Child entity (quick creation form) so that the values can be passed automatically.

    In case this does not solve the entire scenario, I would use code and you can do it this way

    https://learn.microsoft.com/en-us/power-apps/maker/data-platform/map-entity-fields

     

    function ObtenerCorreo(e) {
     debugger;
     
     // Get the Form Context
     var formContext = e.getFormContext(); 
     
     // Set variables for the related entity to get data from
     try{var recordGuid = formContext.getAttribute("jm_profesor").getValue()[0].id; }
     catch(err) {}
     
     // If the recordGuid contains data
     if (recordGuid != null) {
     
     // Use the WebApi to get data 
     Xrm.WebApi.retrieveRecord("jm_profesor", recordGuid, "?$select=jm_nombre,jm_correoelectronico").then(
     
     // If successful, set variables for the results 
     function success(result) {
     var CorreoElectronico = result.jm_correoelectronico;
     
     // Set the form fields
     formContext.getAttribute("emailaddress").setValue(CorreoElectronico);
     
     },
     // If there's an error in the WebApi call, log the error and alert the user
     function (error) {
     console.log(error.message);
     // handle error conditions
     var errorMessage = 'Error: An error occurred in the GetRelatedInfo function: ' + error.message;
     var alertStrings = { confirmButtonLabel: "Yes", text: errorMessage };
     var alertOptions = { height: 120, width: 260 };
     Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
     function success(result) {
     console.log("Alert dialog closed");
     },
     function (error) {
     console.log(error.message);
     }
     ); 
     }
     );
     }
     }

     

    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.
    You can accept more than one post as a solution

  • a33ik Profile Picture
    3,304 Most Valuable Professional on at
    Re: Pass value from main form to quick create form in Model Driven Apps

    Hello,

    I might be wrong but setSharedVariable i used to pass the data within events on the same form. Is there a chance you can use mapping to pass that data between forms? https://learn.microsoft.com/en-us/power-apps/maker/data-platform/map-entity-fields

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

Announcing the Engage with the Community forum!

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Microsoft Dataverse

#1
mmbr1606 Profile Picture

mmbr1606 22 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 17

#3
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

Overall leaderboard

Featured topics