The Script Component (SC) is a user-defined block of JavaScript code that you can drop any place in the AssemblyLine data Flow list, alongside your Connectors and Function Components, causing the script code within to be executed for each cycle at this point in the AL workflow.
task.dumpEntry( work );
system.skipEntry();
When placed at the appropriate point in the flow of an AssemblyLine, this SC then displays the contents of the work object by writing it to log output and then skip the rest of the AL for this cycle. By moving the SC up and down the component list, you control how much of the AL is actually executed. If you swap out the system.skipEntry() call with system.skipTo("ALComponentName"), you directly pass control to a specific AL Component.
// The LDAP change log contains an attribute called "changeType"
if (work.getString("changeType").equals("delete"))
system.ignoreEntry();
This will cause your Update mode
Connector to skip deleted Entries. You would have complementary code
in the Before Execute Hook of your Delete mode Connector, skipping
everything but deletes.if (work.getString("changeType").equals("delete"))
synchIDS.deleteEntry( work )
else
synchIDS.update( work );
As long as you label your SC
clearly, indicating that it is running Passive Connectors, this approach
will result in shorter AssemblyLines that will be easier to read and
maintain. This is an example of having to choose between two best
practices: keeping the AL short, and using built-in logic versus custom
script. However, in this case the goals of legibility and simplicity
are best served by writing a little script.The Script Component also comes in handy when you want to test logic and script code. Just create an AssemblyLine with a single Script Component in the data Flow list, put in your code and run it.