The Custom Operations setup item enables you to make expressions without having to make a Shipping rules file. You can include the expressions supported in the Shipping Rules <expressions> node. See the Shipping Rules nodes description here.
Adding the setup item
- Go to Setup and navigate to the Location/Actor in your installation where you want to expressions to work.
- Right-click in the pane to the right and select New > Custom Operations.
- Select the type of operation and click New. There are 5 different types of operations:
- Expressions when reading request - the expression will run after the shipment JSON is parsed.
- Expressions at submit - the expression will run at the time of submit which is when a shipment is created.
- Expression at validation - the expression will run together with other validations.
- Patch Options for API - set default values for the Option parameter for Shipment Server. (Not relevant for On-premises customers).
- Patch Data for API - replace values, set a delimiter etc. (Not relevant for On-premises customers).
- Add the expression/code in the field. If you create a new XML file, you need to add your expression in the predefined <Expressions> node.
- Click OK to save.
This expression sets a default value of 15:00 in the Pickup start field if the current time (when the expression is run depending on the type of operation) is less than 14:00. If you want the expression to run on a specific carrier only, it is important to specify this. (Note: this feature does not work with custom carriers).
You can use expressions supported in the Shipping Rules <expressions> node. See the Shipping Rules nodes description here.
<!-- if(currenttime less than 14:00) today 15:00 -->
<Condition name="intlimits" field="fld_SubcarrierConceptID" min="448" max="448" />
<Condition name="timelimits" field="fld_Now" min="00:00" max="14:00"/>
<Item special="datenow" format="YYYY-MM-DD"/>
<Item expression=" "/>
<!-- if(currenttime more than 14:00) today(+1) 15:00 -->
<Item special="datenow" adddays="1" format="YYYY-MM-DD"/>
<Item expression=" "/>
In this example, postcode validation is turned off on PreAdviseOrder and labels are set tp ZPLGK.
The Patch options file follows this format:
<Param Name]=[Param Value]
If the parameter is in the call, it will not be changed. It will only be added if it is not included.
In this example, the delimiter is set to default | and four strings are replaced for PreAdviseOrder.
2="Kind": 176,|"Kind": 177,
3="Kind": 176,|"Kind": 177,
4="Kind": 176,|"Kind": 177,
The Patch data file follows this format:
n is a number starting with 1. If you have gaps in numbers, values after the gap will be ignored.
OldValue is the string to be replaced and NewValue is the string to replace the old value.