web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : 9lFG3vTn8tJtf83Y7HdJKS
Power Apps - Microsoft Dataverse
Answered

How to save data into lookup column dataverse through powerapps

Like (0) ShareShare
ReportReport
Posted on 25 Jul 2023 21:12:11 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 

 

 

Categories:
I have the same question (0)
  • Mahendar Pal Profile Picture
    191 on 26 Jul 2023 at 04:47:43
    Re: How to save data into lookup column dataverse through powerapps

    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 26 Jul 2023 at 19:09:44
    Re: How to save data into lookup column dataverse through powerapps

    @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,637 Moderator on 27 Jul 2023 at 02:09:13
    Re: How to save data into lookup column dataverse through powerapps

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 714 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 419 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 243

Last 30 days Overall leaderboard

Featured topics

Loading complete