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

Unable to set the lookup field value using Patch/UpdateIf in CDS

Hi all,

I am facing a strange issue today, the patch is unable to set the lookup field value. It was working until yesterday.


1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Unable to set the lookup field value using Patch/UpdateIf in CDS

Hi @hemantkumar ,

Currently, the issue has been fixed.

 

I have made a test on my side, the Patch function could patch data to the LookUp column in your CDS Entity. Please consider take a try with the Patch function again within your app, check if the issue is solved.

 

If the issue still exists, please consider re-create an app based on your CDS Entity, then try the Patch function again, check if the issue has been fixed.

 

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

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

6 REPLIES 6
Highlighted
Community Support Team
Community Support Team

Re: Unable to set the lookup field value using Patch/UpdateIf in CDS

Hi @hemantkumar ,

Could you please share a bit more about your issue?

Do you want to set a LookUp field value within your CDS Entity using Patch function? Could you please share a bit more about it?

 

Based on the needs that you mentioned, I have made a test on my side, and don't have the issue that you mentioned. Please take a try with the following workaround:6.JPG

 

7.JPG

Set the Items property of the ComboBox  (ComboBox1) to follownig:

Choices(Tasks.crba2_TaskLists_Task)  /* <-- TaskLists is the LookUp column in my Tasks Entity */

On your side, you should type:

Choices('YourEntity'.LookUpColumn)

Set the OnSelect property of the "Patch" button to following:

Patch(Tasks, First(Tasks),{TaskLists: ComboBox1.Selected})

If you want to add a new value to your CDS Entity, please take a try with the following formula:

Patch(
'YourEntity',
Defaults('YourEntity'),
{LookUpColumn: ComboBox1.Selected}
)

Please also check and see if the following thread would help in your scenario:

https://powerusers.microsoft.com/t5/Creating-Apps/Dynamics-365-Look-up-field-update/m-p/198429?autho...

 

If the issue still exists, I think it may be related to Common Data Service server. Please consider submit an assisted support ticket for help through the following link:

https://powerapps.microsoft.com/en-us/support/pro

 

Best regards,

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.
Maurits
Level 8

Re: Unable to set the lookup field value using Patch/UpdateIf in CDS

Hi, I have the same issue over here, but never did it before, so don't know if it worked before as expected.
I have two custom entities, O and M, with a One-to-Many relation defined to it.
I add one row from a collection to  entity O .
After that I add one or more rows from another collection to entity M and try to fill the lookup field with a reference to the record in entity O. With no luck.

Tried lots of way to do that. The most logic way (using the LookUp function in the Patch statement of the child records), does not raise an error, but still the field remains empty.

This LookUp function retreives the correct record, I've checked that by saving some field from the O record in a text field of the child records in the same Patch function.


BTW I have activated the "Relational data" preview function, maybe that's the cause of this behavior?

 

 

hemantkumar
Level: Powered On

Re: Unable to set the lookup field value using Patch/UpdateIf in CDS

Thanks, @v-xida-msft for the detailed information.

It was working as expected previously but now it doesn't work. (not sure why it may be because of any updates)
But It updates the other fields.

1)Code:

UpdateContext({currentUser:LookUp(
Users,
'Primary Email' = "hemant@xyy.com"
)});
//Users variable always has data

Patch(
'Test Entities',
Defaults('Test Entities'),
{ Name:TextInput1.Text,
User: currentUser
}
);

2)Code:
Set(account,First(Accounts));
Patch(Contacts, Defaults(Contacts),{'Last Name': TextInput1.Text,Account: account});

Community Support Team
Community Support Team

Re: Unable to set the lookup field value using Patch/UpdateIf in CDS

Hi @hemantkumar ,

Currently, the issue has been fixed.

 

I have made a test on my side, the Patch function could patch data to the LookUp column in your CDS Entity. Please consider take a try with the Patch function again within your app, check if the issue is solved.

 

If the issue still exists, please consider re-create an app based on your CDS Entity, then try the Patch function again, check if the issue has been fixed.

 

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

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

Maurits
Level 8

Re: Unable to set the lookup field value using Patch/UpdateIf in CDS

Hi, thanks for the help, MS Support Team.

In my case it is solved indeed and workes as expected!

Kind regards,

Maurits

hemantkumar
Level: Powered On

Re: Unable to set the lookup field value using Patch/UpdateIf in CDS

Thanks @v-xida-msft , Now it's working as expected.

Regards
Hemant Kumar

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,958)