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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Pass value from main f...
Power Apps
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);

 

I have the same question (0)
  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    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

  • Jonathan Manrique Profile Picture
    2,687 on at

    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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard