B2Win Suite Documentation (Under Construction)
ContactB2Data
5.6
5.6
  • B2Win Suite Documentation
  • Scripting
    • B2Win Suite Scripting Overview
    • Scripting in B2Data
      • Custom Script Nodes
        • Custom Script
        • Source Script Node (File)
        • Source Script Node (Table)
        • Source Script Node (Object)
        • If-Else Condition
        • Switch case
        • Condition Node
      • In DataPrep
      • Properties
      • Workflow Applications
        • Workflow #1
        • Workflow #2
    • Getting Started
    • Language Basics
    • Types & Objects
      • Primitives
      • Objects
        • Instant
        • LocalDateTime
        • LocalDate
        • LocalTime
        • JsonNode
        • ObjectNode
        • File
        • SuiteTable
        • Duration
        • Period
      • Arrays & Maps
      • Row, Column, StringColumn
    • Utilities
      • Date & Time
        • InstantUtil
        • GeneralDateUtil
        • LocalDateTimeUtil
        • LocalDateUtil
        • LocalTimeUtil
        • Formatting
        • Timezones
      • Math
      • StrictMath
      • NumericUtil
      • DbUtil
      • DbExecutor
      • StateUtil
      • FileUtil
      • JsonUtil
      • HttpUtil
      • NodeInputReader
      • RandomUtil
      • HashingUtil
      • ShellUtil
      • CompressionUtil
      • Logging
    • Properties
    • Context and System
      • Context
      • System
    • Configurations
      • Workflow Configuration
    • Tutorial
    • Feedback
  • B2Data
    • Tutorials
      • Infor DataFabric to On-Premise Database Replication
      • API (DB replication, Email)
    • Workflow Settings
      • General Settings
      • Global/All Properties
      • Execution Configuration
        • General
        • Runtime
        • Compiler
        • Storage
        • Clean Up
      • Permissions
    • Nodes
      • Scheduler
    • Services Configuration
      • Microsoft Graph
Powered by GitBook
On this page

Was this helpful?

  1. Scripting
  2. Scripting in B2Data
  3. Custom Script Nodes

Switch case

This node enables you to evaluate an input value against multiple predefined cases and route the flow to the corresponding output port based on the matching case.

Example:

/**
 * Write your code here
 * For example a random condition that returns 0, 1 or 2 and output them to a different output port
 */
return Math.round(Math.random() * 10) % 3;

Or for a more intuitive example:

var fileName = NodeInputReader.inputAsFile().getName();

// which department to work with
if (fileName.contains("Accounting")) {
    return 0; // Accounting output
} else if (fileName.contains("Human_Resources")) {
    return 1; // Human Resources output
} else {
    return 2; // Development output
}

In this example the node will evaluates the name of the input file and determines the relevant department based on predefined cases. Depending on the department identified in the file name, the workflow routes to the corresponding output port:

  • Port 0 (Accounting): If the file name contains "Accounting," the flow is routed to the Accounting output port.

  • Port 1 (Human Resources): If the file name contains "Human_Resources," the flow is routed to the Human Resources output port.

  • Port 2 (Development): If the file name does not match "Accounting" or "Human_Resources," it defaults to the Development output port.

PreviousIf-Else ConditionNextCondition Node

Was this helpful?