cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver II
Resolver II

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

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

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
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (7,345)