Skip to main content

Notifications

Dynamics 365 Community / Forums / Field Service forum / Booking Rule in Field ...
Field Service forum

Booking Rule in Field Service

Posted on by Microsoft Employee

Does anyone have an example of a web resource used to create a booking rule in Field Resource? Also- is RSO the only way to avoid stacking bookings on top of each other when work orders are scheduled automatically?

Categories:
  • Thomas David Dayman Profile Picture
    Thomas David Dayman 11,323 on at
    RE: Booking Rule in Field Service

    Sorry, I made a new website a little while ago. Here is my new webiste  - www.daymandynamics.com

  • Conor Gallagher Profile Picture
    Conor Gallagher 715 on at
    RE: Booking Rule in Field Service

    Lads, can we post code as well as the links!!

    For anyone who wanders across this I managed to track down the site. And here's the code being referred to:

    function newBookingRule(sbContext) {
        debugger;
        var ruleResult = {
            IsValid: false,
            Message: '',
            Type: 'error'
        };
        var resourceReqId = sbContext.newValues.ResourceRequirementId;
        var workOrderId = null;
        var req = new XMLHttpRequest();
        req.open("GET", encodeURI(Xrm.Page.context.getClientUrl() + "/api/data/v8.2/msdyn_resourcerequirements(" + resourceReqId + ")?$select=_msdyn_workorder_value"), false);
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
        req.setRequestHeader("OData-MaxVersion", "4.0");
        req.setRequestHeader("OData-Version", "4.0");
        req.setRequestHeader("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue");
        req.send();
        if (req.readyState === 4) {
            req.onreadystatechange = null;
            if (req.status === 200) {
                var result = JSON.parse(req.response);
                workOrderId = result["_msdyn_workorder_value"];
            } else {
                Xrm.Utility.alertDialog(req.statusText);
            }
        }
     
        if (workOrderId != null) {
            ruleResult.IsValid = true;
            ruleResult.Message = "Success";
            ruleResult.Type = 'success';
            alert("WorkOrder Id: " + workOrderId);
        } else {
            ruleResult.IsValid = false;
            ruleResult.Message = 'No WorkOrder Id found';
            ruleResult.Type = 'error';
        }
        return ruleResult;
    }


  • Suggested answer
    Thomas David Dayman Profile Picture
    Thomas David Dayman 11,323 on at
    RE: Booking Rule in Field Service

    Hi Matthew,

    I made a blog post on how to use a booking rule - http://www.kentom.co.uk/?p=455

    You could use a booking rule to stop overlapping ;)

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

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,900 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,297 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans