cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TGrounds
Level 8

The Proper way to patch an Option Set value using CDS2

Hi Folks - 

 

I have an entitiy that has two lookup fields and an option set field and I'm trying to patch a record when a user logs in (there is an if statement around this patch that determines if a record already exists and updates it rather than creates a new one - but for this question I am isolating the creation of the new record).

 

Here is the code that I'm using - I'm doing lookups for the two lookup fields to get the record values - I know what the default value is that I would like to place in the Option Set field (crcf1_role) and through trial and error I have ended up with the following:

Patch(PowerAppUserPreferencess,Defaults(PowerAppUserPreferencess),
{crcf1_SystemUser:LookUp(Users,fullname=UserName)},
{crcf1_Community:LookUp(Communitys,crcf1_communityname="Azure")},
{crcf1_role:849510001},
{crcf1_lastlogin:Now()})

I looked up the internal value of the crcf1_role value and assigned it directly. - the code doesn't show any errors - is this the correct approach? 

 

I haven't been successful in actully creating the record because I'm getting an error 'Expected dataEntityRecord for navigation column'.  I removed the 'crcf1_role' line and I still receive the error.  So, I'm not able to properly test this but I figured since Option Sets are a standard part of the CDS that there should be a recommended method of Patching- but I haven't been able to find any documentation on it.

1 ACCEPTED SOLUTION

Accepted Solutions
TGrounds
Level 8

Re: The Proper way to patch an Option Set value using CDS2

I realized that I set a default value in the CDS and don't have to pass a value at all.

View solution in original post

1 REPLY 1
TGrounds
Level 8

Re: The Proper way to patch an Option Set value using CDS2

I realized that I set a default value in the CDS and don't have to pass a value at all.

View solution in original post

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,102)