Simplify Agreement Booking Recurrence With One Click

Introduction

In Field Service, you can create work orders automatically by using agreements and the interval in which the work orders are created can be set up by using booking recurrence from the agreement booking setup, but this might be confusing and time consuming for clients/users, so in this blog we will see how you can configure the booking recurrence and keep it at just one click.

Dynamics 365 Field Service OOB functionality to setup Booking Recurrence

 

  • Go to Agreements > Agreement Booking Setup –> Booking Recurrence.
  • Once user clicks on the “BOOKING RECURRENCE” button, the following window is opened, where the user provides the required information.

  • The above Booking recurrence pattern is an example of Monthly recurrence which will create a Work Order on 1st weekday of every month from the Start Date to End Date.
  • A user will require too many clicks and need to set the proper patterns to achieve requirements, and this can be tedious for some users.

Simplified one click solution for Booking Recurrence

  • To make the above process simple for Users, you can make a custom Option Set field “Booking Recurrence” on the Booking Setup form with the most commonly used option values like: “Weekly”, “Monthly”, “Quarterly”, “Bi-annually” and “Annually” as indicated in the below picture.
  • You can also add this field on some other entity if you are using the other entity to create the Agreement.

  • And by selecting any one option from the above option set, the Booking Recurrence pattern is automatically generated. Based on the Booking Recurrence pattern, the Booking Date record gets created.

To achieve this follow the below steps:

  1. There is a “Recurrence settings” field on the Agreement Booking Setup form, but it is hidden. This field takes an xml string.
  2. You will need to set the XML string in the field to achieve the above functionality.
  3. Once the XML string is set the OOB Field service workflow is triggered and the booking recurrence is set

The structure of the XML string for most commonly used Booking Recurrence Pattern is given below:

For Creating Bookings Weekly:

var recurrenceSettingXml =
"<root><pattern><period>weekly</period><option>every</option><weeks every='1'><days>1</days></weeks></pattern><range><start> AGREEMENTSTARTDATE </start><option>endBy</option><end> AGREEMENTENDDATE </end></range><datas/></root>"

For Creating Bookings Monthly:

var recurrenceSettingXml =
<root><pattern><period>monthly</period><option>everyWeekday</option><months every='1'><weekdef>1</weekdef><weekday>7</weekday></months></pattern><range><start>AGREEMENTSTARTDATE </start><option>endBy</option><end> AGREEMENTENDDATE </end></range><datas/></root>"

For Creating Bookings Quarterly:

var recurrenceSettingXml =
"<root><pattern><period>monthly</period><option>everyWeekday</option><months every='3'><weekdef>1</weekdef><weekday>7</weekday></months></pattern><range><start>AGREEMENTSTARTDATE </start><option>endBy</option><end> AGREEMENTENDDATE </end></range><datas/></root>"

For Creating Bookings Bi-Annually:

var recurrenceSettingXml =
"<root><pattern><period>monthly</period><option>everyWeekday</option><months every='6'><weekdef>1</weekdef><weekday>7</weekday></months></pattern><range><start>AGREEMENTSTARTDATE </start><option>endBy</option><end> AGREEMENTENDDATE </end></range><datas/></root>"

For Creating Bookings Annually:

var recurrenceSettingXml =
"<root><pattern><period>yearly</period><option>every</option><years every='1'><day>1</day></years></pattern><range><start>AGREEMENTSTARTDATE </start><option>endBy</option><end> AGREEMENTENDDATE </end></range><datas/></root>"

Where,

  • AGREEMENTSTARTDATE– “Agreement start date” of Agreement record.
  • AGREEMENTENDDATE– “Agreement end date” of Agreement record.

So, to finally use this functionality and generate the XML string based on the selected option set value and set it to the Recurrence settings field. You can simply write a JavaScript code for generating the XML string

Use the following code snippet to assign the selected option set’s value to Recurrence settings field:

formContext.getAttribute(“msdyn_recurrencesettings”).setValue(recurrenceSettingXml);