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
  • Script Source (Table)
  • DataPrep
  • Send Email (Global SMTP)

Was this helpful?

  1. B2Data
  2. Tutorials

API (DB replication, Email)

PreviousInfor DataFabric to On-Premise Database ReplicationNextWorkflow Settings

Was this helpful?

Script Source (Table)

var request = HttpUtil.get("https://randomuser.me/api");
var jsonContent = JsonUtil.parse(request.asString().getBody());
var user = jsonContent.get("results").get(0);

// Create a table to store the data
var table = SuiteTable.create("UsersTable");
table.addStringColumn("uuid");
table.addStringColumn("firstname");
table.addStringColumn("lastname");
table.addStringColumn("gender");
table.addStringColumn("country");
table.addStringColumn("city");
table.addStringColumn("email");
table.addStringColumn("phone");


// Populate the table with data from the API
var uuid = user.get("login").get("uuid").asText();
var firstname = user.get("name").get("first").asText();
var lastname = user.get("name").get("last").asText();
var gender = user.get("gender").asText();
var country = user.get("location").get("country").asText();
var city = user.get("location").get("city").asText();
var email = user.get("email").asText();
var phone = user.get("phone").asText();

var row = {
    "uuid": uuid,
    "firstname": firstname,
    "lastname": lastname,
    "gender": gender,
    "country": country,
    "city": city,
    "email": email,
    "phone": phone
};


table.addRow(row);

// Return the table
return table;

DataPrep

Weather

var table = NodeInputReader.inputAsDataFrame();
var city = table.row(0).getString("city");

var request = HttpUtil.get("https://wttr.in/" + city + "?format=2");
var body = request.asString().getBody().trim();

Send Email (Global SMTP)

Email (property)

var table = NodeInputReader.inputAsDataFrame();
return table.row(0).getString("email");

City (property)

var table = NodeInputReader.inputAsDataFrame();
return table.row(0).getString("city");

FULL_NAME (property)

var table = NodeInputReader.inputAsDataFrame();
var firstname = table.row(0).getString("firstname");
var lastname = table.row(0).getString("lastname");
return firstname + " " + lastname

Weather (property)

var table = NodeInputReader.inputAsDataFrame();
return table.row(0).getString("weather");

General configuration

To:

${EMAIL}

Subject:

Welcome to "Company", ${FULL_NAME}!

Message:

Dear ${FULL_NAME},

Welcome to the "Company" family! We’re thrilled to have you join our team.

As you settle in, we hope the weather (${WEATHER}) in ${CITY} reflects the warmth and excitement we feel about having you onboard.

We believe that your skills and experiences will make a positive impact on our journey together. If you have any questions or need support as you get started, please don’t hesitate to reach out—we’re here to help.

Looking forward to meeting you in person and working together!

Warm regards, "Company" family