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 / Sequence Function Addi...
Power Apps
Answered

Sequence Function Adding more rows after submit

(0) ShareShare
ReportReport
Posted on by 237

Hi,

 

I am using a sequence function to add rows based on the # of event days in my editable gallery. The function works fine. However, after the rows get added and the user populates the data and goes to hit submit, after selecting submit, the gallery ends up adding the same number of rows again. If I use the +New button, which adds 1 row at a time and then hit submit, this issue doesn't happen.

 

See formula for adding rows based on number of event days:

 

 

ForAll(
 Sequence(Value(varRecord.EventDays)),
 Patch(
 'Checklist Details',
 Defaults('Checklist Details'),
 {Title: varRecord.ID},
 {'Event Date': varRecord.'Event Start Date'},
 {'Event Zip': varRecord.'Event Zip Code'},
 {'Non Attendees': varRecord.'Non Attendees'},
 {'Attendees': varRecord.'Attendees'},
 {'Required Meals':LookUp(Choices('Checklist Details'.'Required Meals'),Value="-")},
 {
 'Event Lookup': {
 Value: varRecord.Title,
 Id: varRecord.ID
 }
 }
));

 

 

Formula to add 1 row at a time:

 

 

Patch(
 'Checklist Details',
 Defaults('Checklist Details'),
 {Title: varRecord.ID},
 {'Event Date': varRecord.'Event Start Date'},
 {'Event Zip': varRecord.'Event Zip Code'},
 {'Non Attendees': varRecord.'Non Attendees'},
 {'Attendees': varRecord.'Attendees'},
 {'Required Meals':LookUp(Choices('Checklist Details'.'Required Meals'),Value="-")},
 {
 'Event Lookup': {
 Value: varRecord.Title,
 Id: varRecord.ID
 }
 }
);
Select(btnLoadMeals);
ClearCollect(
 colPerDiemRate,
 Table1
);

 

 

 

Submit button formula:

 

 

Patch(
 'Checklist Details',
 ShowColumns(
 colAddMealsUpdates,
 "Title",
 "Event_x0020_Date",
 "Event_x0020_Duration_x0020__x002",
 "Non__x0020_Attendees",
 "Attendees",
 "Per_x0020_Diem_x0020_Rate",
 "Per_x0020_Diem_x0020_Total",
 "Required_x0020_Meals",
 "ID",
 //"Total_x0020_Attendees",
 "Event_x0020_Zip",
 "EventLookup"
 )
);
If(
 varEditButton<>1,
 Patch(
 'Event Information',
 LookUp(
 'Event Information',
 ID = varRecord.ID
 ),
 {'Workflow Status': {Value: "In Progress"}}
 ),
 Patch(
 'Event Information',
 LookUp(
 'Event Information',
 ID = varRecord.ID
 ),
 {'Workflow Status': {Value: "Resubmit"}}
));

Select(btnLoadMeals);
Navigate(Screen2);

 

 

 

Editable screen gallery

After hitting submit, the 3 highlighted got added again:

NPatel12498_0-1708011104092.png

 

 

Categories:
  • CU18061035-1 Profile Picture
    Microsoft Employee on at

    hey @NPatel12498 

     

    try this please:

     

    If(
     !varRowsAdded,
     ForAll(
     Sequence(Value(varRecord.EventDays)),
     Patch(
     'Checklist Details',
     Defaults('Checklist Details'),
     {Title: varRecord.ID},
     {'Event Date': varRecord.'Event Start Date'},
     {'Event Zip': varRecord.'Event Zip Code'},
     {'Non Attendees': varRecord.'Non Attendees'},
     {'Attendees': varRecord.'Attendees'},
     {'Required Meals':LookUp(Choices('Checklist Details'.'Required Meals'),Value="-")},
     {
     'Event Lookup': {
     Value: varRecord.Title,
     Id: varRecord.ID
     }
     }
     )
     ),
     Set(varRowsAdded, true)
    );
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • NP-18101421-0 Profile Picture
    237 on at

    Hi,

     

    It looks like when I went back into edit the request, it showed up again with the extra rows generated with the formula you suggested above

     

    NPatel12498_0-1708013089895.png

     

  • CU18061035-1 Profile Picture
    Microsoft Employee on at
    ForAll(
     Sequence(Value(varRecord.EventDays)),
     With(
     {currentDayIndex: Value},
     With(
     {existingRecord: LookUp('Checklist Details', 'Event Lookup'.Id = varRecord.ID && 'Day Index' = currentDayIndex)},
     If(
     IsBlank(existingRecord),
     // If the record does not exist, add a new one
     Patch(
     'Checklist Details',
     Defaults('Checklist Details'),
     {
     Title: varRecord.ID,
     'Event Date': DateAdd(varRecord.'Event Start Date', currentDayIndex - 1, Days),
     'Event Zip': varRecord.'Event Zip Code',
     'Non Attendees': varRecord.'Non Attendees',
     'Attendees': varRecord.'Attendees',
     'Required Meals': LookUp(Choices('Checklist Details'.'Required Meals'), Value="-"),
     'Event Lookup': {
     Value: varRecord.Title,
     Id: varRecord.ID
     },
     'Day Index': currentDayIndex // This assumes you have a way to store the day index or equivalent unique identifier
     }
     ),
     // If the record exists, update it
     Patch(
     'Checklist Details',
     existingRecord,
     {
     'Event Date': DateAdd(varRecord.'Event Start Date', currentDayIndex - 1, Days), // Update only if necessary
     // Update other fields if necessary
     }
     )
     )
     )
     )
    );
    

     

    try this modification please

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • NP-18101421-0 Profile Picture
    237 on at

    Sorry, what is 'Day Index'? I do not have that as a column in my list

  • Verified answer
    NP-18101421-0 Profile Picture
    237 on at

    Hi,

     

    I was able to resolve this issue. My update button didn't have the logic to update all of the fields in the gallery as my submit button did. For some reason, it works when it uses the same logic as the submit button. Only difference is that the patch function in the update duration button doesn't trigger a workflow where as the submit button does.

     

    Thanks for your help and time! @mmbr1606 

  • CU18061035-1 Profile Picture
    Microsoft Employee on at

    dont forget to accept an answer as solution so others can find the post with similar issues and see that the issue is resolved

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 232 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard