Here are some real-world examples of solutions that have been built in Infoplus using Scripts.
Please note that Infoplus Support helps with scripts that are not correctly working within the Infoplus Application. Additions, Optimization, and Augmentation to scripts must be requested through our Pro Service Department. You can request a project review here.
Automatically Place Orders on Hold
Use Case: You want to place a Hold on any Order that is placed meeting certain conditions such as:
- A total value over some amount
- A specific line item
- A special ship-to destination
- etc.
This script could be assigned to run with a Trigger that searched for new Orders containing the Item "SOURCE".
Add a Line Item to an Order
Use Case: You want to a certain line item to any order that matches a specific condition. This script could be assigned to run with a Trigger that identified orders with the condition in question.
Update the names of all Third-Party Parcel Accounts to match their Account Numbers
Use Case: To clean up the data in your Third Party Parcel Account table, you want to update all records so that their Account Names match their Account Numbers.
This can be done by creating a simple script like this, then selecting rows from the Third Party Parcel Accounts table and using the Bulk Run Script process.
Split an Order into Two Orders
Use Case: Any time an Order is placed for any one or more specific SKUs, peel those SKUs off into a second-order (with the same root order number).
To use this script, you'll need to replace the top lines with the SKUs you want to be peeled off (or customize the if statement on line 23 to use your own custom rule).
This script could be assigned to run with a Trigger that searched for new Orders containing the Item "SOURCE".
Peel a special SKU off into a new order
Use Case: Any time an Order is placed for the Item "SOURCE", a second-order should be created, with the same root order number, for the Item "TARGET".
This script could be assigned to run with a Trigger that searched for new Orders containing the Item "SOURCE".
Change an Order containing Items set as Hazmat to land on hold with a Tag
Use Case: When an Order lands for an Item set up as Hazmat, place the Order on hold and add a tag to it.
How to Paginate in a API/Script
Use Case: There are time when a user is looking for records on a specific search term that produces more than 20 records. The the following script will allow the user to receive more than 20 records.
All search endpoints return paginated lists of records. By default, 20 records are returned. This can be overridden by specifying the limit query string parameter. The largest allowed value for limit is 250. Specifying a larger value will return a 400 HTTP error.
By default, the first page of results is returned from search calls (i.e., no records are skipped from the start of the result set). This can be overridden by specifying the page query string parameter. This parameter works in conjunction with the limit parameter (defaulting to 20 if not specified), to determine how many rows at the beginning of the result set are skipped, to implement paging of results.
This example is for an Invoice Worksheet Line Detail record but can be used for any record by changing the API endpoint.
The above example also shows how to paginate so that you get more than 20 records. It will loop through each page and calls come back in 20, 50, 100, and 250 intervals.
Checking Job Inventory Script
Use Case: This script is designed to be run before your Start Job Process. Running this script will query inventory to see if the necessary amounts of SKUs are received to complete the Job Process. In the event that there is enough inventory, you will receive a screen with an output that shows the following: