Skip to content

Built-in Functions

Actions have functions that are provided from the start. This is called a built-in function. Built-in functions correspond to methods of the object $fn and can be called in the form $fn.XXX.

Tips

$fn.addUsers(param)

Add users to the application’s authorization group. "asynchronous"

Tips

Arguments

NameTypeDescription
paramobjectGroup name and user information to add

parameters details

PropertyTypeDescription
groupNamestringGroup Name
emailsarray of stringArray of email addresses of users to add to the group

Return value

None

Sample

try {
/* CSV content
* ---------------------------
* "email"
* "user01@test.co.jp"
* "user02@test.co.jp"
* ---------------------------
*/
const file = await $fn.getFile('/addUsers.csv');
const buffer = file.data;
const addUsers = $fn.csvToObject(buffer);
const emails = addUsers.map(function (item) {
return item['email'];
});
// Add user to authorization group [Group01]
await $fn.addUsers({
groupName: "Group01",
emails: emails
});
}catch(err) {
console.log("Error", err);
}

$fn.createFolder(path)

Creates a folder in the specified path. "asynchronous"

Tips

Arguments

NameTypeDescription
pathstringPath of the folder to be created

Tips

Return value

None

Sample

try {
await $fn.createFolder('/folder1');
} catch (err) {
console.log("Error", err);
}

$fn.createGroup(param)

Add an authorization group for the application. "asynchronous"

Tips

Arguments

NameTypeDescription
paramobjectGroup information to be registered

parameters details

PropertyTypeDescription
groupNamestringGroup Name
descriptionstringDetails

Return value

TypeDescription
Promise<Group>Registered Group Information
ObjectPropertyTypeDescription
GroupgroupNamestringGroup Name
descriptionstringDescription
membersobject arrayActive user array belonging to group

Tips

Sample

const groupName = $ui.groupName.value;
const description = $ui.description.value;
try {
await $fn.createGroup({
groupName: groupName,
description: description
});
} catch (err) {
console.log("Error", err);
}

$fn.createUser(param)

Add an authenticated user for the application. "asynchronous"

Tips

Arguments

NameTypeDescription
paramobjectUser information to be registered

parameters details

PropertyTypeDescription
emailstringEmail (string used for sign-in ID)
namestringName
passwordstringTemporary password
sendMailbooleantrue: Send issue mail
false: Do not send issue mail
Default is false
custom_01stringCustom Attribute 1
custom_02stringCustom Attribute 2
custom_03stringCustom Attribute 3
custom_04stringCustom Attribute 4
custom_05stringCustom Attribute 5
custom_06stringCustom Attribute 6
custom_07stringCustom Attribute 7
custom_08stringCustom Attribute 8
custom_09stringCustom Attribute 9
custom_10stringCustom Attribute 10

Tips

Return value

TypeDescription
Promise<User>Registered User Information
ObjectPropertyTypeDescription
UseruserIdstringUser ID (GUID)
emailstringEmail
namestringName
custom_01stringCustom Attribute 1
custom_02stringCustom Attribute 2
custom_03stringCustom Attribute 3
custom_04stringCustom Attribute 4
custom_05stringCustom Attribute 5
custom_06stringCustom Attribute 6
custom_07stringCustom Attribute 7
custom_08stringCustom Attribute 8
custom_09stringCustom Attribute 9
custom_10stringCustom Attribute 10
enabledbooleanEnable/Disable
createdstringCreation date and time
updatedstringUpdate date and time
statusstringUser Status

Tips

Sample

try {
/* CSV content
* -----------------------------------------------------
* "email","name","password","sendMail"
* "user01@test.co.jp","User01","Password@01",true
* "user02@test.co.jp","User02","Password@02",false
* -----------------------------------------------------
*/
const file = await $fn.getFile('/userInfo.csv');
const buffer = file.data;
const userInfos = $fn.csvToObject(buffer);
for (let userInfo of userInfos) {
console.log(JSON.stringify(userInfo));
let data = {};
data = {
email: userInfo['email'],
name: userInfo['name'],
password: userInfo['password'],
sendMail: JSON.parse(userInfo['sendMail'])
};
// Add User
let result=await $fn.createUser(data);
if(result.errorType){
throw new Error (result.errorMessage);
}
}
} catch(err) {
console.log("Error", err.message);
}

$fn.csvToObject(csv)

Converts the specified CSV file data to object format.

Arguments

NameTypeDescription
csvBufferBuffer object in CSV file

CSV File Specifications

HeaderRequired
This is the name of the object’s property.
Only single-byte alphanumeric characters are allowed.
(Starting with a numeral is not acceptable.) Example)“email”, “name”
Delimiter,(comma)
FieldIf the value contains double quotes,commas, or line breaks, be sure to enclose them.
Newline CharacterCRLF or LF
EncodingUTF-8
BOMWithout BOM or with BOM

Return value

TypeDescription
array of objectConverts CSV file data to object format and returns it

Tips

Sample

try {
/* CSV Contents
* ----------------------------------------------------------------------------
* Id,Title,Description,Progress,Category,CreatedBy,CreatedAt
* 00001,Title 1,"Description 1, Sample 1",100,CATEGORY1,User1,2023-08-01
* 00002,Title 2," Description 2, Sample 2",80,CATEGORY2,User2,2023-08-10
* 00003,Title 3," Description 3, Sample 3",20,CATEGORY3,User3,2023-08-12
* ----------------------------------------------------------------------------
*/
const file = await $fn.getFile("/path/to/projects.csv");
const buffer = file.data;
// Parses CSV files and converts them to objects
const projects = $fn.csvToObject(buffer);
// Register data one case at a time
for (const project of projects) {
const { Id, Title, Description, Category, Progress, CreatedBy, CreatedAt } = project;
if (!Id) {
throw new Error("Please enter ID.");
}
const progress = Number(Progress);
if (isNaN(progress)) {
throw new Error("Enter the percentage of progress with numeric.");
}
/* SQL Function Content
* ------------------------------------------------------------------------------------
* insert into Project VALUES (${param.id},${param.title},${param.description},
* ${param.progress},${param.category},${param.createdBy},${param.createdAt});
* ------------------------------------------------------------------------------------
*/
// Register data in tables with SQL functions
await insertToProjectTable({
id: Id,
title: Title,
description: Description,
progress,
category: Category,
createdBy: CreatedBy,
createdAt: CreatedAt
});
}
} catch (e) {
console.error(e);
}

$fn.deleteFile(path)

Deletes files in the specified path. "asynchronous"

Tips

Arguments

NameTypeDescription
pathstringPath of the file to be deleted

Tips

Return value

None

Sample

try {
await $fn.deleteFile('/note.txt');
} catch (err) {
console.log("Error", err);
}

$fn.deleteFolder(path)

Deletes folder in the specified path. "asynchronous"

Tips

Arguments

NameTypeDescription
pathstringPath of the folder to be deleted

Tips

Return value

None

Sample

try {
await $fn.deleteFolder('/folder1');
} catch (err) {
console.log("Error", err);
}

$fn.deleteUser(email)

Deletes the authenticated user of the application. "asynchronous"

Tips

Arguments

NameTypeDescription
emailstringEmail of user to be deleted

Return value

None

Tips

Sample

try {
/* CSV content
* ---------------------------
* "email"
* "user01@test.co.jp"
* "user02@test.co.jp"
* ---------------------------
*/
const file = await $fn.getFile('/userInfo.csv');
const buffer = file.data;
const userInfos = $fn.csvToObject(buffer);
const emails = userInfos.map(function (item) {
return item['email'];
});
// Delete User
for (let email of emails) {
console.log(email);
await $fn.deleteUser(email);
}
} catch(err) {
console.log("Error", err);
}

$fn.download(file, filename)

Download the specified file locally. The name of the file to be downloaded, can be specified. "asynchronous"

Tips

Arguments

NameTypeDescription
fileBufferBuffer object of the file to download
filenamestringFile name to download

Return value

None

Sample

try {
const file = await $fn.getFile('/note.json');
const buffer = file.data;
// File Download
await $fn.download(buffer, 'download.json');
} catch (err) {
console.log("Error", err);
}

$fn.getCurrentPosition()

Obtains the current location of the smartphone device.

Tips

Arguments

None

Return value

TypeDescription
GeolocationCoordinatesDevice Location

Sample

$fn.getCurrentUser()

Retrieves the user who is signed in. "asynchronous"

Tips

Arguments

None

Return value

TypeDescription
UserReturns the user currently signed in
ObjectPropertyTypeDescription
UseruserIdstringUser ID (GUID)
emailstringEmail
namestringName
custom_01stringCustom Attribute 1
custom_02stringCustom Attribute 2
custom_03stringCustom Attribute 3
custom_04stringCustom Attribute 4
custom_05stringCustom Attribute 5
custom_06stringCustom Attribute 6
custom_07stringCustom Attribute 7
custom_08stringCustom Attribute 8
custom_09stringCustom Attribute 9
custom_10stringCustom Attribute 10
enabledbooleanEnable/Disable
createdstringCreation date and time
updatedstringUpdate date and time
statusstringUser Status

Sample

try {
const user = await $fn.getCurrentUser();
console.log(user);
} catch (err) {
console.log("Error", err);
}

$fn.getFile(path)

Retrieves the file at the specified path. "asynchronous"

Tips

Arguments

NameTypeDescription
pathstringPath of file to be retrieved

Tips

Return value

TypeDescription
Promise<{data: Buffer}>Object with properties of binary data (data: Buffer type) to be retrieved from Amazon S3

Tips

Sample

try {
const file = await $fn.getFile('/note.json');
const buffer = file.data;
// JSON object
const obj = JSON.parse(buffer.toString());
} catch (err) {
console.log("Error", err);
}

$fn.getFileNames(path)

Obtains a list of file names in a specified directory path. "asynchronous"

Tips

Arguments

NameTypeDescription
pathstringPath of the directory to be retrieved

Return value

TypeDescription
array of stringList of file names in target directory

Tips

Sample

try {
const files = await $fn.getFileNames('/folder1');
} catch (err) {
console.log("Error", err);
}

$fn.getGroups(option)

Retrieves all groups that exist in the user manager. "asynchronous"

Tips

Arguments

NameTypeDescription
optionobjectSpecify whether to include invalid users

Option Details

NameTypeDescription
containUsersbooleantrue: Include users belonging to the group
false: Do not include users belonging to the group
Default is true

Return value

TypeDescription
Promise<Group[]>Group list
ObjectPropertyTypeDescription
GroupgroupNamestringGroup Name
descriptionstringDescription
membersobject arrayActive user array belonging to group

Sample

try {
// Obtain group information not including users belonging to the group
const groups = await $fn.getGroups({containUsers:false});
console.log(groups);
} catch (err) {
console.log("Error", err);
}

$fn.getLanguage()

Gets the currently displayed language.

Arguments

None

Return value

TypeDescription
stringReturns one of the values of "default | en | ja"

Sample

const lang = $fn.getLanguage();

$fn.getPresignedUrl(path,options)

Issues a signed URL to access a file manager in the WebPerformerNX execution environment. "asynchronous"

Tips

Argument

NameTypeDescription
pathstring
  • File path of the file manager issuing the signed URL
  • Support for the following query parameter
  • Query ParameterDescription
    response-content-typeOverride Content-type in response headers
    If not specified, binary/octet-stream is set
    response-cache-controlOverride Cache-control in response headers
    optionsobjectSigned URL validity time

    Options Details

    PropertyTypeDescription
    expiresInnumberValidity time of signed URL (seconds)
    Default is 900

    Tips

    Return value

    TypeDescription
    StringSigned URL

    Sample

    // Query parameter (cache:don't save, MIME type:application/pdf) specified in file path
    const path = $ui.filePath.value + "\?response-cache-control=no-store&response-content-type=application/pdf";
    // Issuing a signed URL with a validity time of 10 minutes
    $ui.url.value = await $fn.getPresignedUrl(path, {expiresIn:600});

    Tips

    Tips

    $fn.getUploadFiles()

    Retrieve files uploaded with the push button or icon button."asynchronous"

    Tips

    Arguments

    None

    Return value

    TypeDescription
    Promise <FileInfo[]>Uploaded file information
    ObjectPropertyTypeDescription
    FileInfodataBufferFile data
    filenamestringFile name
    filesizenumberFile size

    Sample

    try {
    // The return value is an array of objects
    const files = await $fn.getUploadFiles();
    await Promise.all(files.map(async (file) => {
    const path = `/uploads/${file.filename}`;
    // Save the file to the specified path
    await $fn.putFile(path, {
    data: file.data,
    });
    }));
    } catch (err) {
    console.error("Error ", err);
    }

    $fn.getUsers(groupName?,option)

    Retrieves the users present in the User Manager."asynchronous"

    Tips

    Arguments

    NameTypeDescription
    groupName?stringGroup name for user extraction conditions
    optionobjectSpecify whether to include invalid users

    Option details

    NameTypeDescription
    disabledbooleantrue: Include invalid users
    false: Do not include invalid users.
    Default is false

    Tips

    Return value

    TypeDescription
    Promise<User[]>List of users matching the criteria
    ObjectPropertyTypeDescription
    UseruserIdstringUser ID (GUID)
    emailstringEmail
    namestringname
    custom_01stringCustom Attribute 1
    custom_02stringCustom Attribute 2
    custom_03stringCustom Attribute 3
    custom_04stringCustom Attribute 4
    custom_05stringCustom Attribute 5
    custom_06stringCustom Attribute 6
    custom_07stringCustom Attribute 7
    custom_08stringCustom Attribute 8
    custom_09stringCustom Attribute 9
    custom_10stringCustom Attribute 10
    enabledbooleanEnable/Disable
    createdstringCreation date and time
    updatedstringUpdate date and time
    statusstringUser Status

    Sample

    try {
    const users = await $fn.getUsers('group1',{disabled:true});
    } catch (err) {
    console.log("Error", err)
    }

    $fn.link(url)

    Function to display the URL destination in a new tab.

    Tips

    Arguments

    NameTypeDescription
    urlstringWebsite URL

    Return value

    None

    Sample

    $fn.link(‘https://google.com/’);

    $fn.listUsersByEmail(email,option)

    Performs forward match search by Email to retrieve users present in the user manager. "asynchronous"

    Tips

    Argument

    NameTypeDescription
    emailstringSearch string
    optionobjectSpecify whether to include invalid users

    option details

    NameTypeDescription
    disabledbooleantrue: Include disabled users
    false: Do not include invalid users
    Default is false

    Tips

    Return value

    TypeDescription
    Promise<User[]>List of users matching the criteria
    ObjectPropertyTypeDescription
    UseruserIdstringUser ID (GUID)
    emailstringEmail
    namestringUser Name
    custom_01stringCustom Attribute 1
    custom_02stringCustom Attribute 2
    custom_03stringCustom Attribute 3
    custom_04stringCustom Attribute 4
    custom_05stringCustom Attribute 5
    custom_06stringCustom Attribute 6
    custom_07stringCustom Attribute 7
    custom_08stringCustom Attribute 8
    custom_09stringCustom Attribute 9
    custom_10stringCustom Attribute 10
    enabledbooleanEnable/Disable
    createdstringCreation date and time
    updatedstringUpdate date and time
    statusstringUser Status

    Sample

    try {
    const email = $ui.searchKey.value;
    // Display search results in table with table columns "userId", "email", and "name"
    $ui.userList.value = await $fn.listUsersByEmail(email,{disabled:true});
    } catch(err) {
    console.log("Error", err);
    }

    $fn.listUsersByName(name,option)

    Performs a forward match search by user name to retrieve users present in the user manager. "asynchronous"

    Tips

    Arguments

    NameTypeDescription
    nameStringSearch string
    optionobjectspecify whether to include invalid users

    Option details

    NameTypeDescription
    disabledbooleantrue: Include disabled users
    false: Do not include invalid users
    Default is false

    Tips

    Return value

    TypeDescription
    Promise<User[]>List of users matching the criteria
    ObjectPropertyTypeDescription
    UseruserIdstringUser ID (GUID)
    emailstringEmail
    namestringUser Name
    custom_01stringCustom Attribute 1
    custom_02stringCustom Attribute 2
    custom_03stringCustom Attribute 3
    custom_04stringCustom Attribute 4
    custom_05stringCustom Attribute 5
    custom_06stringCustom Attribute 6
    custom_07stringCustom Attribute 7
    custom_08stringCustom Attribute 8
    custom_09stringCustom Attribute 9
    custom_10stringCustom Attribute 10
    enabledbooleanEnable/Disable
    createdstringCreation date and time
    updatedstringUpdate date and time
    statusstringUser Status

    Sample

    try {
    const name = $ui.searchKey.value;
    // Display search results in table with table columns "userId", "email", and "name"
    $ui.userList.value = await $fn.listUsersByName(name,{disabled:true});
    } catch(err) {
    console.log("Error", err);
    }

    $fn.message(parameters)

    The snack bar component displays a message on the screen.

    Arguments

    NameTypeDescription
    parametersobjectObject indicating message content

    parameters details

    PropertyTypeDescription
    messagestringMessage string to be displayed
    closebooleanButton to close the message
    - Show (default)
    - Hide
    autoHideDurationnumberTime to auto-close (ms)
    severitystringSpecify alert display
    - none (default)
    - error
    - warning
    - info
    - success
    positionstringSpecify display position
    - bottom-left
    - bottom-center (default)
    - bottom-right
    - top-left
    - top-center
    - top-right
    transitionDurationnumberSnack bar display and fade-out time (milliseconds)

    Tips

    Return value

    None

    Sample

    $fn.message(
    {
    message: "Hello world.",
    close: false,
    autoHideDuration: 1000,
    severity: "info",
    transitionDuration: 300,
    }
    );

    $fn.nextUI(uiCode)

    Function to transition the screen to another UI.

    Arguments

    NameTypeDescription
    uiCodestringID of target UI

    Tips

    Return value

    None

    Sample

    $fn.nextUI(‘UI01’);

    $fn.putFile(path, parameters)

    Saves the file to the specified path. "asynchronous"

    Tips

    Arguments

    NameTypeDescription
    pathstringPath of the file to save
    parametersobjectdata: Buffer | Unit8Array | Objects with string as a property

    Tips

    Return value

    None

    Sample

    try {
    const obj = await $fn.getFile("/note.dat");
    await $fn.putFile('filePath', obj);
    } catch (err) {
    console.log("Error", err);
    }

    $fn.removeUsers(param)

    Exclude registered users from application authorization groups."asynchronous"

    Tips

    Arguments

    NameTypeDescription
    paramobjectGroup name and user information to be excluded

    param details

    PropertyTypeDescription
    groupNamestringGroup Name
    emailsarray of stringArray of email addresses of users to exclude from the group

    Return value

    None

    Sample

    try {
    /* CSV content
    * ---------------------------
    * "email"
    * "user01@test.co.jp"
    * "user02@test.co.jp"
    * ---------------------------
    */
    const file = await $fn.getFile('/removeUsers.csv');
    const buffer = file.data;
    const addUsers = $fn.csvToObject(buffer);
    const emails = addUsers.map(function (item) {
    return item['email'];
    });
    // Exclude users from authorization group [Group01]
    await $fn.removeUsers({
    groupName: "Group01",
    emails: emails
    });
    } catch(err) {
    console.log("Error", err);
    }

    $fn.resetPassword(param)

    Reset application authenticated user passwords."asynchronous"

    Tips

    Arguments

    NameTypeDescription
    paramobjectInformation about the user whose password is to be reset

    param details

    PropertyTypeDescription
    emailstringEmail
    passwordstringTemporary password

    Return value

    TypeDescription
    PromisePassword reset user information
    ObjectPropertyTypeDescription
    UseruserIdstringUser ID (GUID)
    emailstringEmail
    namestringName
    custom_01stringCustom Attribute 1
    custom_02stringCustom Attribute 2
    custom_03stringCustom Attribute 3
    custom_04stringCustom Attribute 4
    custom_05stringCustom Attribute 5
    custom_06stringCustom Attribute 6
    custom_07stringCustom Attribute 7
    custom_08stringCustom Attribute 8
    custom_09stringCustom Attribute 9
    custom_10stringCustom Attribute 10
    enabledbooleanEnable/Disable
    createdstringCreation date and time
    updatedstringUpdate date and time
    statusstringUser Status

    Sample

    try {
    /* CSV content
    * ------------------------------------
    * "email","password"
    * "user01@test.co.jp","Password@01"
    * "user02@test.co.jp","Password@02"
    * ------------------------------------
    */
    const file = await $fn.getFile('/resetPassword.csv');
    const buffer = file.data;
    const resetPWInfos = $fn.csvToObject(buffer);
    // reset password
    for (let resetPWInfo of resetPWInfos) {
    await $fn.resetPassword(resetPWInfo);
    }
    } catch(err) {
    console.log("Error", err);
    }

    $fn.sendMail(param)

    Send an email. "asynchronous"

    Tips

    Arguments

    NameTypeDescription
    paramobjectParameter object indicating the contents of the email transmission

    param details

    PropertyTypeDescription
    tostring arrayTO address (multiple)
    ccstring arrayCC address (multiple)
    bccstring arrayBCC address (multiple)
    fromAddressstringFrom address
    fromNamestringFrom Name
    subjectstringSubject
    textstringBody
    encodingbooleantrue: Base64 encoding of fromName
    false: Do not Base64-encode fromName
    Default is false

    Tips

    Execution EnvironmentfromAddressfromNameEmail Address Identities format
    Free-(not available)-(not available)no-reply@webperformer.jp
    Premiumavailablenot availableconfigured address
    Premiumnot availableavailableconfigured name no-reply@webperformer.jp
    Premiumavailableavailableconfigured name

    Return value

    None

    Tips

    Sample

    try {
    let toArray=["user01@test.co.jp"];
    let textValue = $ui.text.value;
    let subjectValue = $ui.subject.value;
    const params = {
    to: toArray,
    text: textValue,
    subject: subjectValue
    };
    await $fn.sendMail(params);
    } catch(err) {
    console.log("Error", err);
    }

    $fn.setLanguage(language)

    Change the display language.

    Arguments

    NameTypeDescription
    languagestringSet one of the values of "default | en | ja"

    Return value

    None

    Sample

    $fn.setLanguage(‘en’);

    $fn.signOut()

    Sign out.

    Tips

    Arguments

    None

    Return value

    None

    Sample

    $fn.signOut();

    $fn.updateUser(param)

    Update the application’s authenticated users. "asynchronous"

    Tips

    Arguments

    NameTypeDescription
    paramobjectUser information to update

    param details

    PropertyTypeDescription
    originalEmailstringEmail(before update)
    emailstringEmail(after update)
    namestringName
    enabledbooleantrue: Enabled
    false: Disabled
    Default is true
    custom_01stringCustom Attribute 1
    custom_02stringCustom Attribute 2
    custom_03stringCustom Attribute 3
    custom_04stringCustom Attribute 4
    custom_05stringCustom Attribute 5
    custom_06stringCustom Attribute 6
    custom_07stringCustom Attribute 7
    custom_08stringCustom Attribute 8
    custom_09stringCustom Attribute 9
    custom_10stringCustom Attribute 10

    Tips

    Return value

    TypeDescription
    Promise<User>Updated user information
    ObjectPropertyTypeDescription
    UseruserIdstringUser ID (GUID)
    emailstringEmail
    namestringName
    custom_01stringCustom Attribute 1
    custom_02stringCustom Attribute 2
    custom_03stringCustom Attribute 3
    custom_04stringCustom Attribute 4
    custom_05stringCustom Attribute 5
    custom_06stringCustom Attribute 6
    custom_07stringCustom Attribute 7
    custom_08stringCustom Attribute 8
    custom_09stringCustom Attribute 9
    custom_10stringCustom Attribute 10
    enabledbooleanEnable/Disable
    createdstringCreation date and time
    updatedstringUpdate date and time
    statusstringUser Status

    Sample

    try {
    /* CSV content
    * ---------------------------------------------------------
    * "originalEmail","email","name","enabled"
    * "user01@test.co.jp","user01@test.co.jp","User01",ture
    * "user02@test.co.jp","user02@test.co.jp","User02",false
    * ---------------------------------------------------------
    */
    const file = await $fn.getFile('/updateUserInfo.csv');
    const buffer = file.data;
    const userInfos = $fn.csvToObject(buffer);
    for (let userInfo of userInfos) {
    let data = {};
    data = {
    originalEmail: userInfo['originalEmail'],
    email: userInfo['email'],
    name: userInfo['name'],
    enabled: JSON.parse(userInfo['enabled'])
    };
    // Update User
    const result = await $fn.updateUser(data);
    }
    } catch(err) {
    console.log("Error", err);
    }