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

When patching a record, Optionset failed to find OptionsetValue in the Power Fx formula

In my Appointment entity, we have 2 custom fields named "Interview Type" & "Interview Type Global".  The Label and Value of both optionset/choice fields are completely the same as "Individual" (740110000) & "Group" (740110001).  The only difference is one is a local choice, the other one is a global choice named "Interview Type":

daniuosagi_0-1632275781404.png      daniuosagi_1-1632275818575.png

When I tried to create an Appointment record with the "Interview Type" field set as "Individual", it's patched like below and worked successfully:

Patch(Appointments, Defaults(Appointments), { 'Interview Type': 'Interview Type (Appointments)'.Individual, Subject:"Test Interview", 'Start Time':Now(), 'End Time':DateAdd(Now(), 0.5, Hours), IsDraft: false})

 

But when I tried to create an Appointment record with the other "Interview Type Global" field set as "Individual", technically the Fx should be:

Patch(Appointments, Defaults(Appointments), { 'Interview Type Global': 'Interview Type Global (Appointments)'.Individual, Subject:"Test Interview", 'Start Time':Now(), 'End Time':DateAdd(Now(), 0.5, Hours), IsDraft: false})

It shows a red wavy line saying: "The type of this argument '***_interviewtypeglobal' does not match the expected type 'OptionSetValue'.  Found type 'Error'."

 

I also tried to remove the "Global" on the right side since they're using the exact same OptionSetValues & Labels, which becomes:

Patch(Appointments, Defaults(Appointments), { 'Interview Type Global': 'Interview Type Global (Appointments)'.Individual, Subject:"Test Interview", 'Start Time':Now(), 'End Time':DateAdd(Now(), 0.5, Hours), IsDraft: false})

It shows another error saying: "Invalid argument type.  Expecting a OptionSetValue value, but of a different schema."

 

We need both fields for our business process.  The confusing parts are:

1. Why it works on the "Interview Type" but not the "Interview Type Global“ field.  Technically a global optionset/choice column/field is what the PowerApps is suggesting more, but I'm only able to set the Local Choice field.  Is there any way to make it work on the "Interview Type Global" as well?

2. If there is no solution to the question 1, is there a way that we can set a static OptionSetValue given we already have the value to make something like in C# of Javascript:  "OptionsetValue (740110000)" to make it work instead of having to pull from the datasource like 'Interview Type Global (Appointments)'.Individual"?  If so, how to use it?

 

Thanks a lot in advance!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Community Champion
Community Champion

Hi @daniuosagi 

 

Use Global Choice Field

 

Patch(
    Appointments,
    Defaults(Appointments),
    {
        Subject: "Test Stalin Interview",
        'Start Time': Now(),
        'End Time': DateAdd(
            Now(),
            0.5,
            Hours
        ),
        IsDraft: false,
        'Interview Type Global': 'Interview Type'.Group
    }
)

 

In this example

 

'Interview Type Global' - Column name in Appointment table

'Interview Type' - Global Choice field

 

StalinPonnusamy_0-1632281587190.png

 

View solution in original post

2 REPLIES 2
StalinPonnusamy
Community Champion
Community Champion

Hi @daniuosagi 

 

Use Global Choice Field

 

Patch(
    Appointments,
    Defaults(Appointments),
    {
        Subject: "Test Stalin Interview",
        'Start Time': Now(),
        'End Time': DateAdd(
            Now(),
            0.5,
            Hours
        ),
        IsDraft: false,
        'Interview Type Global': 'Interview Type'.Group
    }
)

 

In this example

 

'Interview Type Global' - Column name in Appointment table

'Interview Type' - Global Choice field

 

StalinPonnusamy_0-1632281587190.png

 

View solution in original post

It works!  Thanks a lot!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,248)