In this example we will preview how to use scripts and the Infoplus API to check for hazmat items on an order.
if(order.lineItems) { ////////////////////////////////////////////////////////// // setup a filter for all the items on the order // ///////////////////////////////////////////////////////// for(var i = 0; i < order.lineItems.size(); i++) { var lineItem = order.lineItems.get(i); var sku = lineItem.sku; var items = infoplusApi.search("item", "lobId eq '" + order.lobId + "' and sku eq '" + sku + "'", null, 100, null); } if(items.size() > 0) { for(var i = 0; i < items.size(); i++) { var lineItem = items.get(i); var hazmat = lineItem.hazmat; if(lineItem.hazmat.equals("Yes")) { utils.log("Found Dangerous Goods Item: " + items.sku); infoplusApi.addTag("order", order.orderNo, "DG Order"); order.customFields.put("containsDangerousGoods", "True"); break; } else { utils.log("No Dangerous Goods Items found on this order"); order.customFields.put("containsDangerousGoods", "False"); } } } else { utils.log("No Items found on this order"); } } infoplusApi.updateCustomFields("order", order); infoplusApi.update("order", order);