Using a Script & Trigger to Update Parcel Reference Fields in Orders

Learn the steps to use a script and trigger combination to automatically update parcel reference fields for orders

*Note: Due to the ever-changing nature of writing and maintaining scripts, Infoplus does not provide support in this area. We recommend someone in your IT Department handles scripting requests internally so that you keep all control over the process.*

This article will describe how an Infoplus user can use a script and trigger combination to automatically update parcel reference fields for orders. Some companies, like Target or WalMart, require additional requirements to be displayed on the parcel labels. Use this script to make these changes on these orders so that required fields are included on these parcel labels.

In this particular example we will explore mapping the following:

Parcel Reference 1 mapped with Order No

Parcel Reference 2 mapped with Customer Order No

Parcel Reference 3 mapped with Customer PO No 

First we will want to use the Infoplus API reference page to get the field names in question. (make sure you are using the beta (our edge) version of the API)!/order/addOrder

The field names needed to complete this script are as follows: 

Order No: orderNo

Customer Order No: customerOrderNo

Customer PO No: customerPONo

Parcel Reference 1:  parcelLabelRef1

Parcel Reference 2:  parcelLabelRef2

Parcel Reference 3:  parcelLabelRef3

Step 1:  Navigate to the Script table and select the Create New button. 

Step 2: Enter a name for the script, select Record as Script Type, Order as Record Type and again make sure you are using the Beta API Version. 

Step 3: The code to make this happen is very simple. 


Step 4: Now that we have the script created, we can setup a Trigger to automatically run it on the orders we want. In this example, we will update all orders that enter the system. To accomplish this we will navigate to the order table and create a smart filter for any order in the 'Pending' status (orders are briefly in a pending status when they first enter the system). By creating a filter on this pending status we will be able to update all of the orders before they are in an 'On Order' status. 

Note: you can apply additional filters if you want to specify what kind of orders this script should be applies to, ie. certain lines of business, carriers, ship to states etc. etc.

Step 5: Now that you have the script and a pending smart filter created, it is time to create the trigger that will automatically run the script. Navigate to the Trigger table and select Create New. 

Step 6: Give the trigger an appropriate name and description. Next, select the pending smart filter that was created and make sure the trigger is active. Since we want to run this script on any new orders entering the system, we will choose the Insert event option. (The update option would run the script anytime and order is updated to meet the smart filter criteria.)

Step 7:  Now that the trigger is created, we will want to give it an 'action' to take. Select the actions icon bubble to see the full menu of available actions. In this scenario we will want to select 'run script' and choose the Parcel Reference Mapper script. (note that you can stack actions on top of each other for a single trigger)

Once you hit save, the trigger is in place and the next order that enters the system should get updated. You can check your script by looking at your Script Log table once some orders have dropped in.