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.
Hope somone can help with this...
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!
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!
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!