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 / Check if item exists i...
Power Apps
Unanswered

Check if item exists in datasource and append otherwise create a new row

(0) ShareShare
ReportReport
Posted on by

Hi there,

 

I'm building a simple app which just puts data into an excel sheet.

At first you have to scan the order-number, which is also the primary identifier, and then scan all corresponding serialnumbers in a second inputfield. After that there's a button which submits the form and saves the values into an excel sheet in sharepoint.

That's working fine so far.

 

But now there's the problem that, if someone forgets serial numbers or just picket up less parts then needed, and then try to scan a second time, there is an error message, because the order number already exists in the sheet.

 

I've seen many topics about that, but I didn't found one which appends the data of the second scan to the first one. It is mostly everytime replaced through the Patch function. But I need to check if the order number already exists and then append the serial numbers to the already existing values, or, if the order number doesn't exists, add a new row.

It would be fine if this works without any user interaction, the workaround I was thinking about was kind of a landing page where you put in the order number and then get redirected to an edit form oder a new form to submit your serialnumbers, but I want it as one page so this isn't really a propriate solution....

 

Here's a screenshot of the actual App for better understanding.

screenshot.PNG

 

Hope somone can help with this...

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Anonymous,

     

    That is very much possible without user interaction, but will require some rework on the OnSelect of your button. Currently, I am guessing that the button will just have a Patch function or a submitform.

     

    I don't know the structure of your datasource so I will provide a general architecture and mark the fields that need to be replaced:

    //Please replace all references to tableName, Columnauftragsnummer, ColumnSeriennummern and TextInput.Text to the correct names
    //TextInput.Text refers to the Auftragsnummer text control
    With(
     {
     wLookUpRecord: LookUp(
     tableName,
     //Should it be a Form control, reference the DataCardValue.Text below 
     ColumnAuftragsnummer = TextInputAuftragsnummer.Text
     )
     },
     If(
     //If record does not exist, create a new one
     IsBlank(wLookUpRecord),
     //Should you use a form, replace this Patch with your SubmitForm function
     //Otherwise replace this with your current Patch function
     Patch(
     tableName,
     Defaults(tableName),
     {
     ColumnAuftragsnummer: TextInput.Text
     }
     ),
     //Don't replace this Patch() - this will update your record
     Patch(
     tableName,
     wLookUpRecord,
     //Should you use a multiline text field
     //You could also separate the append with a new line break: & Char(13) & TextInput.Text
     {ColumnSeriennummern: wLookUpRecord.ColumnSeriennummern & TextInputSeriennummern.Text}
     )
     )
    )

     

    Should you use the European coding syntax, please replace my commas in the code above with semicolons.

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Community Power Platform Member Profile Picture
    on at

    Hi @LaurensM ,

    thank you for your reply.

     

    The serialnumber (Seriennummer) field is a multiline text field, but I don't understand how to alter the code of the second Patch function mentioned in the comment. Could you please tell me how to do it?

     

    Thank you!

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Anonymous,

     

    The last patch would look as follows:

    Patch(
     tableName,
     wLookUpRecord,
     {ColumnSeriennummern: wLookUpRecord.ColumnSeriennummern & Char(13) & TextInputSeriennummern.Text}
    )

    You will have to change the TextInput & tablename to the correct names.

     

    I hope this helps!

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