Announcements
Hi everyone,
I have a Power Apps canvas app, which has a gallery of Bookable Resource Bookings.
The app has a 'Change Status' button and I need this to update the Field Service Status using a Patch statement.
Have a global variable called varBooking, which contains the entire Booking record, however am getting an error with the Patch statement.
Can anyone assist with providing the correct Patch syntax...thank you
Hi Akash,
Thanks for the link, however I couldn't see any mention how to Patch a lookup field, could you provide some further information on how to Patch a Lookup field in D365
'Booking Status' is the Display name and BookingStatus is the underlying field name.. I believe you can refer to either, but because there are spaces in the Display name you have to wrap them in single quotes.
Hi Partner,
You can also refer the article docs.microsoft.com/.../function-filter-lookup which has a sample and the detailed information to patch a lookup field along with Syntax.
Hope this helps.
Best regards,
Akash
Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.
I am still not able to figure out why you keep these('Booking Status'.'Field Service Status') under quotes.
Does the data object(varNewBooking) have them in quotes?
Pass the attribute without quotes
Have experimented further using this syntax...
Set (varNewBooking,Filter('Bookable Resource Bookings', bookableresourcebookingid = varBooking.bookableresourcebookingid));
Patch('Bookable Resource Bookings',First(varNewBooking),{'Booking Status'.'Field Service Status' = 'Booking System Status'.Completed})
The varNewBooking variable was used to examine the results of the Filter, and although it worked OK, it actually returned a Table, so I used the First () function to return a single record.
Unfortunately am still getting the original error ..inside the Patch statement 'Booking Status'.'Field Service Status'.
Still think the problem is related to this Lookup field.. but will be very happy to be proved wrong
If you want to execute filter, please use filter function inside patch. Your original post doesn't show usage of filter function.
For example, you want to modify a record in a data source, named IceCream, that contains the data in the below table
Patch( IceCream, Filter( IceCream, Flavor = "Chocolate" ) , { Quantity: 400 } )
So, your patch should be as follows:
Patch('Bookable Resource Booking', Filter('Bookable Resource Booking', 'Booking Status'.'Field Service Status'= 'Booking System Status'.Scheduled), {'Booking Status'.'Field Service Status' = 'Booking System Status'.Completed})
The above is just a sample, although you should filter the actual booking using an ID / Work Order Reference.
Hi there,
Thanks for the quick response..
This is the syntax for filtering the gallery to get the booking record, so I simply tried to reference the same field names to try and update.
Filter('Bookable Resource Bookings','Booking Status'.'Field Service Status'= 'Booking System Status'.Scheduled)
Booking Status is a Lookup field
What is the 'Booking Status'.'Field Service Status'
Is it an attribute in Bookable Resource Bookings?
Why is it in quotes?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,802 Super User 2024 Season 2
Martin Dráb 229,133 Most Valuable Professional
nmaenpaa 101,154