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

Source Script Node (Table)

Experimental

This node allows you to customize data extraction and manipulation then return data in tabular form to the following node.

Example: Read tabular data from a file (e.g., CSV) and return it as a table or structured data.

var tableContent = FileUtil.readFile("d:\\tmp\\file.csv");
// Perform any required operations on the table
return tableContent;

Example: Retrieve data from API and return in Tabular format

// Retrieve exchange rates from the API
var request = HttpUtil.get("https://boi.org.il/PublicApi/GetExchangeRates");
var jsonContent = JsonUtil.parse(request.asString().getBody());
var exchanges = jsonContent.exchangeRates;

// Create a table to store the data
var table = SuiteTable.create("MyTable");
table.addStringColumn("key");
table.addDoubleColumn("rate");
table.addStringColumn("lastupdate");

// Populate the table with data from the API
for (var i = 0; i < exchanges.size(); i++) {
    var item = exchanges[i];
    var key = item.key.asText();
    var rate = item.currentExchangeRate.asDouble();
    var date = item.lastUpdate.asText();
    
    var row = {
        "key": key,
        "rate": rate,
        "lastUpdate": date
    };
    

    table.addRow(row);
}

// Filter table with some type of selection example:
var selection = table.stringColumn("key").isEqualTo("USD");
var filteredTable = table.where(selection);

// Return the filtered table
return filteredTable;
PreviousSource Script Node (File)NextSource Script Node (Object)

Was this helpful?