You are viewing PowerRosterâ„¢ v8.1. See what's new in Release Note v8.1

Compliance Rules

Prev Next

A Compliance Rule is a definition of an organisation, department or team policy that needs to be followed when scheduling or rostering resources on a Roster.

Setting up the Compliance Rules ensures that criteria such as maximum working hours, minimum breaks between shifts, and maximum weekend hours are automatically considered without the Workforce Planner needing to worry about every requirement.

These rules alert Workforce Planners to potential compliance issues, ensuring that all rosters align with organisational policies. Built-in checks provide peace of mind by preventing breaches and ensuring compliance is maintained, so planners can confidently create rosters without worrying about breaching regulations.

Example for Compliance Rules:

  • Shift is a specific type.

  • Maximum Working Hours.

  • Minimum Break between shifts.

Navigate Rules

Developers generally create compliance rules. Customers who use compliance rules are encouraged to work with Microsoft Partner/ Velrada to set up their initial rules, which can then be further refined using Compliance constraints.

To navigate the Rules:

  1. Navigate to the PowerRoster App > Settings > Go to the Compliance section and select Rules.

  2. Fill in the required fields and click Save.

Field

Description

*Name

Name of the Rule.

Description

The description of the rule describes what the rule does.

Is Valid

The field is auto-populated on save. It is used to state whether the Lambda Expression is a valid expression or not.

*Lambda Expression

Formula expression is used to interact with the C# model and define the rule.

Metadata

Metadata script JSON formula is used to break down bigger statements into smaller logical expressions as parameters within a rule definition. See the table below for the Metadata data structure.

Parameters

Parameter used within the Rule to allow it to be reused by multiple Compliance Constraints.

Data model for the Metadata field  

Field

Data Type

Nullable

Description

SuccessEvent

String

No

The message logged when rule complies. Note this is not used in the system.

ErrorMessage

String

No

The message displayed to users when the rule breaches (returns false).

LocalParams

Array: Object

No

List of LocalParams. Local Params are reusbale parameters that can be used in the rule expression. Think of it as a C# parameter for a method.

LocalParams.Name

String

No

Name of the Local Param.

LocalParams.Expression

String

No

Expression of the Local Param.

Parameters

Parameters are used in Compliance Rules to extend the functionality of Rules and to make them flexible. Parameters allow developers to create placeholders that can be modified to create multiple instances of the Compliance Rules.

Go to the Parameters tab and click on New Parameter to create a new Parameter for the Compliance Rule.

Field

Description

*Name

Name of the Parameter.

*Is Required

Whether the Parameter is mandatory or not.

*Data Type

The data type of the Parameter being created.

Default Value

The default value set for the Parameter f there is no value defined.

Metadata

Not Applicable

A screenshot of a computer  Description automatically generated

Expression Data Model

Compliance Rules can be written against the below properties on the C# class.

The ShiftModel object will be referenced by a variable name of input1.

For example, here is a rule expression checking a shift has a clock on value input1.ClockOn.HasValue && input1.ClockOn.Value != DateTime.MinValue.

Field

Data Type

Nullable

Description

ID

Guid

No

Unique ID of the shift.

ShiftType

String

Yes

The shift type.

ResourceId

Guid

Yes

Unique id of the resource assigned to the shift.

ResourceName

String

Yes

Name of the resource assigned to the shift.

Start

DateTime

Yes

Start date and time of the shift.

End

DateTime

Yes

End date and time of the shift.

ClockOn

DateTime

Yes

Date Time resource started the shift. NOTE - clock on field is set by the resource using the Frontline App.

ClockOff

DateTime

Yes

Date Time resource started the shift. NOTE - clock on field is set by the resource using the Frontline App.

PreviousShifts

Array: ShiftModel

Yes

List of shifts assigned to the resource that occured before the target shift.

FutureShifts

Array: ShiftModel

Yes

List of shifts assigned to the resource that occured afterthe target shift.

PowerRoster Compliance Rule Example

In this example, we will create a Compliance Rule when the Shift has a particular Type.

Field

Description

Name

Shift is particular type

Lambda Expression

ExpressionExtensions.CheckContains(input1.ShiftType, "|Shift Type|")

Metadata

{

"SuccessEvent":"Has shifts",

"ErrorMessage":"shift is not of type |Shift Type|"

}

Creating a new rule in Dynamics 365 with specific shift type validation details.

Complex PowerRoster Compliance Rule Example

In this example, we will create a Compliance Rule to ensure employees are not exceed a max allowed hours per week, averaged over a reference period. Eg max of 55 hours per week average over 17 weeks.

Field

Description

Name

Average Hours Per Reference Period

Lambda Expression

(input1.PreviousShifts

   .Where(s => s.Start >= input1.Start.Value.AddDays(-1 * referencePeriodInDays.First()))

   .Sum(s => Convert.ToInt32(Math.Round(((s.End.Value.Subtract(s.Start.Value).TotalMinutes) / 60), 0))) / referencePeriodInWeeks.First()) <= |maxAverageHours|

Metadata

{

   "SuccessEvent": "Is within average hours per referesgasdnce period",

   "ErrorMessage": "WARNING: Is OVER average hours per reference period",

   "LocalParams": [

       {

           "Name": "referencePeriodInHours",

           "Expression": "(new int[] {|referencePeriodInHours|})"

       },

       {

           "Name": "referencePeriodInDays",

           "Expression": "(new int[] {referencePeriodInHours.First()/24})"

       },

       {

           "Name": "referencePeriodInWeeks",

           "Expression": "(new int[] {referencePeriodInHours.First()/(24*7)})"

       }

   ]

}

Create the maxAverageHours Parameter

Field

Description

Name

maxAverageHours

Is Required

No

Data Type

Integer

Default Value

N/A

Metadata

N/A

Create the referencePeriodHours Parameter

Field

Description

Name

referencePeriodInHours

Is Required

No

Data Type

Integer

Default Value

N/A

Metadata

N/A

Note

The Nightly Compliances Runs are created by Power Automate and run every night.