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 / How to save data into ...
Power Apps
Answered

How to save data into lookup column dataverse through powerapps

(0) ShareShare
ReportReport
Posted on by 59

Hi All,

I built two tables in dataverse. One is Surplus table that has different column such as department, date, location and ID(which is autonumber -data type). its linked to the second surplus data which has IDSurplus(lookup column), description of items , quantity and others.

 

I built an app and want to get to save the information into the two tables . How can i pass the ID (autogenerated number ) from surplus table into surplus data IDsurplus column which is a lookup..

 

Thank you in advance 

 

 

I have the same question (0)
  • Mahendar Pal Profile Picture
    191 on at

    Hi,

     

    You should be able to set lookup field in your patch like below

     

    {lookupfieldname:LookUp(yoursurplustablename,ID=valueofid)}

     

    You can try to look here: https://devoworx.net/powerapps-lookup-function-examples-complete-tutorial/

  • MAM627646 Profile Picture
    59 on at

    @Mahender thank you for your prompt response. My code is as follow

    Patch(
    'Surplus tables',Defaults('Surplus tables'),
    {Department:TxtDepart.Text,
    Division:Txtdivision.Text,
    Community:TxtCommunity.Text,
    Date:Dateapps.SelectedDate,
    Location:TxtLocation.Text,
    'Orginator ':TxtOrginator.Text,
    'Reason for Declaration ':TextReasonforDeclaration.Text
    }
    );


    ForAll(surpluscollection,Patch('Surplus Data',Defaults('Surplus Data'),
    { 'Item No.':TxtItemNo1,
    Quantity:TxtQuantity1,
    'Description of Items':Txtdescription1,
    'Serial Number':TxtSerial1,
    'ID Surplus':

    }
    )
    )

    So the ID in Surplus table is auto-increment by dataverse. I am trying to patch the information to first table to generate the auto generated number but lacking how to insert /connect it to the IDSurplus in the second table which is a lookup. 
    Thanks much

  • Verified answer
    Mitanshu Profile Picture
    1,650 Moderator on at

    I am going to contribute below the concept that should solve your problem and all such scenarios. You will have to adapt to your specific situation.

     

    LookUp column type in Dataverse expects a Record value and not a Text or AutoNumber value.

     

    When you Patch the ParentTable ('Surplus tables'), it will return you the Record information that you can store as a variable to be used later for the ChildTable ('Surplus Data')

     

    Set(
     latestRecord,
     Patch(
     'ParentTable',
     Defaults('ParentTable'),
     { Department: txtDepartment.Text, ... ,... }
     )
    )

     

     

    Now, when  you are doing Patch for your ChildTable ('Surplus Data'), follow the concept below:

     

    ForAll(
     surpluscollection,
     Patch(
     'ChildTable',
     Defaults('ChildTable'),
     { 'Item No.':TxtItemNo1, 'ID Surplus': latestRecord, ... , ... }
     )
    )

     

     

    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 this post or my previous reply 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

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard