Skip to main content

Notifications

Announcements

No record found.

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

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?

  • CRMcrm1 Profile Picture
    CRMcrm1 45 on at
    RE: booking rule: how can I do a dialog box coming when the 2nd Bookings of the same Work Order are made

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

    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.

  • CRMcrm1 Profile Picture
    CRMcrm1 45 on at
    RE: booking rule: how can I do a dialog box coming when the 2nd Bookings of the same Work Order are made

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

  • Suggested answer
    Gabriel Dias Junckes Profile Picture
    Gabriel Dias Junckes 2,435 on at
    RE: booking rule: how can I do a dialog box coming when the 2nd Bookings of the same Work Order are made

    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 

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans