web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Unanswered

Script Error Bookable Resource Booking

(0) ShareShare
ReportReport
Posted on by 2,909

Getting an error on Bookable Resource Booking that just randomly started.

Have some JS OnSave of the Bookable Resource Booking form which was working however now is having an error on the Field Service Mobile App. It basically checks if work order is a "breakdown" and if it's status is set to "complete" it checks if Fault Category is null and if it is it stops the Save and sets "Fault Category" required.

Doesn't happen on desktop only on mobile App so not sure if can debug like I would on desktop browser.

It does not happen every time I test.

It will work as expected make the field required and create an error notification message. I can then click the error message be taken to the field select a choice and save "complete".

This is the details from the script error:

pastedimage1644560499078v2.png

pastedimage1644560008256v1.png

function TestOnSave(executionContext) {

    var formContext = executionContext.getFormContext(); // get formContext
    var status = formContext.getAttribute("bookingstatus").getValue()[0].name;
    var faultcategory = formContext.ui.tabs.get(3).sections.get(0).controls.get(0).getAttribute("eye_faultcategory").getValue();
    var incidenttype = formContext.ui.tabs.get(3).sections.get(0).controls.get(0).getAttribute("msdyn_primaryincidenttype").getValue()[0].name;
    

    if (status == "Completed" && incidenttype == "Breakdown" && faultcategory == null) {
        executionContext.getEventArgs().preventDefault(); // Stop the Save
        
        formContext.ui.tabs.get(3).sections.get(0).controls.get(0).getAttribute("eye_faultcategory").setRequiredLevel("required")
    }
    else
    {
        formContext.ui.tabs.get(3).sections.get(0).controls.get(0).getAttribute("eye_faultcategory").setRequiredLevel("none")
}
}

I know this is a form that uses PCF to get the work order parts of the form. 

Any ideas?

I have the same question (0)
  • Dan Gittler - Dynamics Field Service Profile Picture
    on at
    RE: Script Error Bookable Resource Booking

    Hi Anthony, I asked my colleague to take a look and reply

  • Jonathan baker Profile Picture
    on at
    RE: Script Error Bookable Resource Booking

    Hi Anthony,

    Recommend you submit a support request with MS Support for help here.

    Is this an issue on mobile in general, or do the error happen specifically with mobile while running offline?

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

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 60

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 24 Super User 2025 Season 2

#3
CU29080825-0 Profile Picture

CU29080825-0 16

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans