Skip to main content

Notifications

Dynamics 365 Community / Forums / Field Service forum / Updating Bookable Reso...
Field Service forum
Suggested answer

Updating Bookable Resource Booking set Field Service Status using Patch with Power Apps canvas app

Posted on by 5

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

pastedimage1577413826509v1.png 

  • RichardB 99 Profile Picture
    RichardB 99 5 on at
    RE: Updating Bookable Resource Booking set Field Service Status using Patch with Power Apps canvas app

    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

  • RichardB 99 Profile Picture
    RichardB 99 5 on at
    RE: Updating Bookable Resource Booking set Field Service Status using Patch with Power Apps canvas app

    '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.

  • RE: Updating Bookable Resource Booking set Field Service Status using Patch with Power Apps canvas app

    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.

  • ba365guy Profile Picture
    ba365guy 2,946 on at
    RE: Updating Bookable Resource Booking set Field Service Status using Patch with Power Apps canvas app

    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

  • RichardB 99 Profile Picture
    RichardB 99 5 on at
    RE: Updating Bookable Resource Booking set Field Service Status using Patch with Power Apps canvas app

    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

  • Suggested answer
    ba365guy Profile Picture
    ba365guy 2,946 on at
    RE: Updating Bookable Resource Booking set Field Service Status using Patch with Power Apps canvas app

    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

    pastedimage1577418422990v1.png

    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. 

  • RichardB 99 Profile Picture
    RichardB 99 5 on at
    RE: Updating Bookable Resource Booking set Field Service Status using Patch with Power Apps canvas app

    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

    pastedimage1577418013077v1.png

  • ba365guy Profile Picture
    ba365guy 2,946 on at
    RE: Updating Bookable Resource Booking set Field Service Status using Patch with Power Apps canvas app

    What is the 'Booking Status'.'Field Service Status'

    Is it an attribute in Bookable Resource Bookings?

    Why is it in quotes?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Give Back to the Community this Month

Quick Links

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,802 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,133 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,154

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans