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 / Add Row in Gallery - R...
Power Apps
Answered

Add Row in Gallery - Reset

(0) ShareShare
ReportReport
Posted on by 75

Hi All,

I have created a gallery that I can add rows to. It works perfectly BUT once I submit and go back to the front page and try to create another one I press create to go back to the gallery but there is still a line viable, it has nothing in it but it technically shouldn't be there until the click "Add Row" I have put in the "Reset Gallery" formula but it still doesn't clear it

 

CAJ1_0-1684466924322.png

 

Categories:
  • EddieE Profile Picture
    4,650 Moderator on at

    @CAJ1 

    You need to supply your code for

    - The Add Row button

    - The Gallery items

    - The Delete / Trash can, and

    - The Submit button

     

    You can change any data source names, etc that you don't want to share.

  • CAJ1 Profile Picture
    75 on at

    Add Row Button: 

    Collect(
    colRowUpdates1,
    {
    Quantity: "",
    CostType: "",
    ItemDescription: "",
    ReasonforPurchase: txtReason.Text,
    FullName: txtFullName.Text,
    BusinessUnit: txtBusinessUnit.Text,
    JobNumber: cmbJobNumber.Selected.'JOB #',
    Supplier: cmbSupplier.Selected.Supplier,
    DeliveryAddress: TextInput1.Text,
    DeliveryInstructons: txtDeliveryInstructions.Text,
    CreatorEmail: Label3.Text,
    CostperItem: "",
    TotalLineItem: TextInput6.Text,
    RowNumber: CountRows(colRowUpdates1) + 1
    }
    )

     

    Gallery Items:

    UpdateIf(colRowUpdates1,RowNumber=ThisItem.RowNumber,{CostperItem:TextInput2,TotalLineItem:Qty*TextInput2})

     

    Trash Can

    Remove(colRowUpdates1,ThisItem)

     

    Submit Button:

    Patch(
    'PR Summaries',
    Defaults('PR Summaries'),
    {
    Name: txtFullName.Text,
    'Job Number': cmbJobNumber.Selected.'JOB #',
    Supplier: cmbSupplier.Selected.Supplier,
    ProcurementType: Dropdown1.Selected.Value,
    DeliveryAddress: TextInput1.Text,
    DeliveryInstructions: txtDeliveryInstructions.Text,
    ReasonforPurchase: txtReason.Text,
    DateRequired: DatePicker1.SelectedDate,
    Email: Label3.Text,
    BusinessUnit: Dropdown2.Selected.Value,
    Quote: {
    FileName: First(DataCardValue3_1.Attachments).Name,
    Value: First(DataCardValue3_1.Attachments).Value
    },
    TotalValue: Value(TextInput5.Text)
    }
    );
    ForAll(
    colRowUpdates1,
    Patch(
    'Purchase Requisitions',
    Defaults('Purchase Requisitions'),
    {
    Quantity: Quantity,
    'Business Unit': BusinessUnit,
    Supplier: Supplier,
    'Item Description': ItemDescription,
    'Job Number': JobNumber,
    'Delivery Address': DeliveryAddress,
    'Delivery Instructions': DeliveryInstructons,
    'Full Name': FullName,
    'Cost Type': CostType,
    'Reason for Purchase': ReasonforPurchase,
    CreatorEmail: CreatorEmail,
    'Cost per Item': CostperItem,
    'Procurement Type': Dropdown1.Selected.Value,
    'Date Required': DatePicker1.SelectedDate,
    'Req Summary ID': First(
    Sort(
    'PR Summaries',
    'Summary ID',
    SortOrder.Descending
    )
    ).'Summary ID'
    }
    )
    );
    ClearCollect(
    colRowUpdates1,
    Defaults('Purchase Requisitions');
    Notify(
    "Success",
    NotificationType.Success
    )
    );
    Reset(cmbJobNumber);
    Reset(cmbSupplier);
    Reset(txtDeliveryInstructions);
    Reset(txtReason);
    Reset(TextInput1);
    Reset(Dropdown1);
    Reset(DatePicker1);
    Reset(DataCardValue3_1);
    Reset(Dropdown2);
    Reset(Gallery2);
    Set(varSuccessPopUp,true)

     

     

    Does that help?

  • developerAJ Profile Picture
    4,763 on at

    @CAJ1 

     

    Thanks for the code.

    The reason you are seeing an item in gallery even before you are clicking an add row is because of code on submit button

    ClearCollect(
    colRowUpdates1,
    Defaults('Purchase Requisitions');
    Notify(
    "Success",
    NotificationType.Success
    )
    );

    this will add a row to colrowupdates1. clear this collection. i am not sure exact reason why you are using this. but if you clear this/remove this there won't be rows added to gallery before clicking Add row button.

     

    If you are using that formula for specific reason let me know it, we can try a different workaround for it.

     

    If i am able to fix your issue, please mark my response as Solution😊

    Thank you

    Have a good day

  • CAJ1 Profile Picture
    75 on at

    That is there so that when we have filled in the information and submit the data to a Dataverse table it clears it from that collection.

     

    So, it starts off with the front page and we click the button to “Create New Requisition”, then the page navigates to the purchase req which has been set up like an excel table via a gallery, when you get to the purchase req page there is no line which is how I want it.

     

    CAJ1_2-1684472748418.png

    CAJ1_1-1684472727061.png

    Once we enter all the required information and click submit it takes us back to the front page again, but, if we want to put another requisition in straight after the first one and click the “Create New Requisition” button the page transitions again like normal to the purchase req and there is already a line there. This only happens if we immediately go to create another req after the first and so on.

    CAJ1_3-1684473259902.png

     

  • CAJ1 Profile Picture
    75 on at

    We are not supposed to be able to Add a Row until all of the top information has been filled in, you can see the "Add Row" button is disable but that is how we want it we creating any purchase reqs... does that make sense? 

  • Verified answer
    developerAJ Profile Picture
    4,763 on at

    @CAJ1 

    "That is there so that when we have filled in the information and submit the data to a Dataverse table it clears it from that collection" . 

    if you want to clear the collection use below formula 

    Clear(colRowUpdates1);
    Notify(
    "Success",
    NotificationType.Success
    );

     

    Above formula will clear the collection.

     

    what is happening when you use formula like this.

    ClearCollect(colTest,Defaults(Test)) it add a row to collection with default Values.Please refer the below snip

    developerAJ_0-1684473846262.png

     

    when you use formula like this 

    ClearCollect(colTest,Defaults(Test);Notify("Success",NotificationType.Success))

    developerAJ_1-1684474129668.png

     

    since you are using the formula similar to above pic. When you click on submit it is adding a row to collection thats the reason you are seeing a row in gallery. just hover on colRowUpdates1 and see the values after clicking submit button you will understand it.

     

  • CAJ1 Profile Picture
    75 on at

    Worked perfectly!! Thank you!

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 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard