Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

insert data into another table

(0) ShareShare
ReportReport
Posted on by 24

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!

  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,475 on at
    Re: insert data into another table

    @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.

     

  • vish3027 Profile Picture
    vish3027 434 on at
    Re: insert data into another table

    @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.

  • jacob_ Profile Picture
    jacob_ 24 on at
    Re: insert data into another table

    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

  • WarrenBelz Profile Picture
    WarrenBelz 145,475 on at
    Re: insert data into another table

    @jacob_ ,

    That is what I thought - wat code have you attempted on this - please post in Text.

  • jacob_ Profile Picture
    jacob_ 24 on at
    Re: insert data into another table

    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.   

  • WarrenBelz Profile Picture
    WarrenBelz 145,475 on at
    Re: insert data into another 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?

  • jacob_ Profile Picture
    jacob_ 24 on at
    Re: insert data into another table

    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!

  • WarrenBelz Profile Picture
    WarrenBelz 145,475 on at
    Re: insert data into another table

    @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.

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard