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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do you patching a ...
Power Apps
Unanswered

How do you patching a Lookup column with values from a text column in the same List?

(0) ShareShare
ReportReport
Posted on by 64

I have a list called TestList that has two columns, Title (single-line text) and CustName (Lookup). The Title field is already filled with customer names. However, the CustName column is empty. I want to be able to copy the values from the Title column to the CustName column. How do I do this? Thanks. 

 

testlist.png

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @MrClick 

    You can copy the text from Title to CustName in all rows with a single line of code.

    UpdateIf(TestList, true, {CustName: Title})

     

    Or you can do it for a specific row if you know the ID number.

    Set(varLookupRecord, LookUp(TestList, ID=1));
    Patch(TestList, varLookUpRecord, {CustName: varLookUpRecord.Title});

     

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • MrClick Profile Picture
    64 on at

    Thanks for the help @mdevaney  Unfortunately, it did not work. I had to take a photo of the error instead of the screenshot. Where did I go wrong? Do not forget that CustName is a Lookup column. 

    20200822_135322.jpg

    Also, would this line below do it for all the records in the list? Ideally, I want all empty CustName to be filled with the value of the Title column. I could have done it manually, and saved myself hours of figuring out, but I just think it would be a failure for me. 🙂

    UpdateIf(TestList, true, {CustName: Title})

     

  • mdevaney Profile Picture
    29,991 Moderator on at

    @MrClick 
    Oh, it's a lookup column?  Can you please provide more info in that case?  I need to see the other list that stores your lookup column to provide an answer.

    Once you do this I can replicate it on my side and give you some code to try.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • MrClick Profile Picture
    64 on at

    @mdevaney 

    - Ok. so, the TestList has two columns, one called Title (single-line text)  and the other called CustName which is a Lookup column from a table called CustName.

    - The other List is called CustName and has only one column called Title (single-line text) used to store the name of the customers. 

    Needless to say, those two lists are created to test what I want to do with the real Lists.

     

    I hope the screenshot below helps. It is from the TestList CustName column. Thank you once again.

    MrClick_0-1598104978442.png

     

  • mdevaney Profile Picture
    29,991 Moderator on at

    @MrClick 
    I'm having some trouble.  I thought this would have worked but I'm getting an error similar to this thread:
    https://powerusers.microsoft.com/t5/Building-Power-Apps/Fetching-items-failed-Possible-invalid-string-in-filter-query/td-p/619241

     

    With(
     {wBlankRecords: Filter(TestList, CustName.Value=Blank())},
     ForAll(wBlankRecords As BlankRecord,
     Patch(TestList,
     BlankRecord,
     {
     CustName: {
     '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: LookUp(CustName, Title=BlankRecord.Title, ID),
     Value: BlankRecord.Title
     }
     }
     )
     )
    )

     

  • MrClick Profile Picture
    64 on at

    Thanks @mdevaney for trying. 

     

    I never knew something a simple as copy the value of one text column to another column from the same list could be that difficult. 

     

    I will try to use my common programming knowledge to figure out a solution. 

     

    Thanks. 

     

     

  • WarrenBelz Profile Picture
    155,427 Most Valuable Professional on at

    Just another suggestion to expand on @mdevaney 's considerable effort

    With(
     {
     wBlankRecords: 
     Filter(
     TestList, 
     CustName.Value=Blank()
     )
     },
     ForAll(
     wBlankRecords As BlankRecord,
     Patch(
     TestList,
     {ID:BlankRecord.ID}, //changed here
     {
     CustName: 
     {
     '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: 
     LookUp(
     CustName, 
     Title=BlankRecord.Title
     ).ID, //changed here
     Value: BlankRecord.Title
     }
     }
     )
     )
    )

     

  • MrClick Profile Picture
    64 on at

    Thanks, @WarrenBelz.

     

    I am having some errors when I try to patch. Will try to figure out and update. Thanks again.

     

     

     

  • WarrenBelz Profile Picture
    155,427 Most Valuable Professional on at

    @MrClick ,

    Put @mdevaney 's ID code at the bottom back the way it was. You really need to only change your existing code in the area

    {ID:BlankRecord.ID},

    instead of 

    BlankRecord,

    this is only a suggestion as I would have thought the original would have worked, but put a couple of variations in.

    The easy solution is get rid of the Lookup field and do the same Lookup in Power Apps instead.

  • MrClick Profile Picture
    64 on at

    Hi @WarrenBelz 

     

    What do you mean by this?

    "The easy solution is to get rid of the Lookup field and do the same Lookup in Power Apps instead."

     

    The Lookup field was done using Power Apps.

     

    Thanks. 

     

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 839

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 412

Last 30 days Overall leaderboard