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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Change Gallery and put...
Power Apps
Answered

Change Gallery and put in edit mode after creating new record

(0) ShareShare
ReportReport
Posted on by 36

Hi there, 

 

I'm a real newbie in PowerApps and try to do my first steps^^.

 

Context:

With a button on a form, I create a new record which I pre-fill with some information with the patch function (see below).

After the creation of the record (which is functional), I'd like to change the edit form to go to the newly created record, switch the gallery to this record too and put the edit form in edit mode, for the user to complete the last details.

The following code is in the OnSelect property of the button:

ResetForm(FrmActivBody);
Patch(
 tblSupportActivities,
 Defaults(tblSupportActivities),
 {
 Scope_of_Support: "New Activity Title",
 Status: {Value: "G"},
 Trend: {Value: "Stable"},
 Start_Support: Today(),
 Planned_End: Today() + 90,
 Support_Provider: {
 Claims:"i:0#.f|membership|" & User().Email,
 Department: "",
 DisplayName:"",
 Email:"",
 JobTitle: "",
 Picture: "" 
 },
 ProjectRef: {
 Id: LookUp(
 tblProjects,
 prjID = GalProjects.Selected.prjID,
 prjID
 ),
 Value: "Text"
 }
 }
);
//Switch Gallery and edit form to the created record
Set(
 varGalActivDefault,
 FrmActivBody.LastSubmit
);
//Put the edit form in edit mode
EditForm(FrmActivBody);

Problem description:

As written above, the record gets created but then nothing happens. The gallery is not changing to the created record. Since this is not happening, the edit form (FrmActivBody) is put in edit mode - but on the current record (not on the new one).

I suppose it's not working since I'm not creating the record via the edit form (not submitted via FrmActivBody but created via patch function).

 

Does anyone know what I could change that this is working?

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    155,559 Most Valuable Professional on at

    Hi @Disubert ,

    This should be a more reliable method.

    ResetForm(FrmActivBody);
    Set(
     varGalActivDefault,
     Patch(
     tblSupportActivities,
     Defaults(tblSupportActivities),
     {
     Scope_of_Support: "New Activity Title",
     Status: {Value: "G"},
     Trend: {Value: "Stable"},
     Start_Support: Today(),
     Planned_End: Today() + 90,
     Support_Provider: 
     {
     Claims:"i:0#.f|membership|" & User().Email,
     Department: "",
     DisplayName:"",
     Email:"",
     JobTitle: "",
     Picture: "" 
     },
     ProjectRef: 
     {
     Id: 
     LookUp(
     tblProjects,
     prjID = GalProjects.Selected.prjID,
     prjID
     ),
     Value: "Text"
     }
     }
     )
    );
    EditForm(FrmActivBody);

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Disubert Profile Picture
    36 on at

    Hi Warren,

    Thanks for your reply, which works like a charm. When I read it right, the trick is to set the default variable of the gallery nested with the patch function and not one after the other ;-).
    Thanks for sharing the best practices!

  • WarrenBelz Profile Picture
    155,559 Most Valuable Professional on at

    Hi @Disubert ,

    Yes - the variable is set to the result of the Patch.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 387

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 301

Last 30 days Overall leaderboard