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 / Help patching a lookup...
Power Apps
Answered

Help patching a lookup to D365

(0) ShareShare
ReportReport
Posted on by 46

Hello All

I am so close to finishing out a project, and would appreaciate a little help.

 

I have a lookup field, which references a Gallery of all Campaigns in D365, this is called Campaign_BCR

 

LookUp(Campaigns,name=BrowseGallery3_1.Selected.name,name)

 

I also have a Patch function which looks to patch the First Name, Last Name and Campaign I have chosen to the Lead entity, which works fine if it is just First Name and Last Name, but when I look to Patch the Campaign to the Lead I get an error

 

 

Patch(Leads,Defaults(Leads),{firstname:FirstName_BCR.Text,lastname:LastName_BCR.Text,campaignid:Campaign_BCR.Selected.campaignid})

 

To confirm the schema of the lookup field on the lead to the campaign is campaignid

 

Here is the error message I am getting.

 

 

The type of this argument campaginid does not match the expected record type 'Record'

 

Any and all advice greatfully recieved.

 

Thanks in advance

Lee

 

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Mr_Mather 

     

    Can you try to update your expression as:
    Patch(Leads,Defaults(Leads),{firstname:FirstName_BCR.Text,lastname:LastName_BCR.Text,campaignid:Campaign_BCR.Selected})
     
    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!
  • Mavver Profile Picture
    46 on at

    Hello there 

     

    Unfortunatley that did not work, I get the same error message

     

    Lee

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

    Hi @Mr_Mather 

     

    Can you please confirm what is Campaign_BCR , is it the name of Gallery control? Based on other expression, your gallery name corresponds to BrowseGallery3_1, if so then you need to update your expression as:
    Patch(Leads,Defaults(Leads),{firstname:FirstName_BCR.Text,lastname:LastName_BCR.Text,campaignid:BrowseGallery3_1.Selected})
     
    Here, the lookup need to be passed through the gallery selected item, so the name of gallery need to be passed.
     
    If this differs, can you please confirm few functional details about the app configuration:
    1) How did you created the connection to this entity, through Dynamics365 connector or Common Data Service connector?
    2) Does Leads has a lookup field to Campaign?
     
    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!
  • Mavver Profile Picture
    46 on at

    Campign_BCR is a lookup field that references the Gallery, which I have renamed for clarity to be CampaignGallery

     

     

    LookUp(Campaigns,name=CampaignGallery.Selected.name,name)

     

    So I changed the Patch to reference the gallery instead

     

     

    Patch(Leads,Defaults(Leads),{firstname:FirstName_BCR.Text,lastname:LastName_BCR.Text,campaignid:CampaignGallery.Selected})

     

    And I got a new error this time

     

    The requested operation is invalid. Server Response: A value must be provided for item

     

    I am using the Dynamics connector not the Common Data Service connection

     

    Thanks for all the help so far

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

    Hey @Mr_Mather 

     

    I am assuming that the gallery control in your app has the items property set to "Campaigns" entity (One that is used in the Lookup field of Leads Entity)
     
    Now, you need to use the expression as:
     
    Patch(testbs,Defaults(testbs),{Name:"test",testa:Gallery1.Selected.testa})
     
    Here, I have used the scenario for two entities, testa and test b, testa is created as a lookup field in testb and the name of the lookup atrribute is "testa". This works fine for me.
     
    Explanation:
    testa:Gallery1.Selected.testa
     
    testa -> Name of the Lookup field in testb entity
     
    Gallery1 -> Name of Gallery control
     
    testa -> to get the GUID of the testa, for this you need to pass the attribute in campaign which holds the guid, mostly it will be campaign.

     

    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!

  • Mavver Profile Picture
    46 on at

    Firstly, thanks ever so much for the time you are taking on this.

     

    To answer your questions - 

     

    Here are my data sets, there are two environments I am looking at, a Development and a Staging.  The Staging environment has the _1 at the end of the name and it is this environment I am currently pointing everything to.

    DataSources.png

     

    Yes, I am pointing the Gallery Control to the Campaigns_1 table in the staging environment.  The Gallery is called CampaignGallery.

     

    SortByColumns(Search(Campaigns_1, CampaignSearch_CS.Text,"name"), "name", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

     

    The following is my patch lines

     

     

    Patch(
     Leads_1,
     Defaults(Leads_1),
     {
     subject: "Tradeshow App Generated",
     firstname: FirstName_BCR.Text,
     lastname: LastName_BCR.Text,
     campaign_1: CampaignGallery.Selected.campaign_1
     }
    )

    With this I get the error that Campaign_1 is not a field in the table, so I change it to the following

     

     

     

    campaignid: CampaignGallery.Selected.campaign_1

    campaignid is the schema name for the lookup column in the Leads_1 table, however when I change it to this I get the following error

     

     

     

    The type of argument 'campaignid' does not match the expected type 'Record'. Found type 'Error'.

    I get a different error when I link it to Campainid at the end

     

     

    campaignid: CampaignGallery.Selected.campaignid

    here i get the error

     

    The type of argument 'campaignid' does not match the expected type 'Record'. Found type 'Guid'.

    so I assuming that whatever is at the end of that line needs to be the type of record.

    here is the solution line for the campaign lookup on the lead entity

    entity.png

     

  • Verified answer
    Mavver Profile Picture
    46 on at

    @yashag2255 

     

    Thanks for taking the time, I managed to solve it in the end and got it working using the following, I have no idea what the difference is, but this worked for me patching a lookup

     

    _campaignid_value: CampaignGallery.Selected.campaignid

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard