Rule Examples

The following examples use most of the components covered in Rule Syntax.

Weighting by <number> exclusion

Let us say that you wanted to create a rule that rejects a particular carrier where the maximum dimension of any of the parcels is greater than 120 cm. You might create a rule as in the following example:

Maximum_Dim.png

When you export the rule, you will see that the test and score expressions are written as follows:

Test: (carrier.code=="HERMESPOS") && (consignment.maxdimension>120), Score: -1

You could create the same rule by entering the following 'custom' rule:

Maximum_Dim_2_.png

Weighting by <text> exclusion

Let us say that you only wish to allow local deliveries from a particular warehouse. You might create a rule as in the following example, by specifying that deliveries from that warehouse which are not to addresses that contain the initial part of the area postcode are not allowed:

Basingstoke_Del.png

Note

Note the use of '*' as a wildcard.

When you export the rule, you will see that the test and score expressions are written as follows:

Test: (consignment.warehousecode==10074) && (consignment.delivery.postcode!="RG2*"), Score: -1

You could create the same rule by entering the following 'custom' rule:

Basingstoke_Del_2_.png

Weighting by <flags> exclusion

Let us say that you wanted to create a rule that rejects carrier services from a particular warehouse when the consignment contains hazardous materials. You might create one as follows, where you exclude any service or carrier for the specified warehouse if the consignment contains hazardous items:

Weighting_by_flag.png

When you export the rule, you will see that the test and score expressions are written as follows:

Test: (consignment.warehousecode==10074) && (consignment.hazardous), Score: -1

You could create the same rule by entering the following 'custom' rule:

Weighting_by_flag_2_.png

Note

You could equally write the rule as follows:

Test: (consignment.warehousecode==10074), Score: IIF (consignment.hazardous, -1, score)

Weighting by <flags> attempt to force

Let us say that you wanted to create a rule that attempts to force delivery by a particular carrier service when the consignment requires proof of delivery. You might create a rule as in the following example:

force.png

When you export the rule, you will see that the test and score expressions are written as follows:

Test: (consignment.podnonsignature || consignment.podsignature), Score: (score * 0)

This means that the score is set to 0 when the rule applies, meaning that the associated carrier service is highly likely to be selected for allocation.

You could create the same rule by entering the following 'custom' rule:

force_2_.png

Weighting by <period of time> exclusion

Let us say that you wanted to create a rule that rejects carrier services which take too long to deliver. You might create one as follows, where you exclude any service or carrier if the maximum time in transit is greater than 24 hours:

Weighting_by_period.png

When you export the rule, you will see that the test and score expressions are written as follows:

Test: DATEDIFF(option.collection.from,option.delivery.to,3) > 24, Score: -1

Note

The '3' is the DATEDIFF mode for Hours.

You could create the same rule by entering the following 'custom' rule:

Weighting_by_period_2_.png

Weighting by <period of time> discouragement

Let us say that you wanted to create a rule that discourages carrier services that take a long time to despatch. You might create one as follows, where you disourage any service or carrier if the maximum time until despatch is greater than 18 hours:

discouragement.png

When you export the rule, you will see that the test and score expressions are written as follows:

Test: (datediff(now(),option.collection.from,3)>18), Score: (score * 2)

The score is doubled when the rule applies, meaning that the associated carrier service is less likely to be selected for allocation.

You could create the same rule by entering the following 'custom' rule:

discouragement_2_.png

'Custom rule' examples

Custom rules provide you with the flexibility to create very specific rules, particularly relating to days of the week and certain times of day, e.g.

  • Exclude a carrier/service if it is Sunday and before 16:30:

    Test: (DAYOFWEEK(today())==SUN && (formatdate(now(),"HH:mm")< "16:30"), Score: -1
  • Exclude a carrier/service if it is in carrier 'service group' NEXTDAY and it is after 17:30:

    Test: (arraycontains("service.group","NEXTDAY") && (formatdate(now(),"HH:mm")>"17:30"), Score: -1

    Caution

    The arraycontains function used with a carrier 'service group' applies to all services in that group, even when any of those services are used in other 'service groups'.

  • Discourage a carrier/service if it is a weekday between 11:00-13:15:

    Test:((ISIN(formatdate(now(),"E"),"Mon","Tue","Wed","Thu","Fri")) && 
    (formatdate(now(),"HH:mm")>="11:00") && 
    (formatdate(now(),"HH:mm")<"13:15")), Score: (score * 2)