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 / Patch doesnt work on L...
Power Apps
Answered

Patch doesnt work on Lookup column

(0) ShareShare
ReportReport
Posted on by 85

Can anyone tell me why the following code doesnt work?  

 

  • I have a lookup column in SharePoint Called CaseNo
  • I am simply trying to patch the number 184299 into a new record
  • The code runs without error, but there is no data placed in the new records lookup field

 

Patch(
SDF_Schedule,
Defaults(SDF_Schedule),
{CaseNo:
{Id: 184299,
Value: 184299,
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},Title:184299
}
)

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

    @Larry_Casey 
    My 1st idea is: can you please try patching without Title?  I don't believe Title is available in a LookUp column.

    Patch(
    SDF_Schedule,
    Defaults(SDF_Schedule),
    {CaseNo:
     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"}
     Id: 184299,
     Value: 184299
     }
    })

     

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

  • lcasey233 Profile Picture
    85 on at

    Hello,

     

    Title is a required field in the list. I removed teh requirement for Title and the code does nothing.  It does not update the Lookup field.

     

    I used your exact code and nothing gets inserted to the table.  What could be causing this? 

     

    Patch(
    SDF_Schedule,
    Defaults(SDF_Schedule),
    {CaseNo:
     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"}
     Id: 184299,
     Value: 184299
     }
    })

     

     

  • lcasey233 Profile Picture
    85 on at

    This must be another Power BI outage!!  Man, I wish MS could keep these things running properly. There is no reason why this code shouldn't work.

  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Larry_Casey 

     

    Can you try to update the expression to:
     
    Patch(
    SDF_Schedule,
    Defaults(SDF_Schedule),
    {CaseNo: LookUp(Choices(SDF_Schedule.CaseNo),ID = 184299)}
    )
     
    Also. if the title field is still marked as required, then the formula should be:
    Patch(
    SDF_Schedule,
    Defaults(SDF_Schedule),
    {
    Title: "Value for Title Column",
    CaseNo: LookUp(Choices(SDF_Schedule.CaseNo),Id = 184299)}
    )
     
    If 184299 is the value of the lookup record then you should use Value instead of Id.
     
    Hope this Helps!

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
  • lcasey233 Profile Picture
    85 on at

    None of this works,  Nothing at all gets inserted. I removed the Title requirement and even then it just doesnt work. 

     

    This is really annoying as this should be as simple as 123

  • lcasey233 Profile Picture
    85 on at

    Ok , 

     

    here is what worked, I needed to use value = rather than ID =.

     

    But I still dont understand why Microsoft puts out wrong information. No where in their documentation do they tell you to patch using Lookup. Thanks so much for the help though, You must be a really advanced programmer!

     

    Patch(
    SDF_Schedule,
    Defaults(SDF_Schedule),
    {CaseNo: LookUp(Choices(SDF_Schedule.CaseNo),Value = TextInput2.Text)}
    )

  • mdevaney Profile Picture
    29,989 Moderator on at

    @Larry_Casey 
    I'm glad you were able to find the answer.  My code was tested in a basic proof of concept app so I'm not sure why it did not work on your end, but ultimately, I'm just happy you found the answer.

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Larry_Casey 

     

    Glad that you were able to resolved. Not an advanced programmer as such. Just some good practice on the Power Platform 🙂

     

    Hope this Helps!

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • lcasey233 Profile Picture
    85 on at

    But the code you gave me is not referenced anywhere on the web. This is the very first web page in the entire world that you provided code that works , but is not documented anywhere.

     

    Its like there is some sort of secret society  with special privledges to information that is not given to the general public.

     

    Everywhere and everyone in the entire world has advised to Use :

    '@odata.type':"#Microsoft.Azure.Connectors.Sharepoint.SPListExpandedReference"

     

    But you provided a whole new method and so you must be super , super advanced or have access to information others dont.

     

    I really truly appreciate the help. Its just so mind boggling why Power Apps requires so much "Secret" knowledge to use.  

  • alrezac Profile Picture
    on at

    Hi,

     

    It looks like you got your issue resolved on patch functions. I just wanted to add in here with a little bit more information if you would like to learn more about them.

     

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

     

    Regards,

     

    Alex

     

    -------

     

    Community Support Team _ Alex Rezac
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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