cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

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

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

7 REPLIES 7
Community Support
Community Support

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.
Resolver II
Resolver II

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?

 

 

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});

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

Hi, thanks for the help, MS Support Team.

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

Kind regards,

Maurits

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

Regards
Hemant Kumar

Greetings,

 

Would you be able to advise the following patch related function:

How I may patch a Lookup field (with field name as 'Entity1ID') in a CDS entity known as Entity#1 (a child entity) with the value from the primary field known as 'ID' (Auto Number data type) from a second CDS entity known as Entity#2 (a parent entity for one-to-many relationship)? 

 

My goal is to fill in the forms for both Entity#1 and Entity#2 simultaneously in two separate Edit Forms but on the same screen, after user finishes entering the inputs on both forms, use the Select button to let CDS perform the following in sequential order:

(i) Submit Form2 to the parent entity (Entity #2) first --> the CDS will generate the ID (record number) in Entity#2,

(ii) use the Patch function to patch the 'ID' value of the record just created in Entity#2 with Form2.LastSubmit.'ID' to the 'Entity1ID' field in Entity#1 (child entity).

(iii) Submit Form1.

 

Please advise the syntax required for the patch function with an example if possible.

Thanks in advance for your help.

 

Regards,

 

Albert

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (12,858)