Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Unanswered

Script Error Bookable Resource Booking

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?

  • 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?

  • RE: Script Error Bookable Resource Booking

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans