hello guys,
I am trying to realize below scenario:
User has a list of items from one table, the main goal is to give him a possibility to approve selected item. Approval is equivalent to execution insert a record to another table. If one item was already approved then there should not be possibility to execute another insert for this item, so we also need to check somehow is there already existing row for selected item.
how it could be handled in power apps?
Thank you in advance for any help!
@jacob_ ,
I cannot start writing accurate code without knowing at least your values (list and field names). I am happy to guide you through the process and the syntax required - I will give you a pattern, but need you to have a attempt to put values in it. To check for existing record and then Patch
If(
IsBlank(
LookUp(
YourTargetList,
YourReferenceField = ValueYouAreChecking
).AnyFieldNameInList
),
Patch(
YourTargetList,
Defaults(
YourTargetList,
{
Field1:YourValue1,
Field2:YourValue2,
. . . . .
}
)
)
)
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.
@Anonymous
What are other possible statuses other than Approved and what happened on those statuses.
You need atleast one column common in both places. Here you can use Item ID your parent list and have RefID column in another table and on Patch you can update this column as well.
Now, before inserting record in another table
You can check LookUp(anotherlist, RefID=curritemID && Status="approved") if this returns record then dont insert else insert record.
Please try this and let me know if this works for you.
to be honest I don't have any working code because I do not know how to approach this. I am looking for some guidance or even confirmation if it is possible
thanks again and best regards
@jacob_ ,
That is what I thought - wat code have you attempted on this - please post in Text.
yes, something like that. If there is matching record for selected item from first table in second table display "status: approved" if not then show button which will insert record with associated attributes for selected item from first table to the second table.
Hi @jacob_ ,
Can you please explain in a bit more detail what you are trying to do here. As long as the item displayed has a "matching" field with the second data source, you can check if the matching record is there and if not create one?
hello Warren, thank you for your reply.
I know both functions, but as I wrote I want to display data from one data source and based on selected item I need to execute insert into another table.. I don't think It is possible from one gallery where I display data or am I wrong?
best regards!
@jacob_ ,
Fairly broad question, but you would use the Patch() statement, but first use LookUp to check if a record exists.
Happy to help with reviewing your code after you have posted 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.