Scripting for Routing Next-Step Selection 
The system supports scripting for routing next-step selection.
The scripting language is interpreted JavaScript. The scripts can make Enterprise Java Beans (EJB) calls or Structured Query Language (SQL) queries if needed.
There are a number of convenience methods (callEJB() and getEJBProperties(), getItemProperties(), getCustomItemProperties()) that make direct calls to EJBs. A large amount of data is also available to these scripts to help make next step decisions.
Caution
The actual syntax of the scripting language may change from the examples shown in this document. Refer to www.mozilla.org/rhino for more information about the scripting language reference.
Certain points on a routing may have multiple next steps in handling the way defects are processed at your installation. This process may vary from one installation to another, and on the same routing. The system allows you this flexibility through custom scripting logic. After one step at an operation is completed, custom logic makes the step selection when multiple next steps are possible.
When a step has multiple next steps, there are multiple connectors exiting from the step. Each of the connectors (lines) can have a decision script associated with it. These scripts are evaluated when an SFC number completes the step. The return values from all of these next steps are used to determine the next step for the SFC numbers.
Each script is associated with the paths between steps. In Routing Maintenance, to display the scripting dialog box for the next step, display the Routing panel and double-click the label on the line that represents the path to the next step.
The following figure depicts an example of the routing that includes rework logic:

In the above example, the routing includes a simple set of logic for determining the next step after the TEST operation. When an SFC number exits the TEST step, it can exit in one of four different ways.
Assume that the production engineer has included the following scripting for the next-step possibilities:
For the TEST-to-SCRAP next step, the SFC number should be scrapped if it fails and has been re-tested too many times (3 times). Therefore, the next-step definition between TEST and SCRAP would include the following scripting code:
if (NC_CODE!=null && LOOP_COUNT>=3) exit(true);
The TEST-to-PMR_ROUTER next step is defined to cover the case where the SFC number fails, but the loop count is less than 3, as specified in this sample code:
if (NC_CODE!=null && LOOP_COUNT<3) exit(true);
The TEST-to-PMR_ASSEMBLE next step is defined to handle the special case when the failure (NC) that is logged is MISSING_COMPONENT, to send the SFC number directly back to ASSEMBLE. The script logic for this would be the following:
if (NC_CODE =="MISSING_COMPONENT") exit(true);
The TEST-to-PMR_ASSEMBLE next step is defined in this sample coding without scripting. If none of the exceptions described above are encountered, the SFC number is allowed to travel through to SHIP.
For more information, see Scripting for Next Step Selection.