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

Help with Patch a new record to Booking Alert Entity

I'm trying to patch a new record to the OOB booking alert entity.  There's an custom optionset that specify which type of booking alert (ie. notes, photo etc). 

When I use this formula: Patch('Booking Alerts', Defaults('Booking Alerts'), {'Booking Alert Type': 'Booking Alert Type'.Note, Subject: Note_Subject_TextInput.Text})

it gave me this error. 

yichingjc_0-1601660122234.png

I'm not sure how to resolve. Please help. 

4 REPLIES 4
Highlighted
Super User II
Super User II

Hi @yichingjc,

What type of control 'Booking Alert Type'? To update optionsets, you'll need to set the integer value of the optionset item. Here's an updated sample of your code. I'm assuming you're using a non-global optionset and getting the optionset value from a dropdown:

Patch('Booking Alerts', Defaults('Booking Alerts'), {'Booking Alert Type': LookUp(Choices('Booking Alerts'.'Booking Alert Type'), Value = Dropdown1.Selected.Value).Value, Subject: Note_Subject_TextInput.Text})

 

Hope this helps

Highlighted

@EricRegnier 
Thanks but I don't think thats correct. You are supposed to patch CDS optionset like this (see screenshot).  I think my issue isn't the optionset, its the Owner Field and I know it is a User. I'm not sure how to patch that...When I tried Owner: First(User()) it still gives me the same error. 

yichingjc_0-1601905089919.png

 

Highlighted

Could be, there are different ways to patch option sets and also depends on the connector used. It's very possible the issue can be with the Owner field. Can you please share your updated patch again as I don't see the Owner getting patched in your original one. Cheers!

Highlighted

@EricRegnier  
I tired patching this - 

 

yichingjc_1-1602003737509.png

 

But that still gave me the same error at the beginning. The given key was not present in the dictionary. I wish it can tell me more.....

 

I also tried - setting a variable for the owner field as I know its USER (polymorphic lookup)
I set the variable to be onVisible of the screen = Set(varUser, First(Users).User)

yichingjc_2-1602003971584.png

 

Patch('Booking Alerts', Defaults('Booking Alerts'), {'Booking Alert Type': 'Booking Alert Type'.Note, Subject: Note_Subject_TextInput.Text, Owner: varUser})
It still gave me error below -

"The type of this argument '_ownerid_value' does not match the expected type 'Polymorphic'. Found type 'Guid'."

 

Tagging - @Shanescows  Hoping you can shed some light in this. 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Users online (11,046)