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

Set CRM Dynamics Lookup data type error

Hello dear community,

 

I have some trouble to get something relatively basic working. I want to insert in D365 CRM a new record in a custom entity, setting 2 fields : a lookup (related ID) and an optionset value hardcoded (10000001).

 

Here is how first I get the info needed :

Collect(MyCollection;{
Var1: MyFunction();
ContactId: Search(
'CustomContact';
MyFunction();
"cc_customcontactid")})

 

And here is how I'm trying to patch

 

Patch('Check-ins';Defaults('Check-ins');{
cc_MyLookupId:MyCollection.cc_customcontactid;
cc_customtype:Value("10000001")})

 

I'm getting the error (in french): The type of this argument "cc_MyLookupId" does not match the expected "Record". Type found "Table".

I tried to find some info on google but with no results. Thanks for your advices.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Set CRM Dynamics Lookup data type error

Hi @Digit89,

I don't agree with the formula that you provided.

If there is Lookup column called cc_Contact within your 'Check-ins' entity, when you want to use this column within a PowerApps app, it would not be shown up as cc_Contact. Instead, this column would be separated into cc_Contact_type property and cc_Contact_value property.

I have made a test on my side, there is a Lookup column called countryname wihtin my Dynamics 365 entity, when I reference this column within my app, it would be separated into _new_countryname_value and _new_countryname_type:6.JPG

 

So if you want to provide a value for the Lookup column within the Patch function that you mentioned, please modify your formula as below:

 

Patch(
'Check-ins';
Defaults('Check-ins'); { cc_Contact_value:'6c118935-xxxx-e811-xxxx-70106fa93fc1' }
)

or

Patch(
'Check-ins';
Defaults('Check-ins'); { _new_cc_Contact_value:'6c118935-xxxx-e811-xxxx-70106fa93fc1' }
)

Note: The '6c118935-xxxx-e811-xxxx-70106fa93fc1' represents the primary GUID of the entity the Lookup column (cc_Contact) reference values from.

 

Best regards,

Kris

 

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

View solution in original post

5 REPLIES 5
Community Support Team
Community Support Team

Re: Set CRM Dynamics Lookup data type error

Hi @Digit89,

 

Could you please show more details about the error message within your app?

Could you please share a  bit more about the MyFunction() that you mentioned?

 

The error message told that the cc_MyLookupId column within your "Check-ins" custom entity is required to provide a record value, the formula MyCollection.cc_customcontactid return a table value.

 

I think there is something wrong with the formula that you provided, and I assume that you want to filter only one record (unique one record) using the Search function. I have made a test, please take a try with the following workaround:

 

Modify your Patch function as below:

Patch(
'Check-ins';
Defaults('Check-ins');
{ cc_MyLookupId:First(MyCollection.cc_customcontactid); cc_customtype:Value("10000001")
}
)

or

Patch(
   'Check-ins';
    Defaults('Check-ins');
    {
     cc_MyLookupId:First(MyCollection.ContactId.cc_customcontactid);
     cc_customtype:Value("10000001")
    }
)

 

More detaisl about the First function, Search function in PowerApps, please check the following article:

First function

Search function

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Digit89
Level: Powered On

Re: Set CRM Dynamics Lookup data type error

Dear Kris,

 

Thanks for your answer. In all my tests I tried to wrap the code into a FORALL(), to patch all records of my collection, with no success.

 

Also, in the function reference, it's explicitly written here that you can give a table as argument:

Patch( DataSource, BaseRecordsTable, ChangeRecordTable1, [, ChangeRecordTable2, … ] )

 

That's why I was confused. I'm still not understanding how you can push i.e. a collection of 10 records by clicking 1 button. You are wring thinkning I want to push only 1 record, I want to push ALL the records that are inside my collection.

Digit89
Level: Powered On

Re: Set CRM Dynamics Lookup data type error

It's me again. This topic shouldn't be marked as resolved.

 

Now I think I understood something, when it says the type should be a Record, I think it waits something like :

 

Patch('Check-ins';Defaults('Check-ins');
{
    cc_Contact:
    {
        Value:ccontact_value;
        Id:ccontact_id
    };
}

The problem is there is absolutely no sample on the net nor references about that.

Community Support Team
Community Support Team

Re: Set CRM Dynamics Lookup data type error

Hi @Digit89,

I don't agree with the formula that you provided.

If there is Lookup column called cc_Contact within your 'Check-ins' entity, when you want to use this column within a PowerApps app, it would not be shown up as cc_Contact. Instead, this column would be separated into cc_Contact_type property and cc_Contact_value property.

I have made a test on my side, there is a Lookup column called countryname wihtin my Dynamics 365 entity, when I reference this column within my app, it would be separated into _new_countryname_value and _new_countryname_type:6.JPG

 

So if you want to provide a value for the Lookup column within the Patch function that you mentioned, please modify your formula as below:

 

Patch(
'Check-ins';
Defaults('Check-ins'); { cc_Contact_value:'6c118935-xxxx-e811-xxxx-70106fa93fc1' }
)

or

Patch(
'Check-ins';
Defaults('Check-ins'); { _new_cc_Contact_value:'6c118935-xxxx-e811-xxxx-70106fa93fc1' }
)

Note: The '6c118935-xxxx-e811-xxxx-70106fa93fc1' represents the primary GUID of the entity the Lookup column (cc_Contact) reference values from.

 

Best regards,

Kris

 

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

View solution in original post

Digit89
Level: Powered On

Re: Set CRM Dynamics Lookup data type error

Kris,

That's it. Finally got it working. I'm sure this post will help other members of the community.

Thank you !

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
Users Online
Currently online: 328 members 5,601 guests
Recent signins:
Please welcome our newest community members: