cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TGrounds
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
TGrounds
Resolver II
Resolver II

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

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (92,221)