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 / A new line is created ...
Power Apps
Answered

A new line is created on each input I don't want

(0) ShareShare
ReportReport
Posted on by 105

Hi,

I created a form, it's like an order form.

The person details are enter at the top of the form and what they want is at the bottom.

The data is stored in two SharePoint lists one for the person details and the other for the order.

The issue is the bottom part I have an order number text input, Date box, Description text box and another text box.

What's happening it's creating a new line just by clicking into each of those input boxes so before they finish the line there are 4 blank lines underneath.

This is my OnSuccess code in Form1:

ForAll(FormCollection, If(!IsBlank(OrderNumber), Patch('Order Jobs', Defaults('Order Jobs'), {'UR Number': OrderNumber, 'Date': DateValue(Date), Description: Description, 'ItemNumber': ItemNumber, MasterID: Form1.LastSubmit.ID})))

I have a save button at the end of the line which is when I would like the extra line created and this is the OnSelect code:
Patch(FormCollection, ThisItem, {OrderNumber: OrderInput.Text, Date:DateInput.SelectedDate, Description:DescriptionInput.Text, ItemNumber:ItemInput.Text, ShowSaveButtons:false}); If(EditPressed, false, Collect(FormCollection, {OrderNumber:"", Date:("dd/mm/yyyy") , Description:"", ItemNumber:"", ShowSaveButtons:true})); UpdateContext({EditPressed: false}); Set(NeedsSaved, false).
I also have a delete button to remove the entry.
Thanks for your help

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,570 Most Valuable Professional on at

    Hi @Markxx60 ,

    Before I get into what I think is the issue, your Patch can be far more efficient with

    Patch(
     'Order Jobs',
     ForAll(
     Filter(
     FormCollection, 
     !IsBlank(OrderNumber)
     ) As aCol, 
     {
     'UR Number': aCol.OrderNumber, 
     Date: aCol.DateValue(Date), 
     Description: aCol.Description, 
     ItemNumber: aCol.ItemNumber, 
     MasterID: Self.LastSubmit.ID
     }
     )
    )

    Also the rest of the code I am a little confused whether it runs on EditPressed true or false, but assuming true

    Patch(
     FormCollection, 
     ThisItem, 
     {
     OrderNumber: OrderInput.Text, 
     Date: DateInput.SelectedDate, 
     Description: DescriptionInput.Text, 
     ItemNumber: ItemInput.Text, 
     ShowSaveButtons: false
     }
    ); 
    If(
     EditPressed, 
     Collect(
     FormCollection, 
     {
     OrderNumber: "", 
     Date: Blank(), 
     Description: "", 
     ItemNumber: "", 
     ShowSaveButtons: true
     }
     )
    ); 
    UpdateContext({EditPressed: false}); 
    Set(NeedsSaved, false).

    but the real issue seems to be the four controls - you need to remove anything that is there on OnChange or OnSelect.\ and see if that fixes it.

     

    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

  • Markxx60 Profile Picture
    105 on at

    Hi Warren,

    Thank you for your time. Here's a screen shot of what the form looks like.

    Markxx60_0-1687988474471.png

    The top part is just some text inputs and the lower part is a gallery every single key press or mouse in those boxes creates a new line entry underneath so by the time they fill out the one line there can be dozens of blank rows underneath. Sorry for the delayed response I was off yesterday.

    I tried your code above but it still creates the extra row.

    Regards

  • WarrenBelz Profile Picture
    156,570 Most Valuable Professional on at

    Hi @Markxx60 ,

    There has to be something else running here - as I mentioned, check OnSelect and OnChange of everything in the gallery.

  • Markxx60 Profile Picture
    105 on at

    Hi Warren,

    I think I've gone and stuff some other parts of the form in trying to fix it.
    I think at this stage I might rebuild it from scratch as since I've had it running there has been no more than 4 entries in the gallery so I think I can forget the adding of a row to simplify things.

    I do appreciate you taking the time to help but it is a simple form and the quick way now would be to redo it and give it a face lift.

    Thank you very much.

    Do I leave it here or mark it Accept as Solution.

    Regards

  • WarrenBelz Profile Picture
    156,570 Most Valuable Professional on at

    @Markxx60 ,

    I can accept it for you - this helps future users find it more easily.

  • DawnT Profile Picture
    6 on at

    I have a similar form, but I was able to determine (after testing by bringing in one field at a time) it was the "People" column in the gallery that was giving me issues.  I tried rebuilding it, by adding the item manually, copying it from a form on a different screen, and any other way I could think of.  I know this is strange, but I recreated the list on SharePoint from the "Work Progress Tracker" template and I no longer have this issue.  It does not make sense but it is working.  Now if I can just figure out why it will not save a date when it is selected from the dropdown calendar without having to click back into the date field in the gallery I will be golden. 

     

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard