cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mr_Mather
Level: Powered On

Help patching a lookup to D365

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Mr_Mather
Level: Powered On

Re: Help patching a lookup to D365

@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

View solution in original post

7 REPLIES 7
Dual Super User
Dual Super User

Re: Help patching a lookup to D365

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!
Mr_Mather
Level: Powered On

Re: Help patching a lookup to D365

Hello there 

 

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

 

Lee

Dual Super User
Dual Super User

Re: Help patching a lookup to D365

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!
Highlighted
Mr_Mather
Level: Powered On

Re: Help patching a lookup to D365

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

Dual Super User
Dual Super User

Re: Help patching a lookup to D365

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!

Mr_Mather
Level: Powered On

Re: Help patching a lookup to D365

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

 

Mr_Mather
Level: Powered On

Re: Help patching a lookup to D365

@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

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,978)