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 / How to run functions i...
Power Apps
Unanswered

How to run functions in sequence order in PowerApps

(0) ShareShare
ReportReport
Posted on by 84

Hi,

 

I see i'm not the first one to encounter this issue of sequence.

But i have a power app where i have a gallery, which is connected to a Form.

 

When is select the gallery, i need

- a NewForm if the record doesn't exist yet in the data set of the form

- if i do find a match in the dataset with the Item selected in the gallery, i need to display (EditForm) this data in my form.

 

When I select a new Item in the gallery, i need

- the form to be posted against the Item that was selected before

- a NewForm displayed if the record doesn't exist yet in the data set of the form

- if i do find a match in the dataset with the Item selected in the gallery, i need to display (EditForm) this data in my form.

 

JeanPhilippevb_1-1675787209764.png

 

Where do i define my Form mode?

is it in the "onSelect'" property of my gallery,

If(
    IsEmpty(First(Filter('Oevel-NCR-NonConfomityList',Title = Gallery1_1.Selected.Title)).Title),
    NewForm(Form10_3),
    EditForm(Form10_3)
)

or on the "onSucces" of the Form?

If(
    IsEmpty(Filter('Oevel-NCR-NonConfomityList',Title = Gallery1_1.Selected.Title)),
    NewForm(Form10_3),
    EditForm(Form10_3)
),

How do i Make sure the data submited in the submitform is against the Item that was selected before; and not the Item i now have selected in the gallery.

 

I tried to work around this with the 'submit data' button, so only after the button is clicked, a new selection in the gallery should be made... but this is very counter productive, and users will forget to click the button... but even then the radio controls will keep the value they had last time selected, and not the values of the newly selected Item.

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Jean-Philippevb 

    You are making this far more complicated than it needs to be.  

    • Adding a new record is normally done with a button Outside the gallery to set the form mode to create a new record. IE. a button with its OnSelect property:   NewForm(Form10_3)
    • To Edit a record, an icon inside the gallery is typically used with OnSelect property:  Edit(Form10_3)
    • The Item property for the form is simply: Gallery1_1.Selected and when the form is in New mode, the Item property is ignored by PowerApps since the record has not yet been created until you submit the form.
    • A button outside the form is used to submit the form.
      • Its OnSelect property is simply: SubmitForm(Form10_3)
      • no other commands should be ever be chained to follow the SubmitForm().  Any further commands should go in the OnSuccess property of the form itself. since you don't want them to execute if the form submission fails.
  • Verified answer
    Jean-Philippevb Profile Picture
    84 on at

    Hi Drrickryp,

     

    I tried to simplify my example as much as possible, but in doing so, i might not have given all information you need:

     

    My gallery is linked to my shipments table,

    Where as my form is linked to my Non-conformity table.

    so, it is not because i have a record in my Shipment table, that this record already has been logged as a non conformity.

     

    the users that are logging the non-conformities should be able to switch easily between shipments during their tasks,

    So i would like to avoid a button as much as possible, upon selecting a different shipment, the data of selected shipment should be stored, and the data of the newly selected shipment should be loaded...

     

    since i know at the moment 'onvisible' of the sheet how many records i need to create, i already created them in advance with a ForAll function => no more need to use the "NewForm" and "EditForm". And while writing this, i'm thinking i could just patch the data when they make a different selection, so i don't need to use the SubmitForm at all...

  • Verified answer
    Jean-Philippevb Profile Picture
    84 on at

    Creating the lines for all the needed records at moment of the 'OnVisible' of the screen, together with

    patching the data immediately at moment of entry did solve my issue of data being registered against the wrong selection of the gallery...

     

    Though it is long from an ideal solution, since if you patch a new line before the last patch action has been finished will cause the data of the first line not to be patched => only way to fix this is by patching it with a different value, and after patch again.

     

    but this does less damage to the data integrity (in worst case scenario, one of the fields will not have data, instead of the whole record being overwritten by the data of the previous selected record).

     

    i guess no better solution is available for now, so i can live with this.

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard