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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

booking rule: how can I do a dialog box coming when the 2nd Bookings of the same Work Order are made

(0) ShareShare
ReportReport
Posted on by 45

Hii, While adding booking to the resources on the Schedule Board; It doesn't matter when the first booking is made, but when the 2nd or later Bookings of the same Work Order are made, a Notification showing some information about the previous Bookings should come. I guess I should do booking rule with javascript. How can get bookings information I want with js?

I have the same question (0)
  • Suggested answer
    Gabriel Dias Junckes Profile Picture
    2,428 on at

    If you want to use the Booking Rules you can follow the sample below. You can check how many bookings there are under the work order.

    docs.microsoft.com/.../set-up-booking-rules

    Alternatively, you can use the booking alert. It might be easier to implement using a Flow.

    https://docs.microsoft.com/en-us/dynamics365/field-service/booking-alert 

  • CRMcrm1 Profile Picture
    45 on at

    How should I start the part where I will create a rule in javascript? can you help me? Gabriel Dias Junckes 

  • CRMcrm1 Profile Picture
    45 on at

    .............

    var resourceId = (sbContext.newValues.ResourceId !== undefined) ? sbContext.newValues.ResourceId : "";

    var resourceReqId = (sbContext.newValues.ResourceRequirementId !== undefined) ? sbContext.newValues.ResourceRequirementId : "";

    var timeDependency = formContext.getAttribute("wwsl_timedependency").getValue();

    var bookingStatus = formContext.getAttribute("bookingstatus").getValue();

    var rr = Xrm.Page.getAttribute('msdyn_resourcerequirements');

    if (rr != null && rr.getValue() != null && rr.getValue().length > 0) {

    resourceReqId = rr.getValue()[0].id;

    }

    var resourceId = sbContext.newValues.ResourceId;

    var startTime = sbContext.newValues.StartTime;

    var endTime = sbContext.newValues.EndTime;

    if() {

       ruleResult.IsValid = true;

       ruleResult.Message = "Success";

       ruleResult.Type = 'success';

    }

    else {

       ruleResult.IsValid = false;

       ruleResult.Message = "For Multiple Resource Bookings, Time Dependency is selected as" + timeDependency

                             resourceReqId , resourceId , startTime - endTime;

       ruleResult.Type = 'warning';

    }

    alert("End Business Rule ...");

    return ruleResult;

    }

    function actionInputParameters(ctx) {

       'use strict';

       var inputParameters = {};

       inputParameters = {

           "bookingstartdate": ctx.newValues.StartTime,

           "bookingenddate": ctx.newValues.EndTime,

           "newBookableResource": ctx.newValues.ResourceId

       };

       return JSON.stringify(inputParameters);

    }

    I wrote like this but I'm not sure. If booking status is for ex. ABC, this alert should be come. can you help me please.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 61 Super User 2025 Season 2

#2
Siv Sagar Profile Picture

Siv Sagar 52 Super User 2025 Season 2

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 31 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans