Skip to content

Built-in function

SVF Cloud Web API calls can use built-in functions. Built-in functions are provided in the following formats to provide the same functionality as the SVF Cloud Web API.

$fn.svf.{API type}.{API name}()

The common rules for interfaces are as follows:

Function type Asynchronous function (returns Promise)
Argument Object
Return value Object or None
Exception occurence HTTP response codes and error contents can be obtained from the error object.

$fn.svf.oauth2.token()

Authentication - Retrieve access tokens

パラメータ

nametyperequiredescription
substringUser ID
expnumberExpiration time
userNamestringUser name
timeZonestringTime Zone
langstringLocale

Tips

Return value

nametypedescription
tokenstringAccess token
expirationnumberExpiration

Tips

Sample

[Action]

const results = await $fn.svf.oauth2.token({
exp: 1333685628,
sub: "xxxx@api.svfcloud.com",
userName: "John D",
locale: "ja"
});

[Return value]

{
token:"fa074d728eef1bfb1da897de1f64b53dae7857e87dd0b8b96d9f65e06da43e9f",
expiration:1442046911540
}

$fn.svf.oauth2.revoke()

Authentication - Discard access tokens

Parameter

nametyperequiredescription
tokenstringaccess token

Return value

None

Sample

[Action]

await $fn.svf.oauth2.revoke({
token: "fa074d728eef1bfb1da897de1f64b53dae7857e87dd0b8b96d9f65e06da43e9f"
});

$fn.svf.artifacts.print()

“Print” - Execute a print job Execute a print job

Parameter

nametyperequiredescription
tokenstringaccess token
namestringdeliverable name
printerstringPDF
sourcestringdata type
defaultFormstringform file path
dataobjectCSV data
timeoutnumbertimeout time (seconds)
resourceobject[]resource data
passwordstringpassword
pdfPermPassstringauthorization password
pdfPermPrintstringPDF printing permission
pdfPermModifystringPDF change permission
pdfPermCopybooleanPDF copy permission
redirectbooleanredirect action
useEudcbooleanuse of EUDC
adjuststringrepositioning
defaultSvfEncodestringdefault SVF encoding

Tips

Tips

Parameter Supplemental Explanation

[data]

Type object
Properties
name type require description
name string Title
csvString string CSV String Data
csvFile string CSV File
Supplementary explanation - Either csvString/csvFileis required (csvString takes precedence if both are specified)
- If multibyte characters are used for name, UTF-8 encoding is required.
Code Example data: {
name: "...",
csvString: "........"
// csvFile: "........"
}

[Resource]

Type object[]
Properties
name type require description
path string Path written in CSV
realpath string Path to the actual file
Supplementary explanation - Multiple resources can be specified
- Limitations of "resource" parameter
- Maximum file size of one image is 5 MB.
- The total file size of images specified in the "resource" property is limited to 10 MB.
Code Example resource: [
{
path: "....",
realpath: "......"
},
{
path: "....",
realpath: "......"
},
]

Return value

nametypedescription
artifactIdstringdeliverable ID
actionIdstringaction ID
ticketstringone-time ticket

Tips

Sample

[Action]

const csvdata =
"ID,NAME,AMOUNT" + "\r\n" +
"00001,Kant,150000" + "\r\n" +
"00002,Heidegger,200000";
const results = await $fn.svf.artifacts.print({
token: "fa074d728eef1bfb1da897de1f64b53dae7857e87dd0b8b96d9f65e06da43e9f",
name: "Invoice",
printer: "PDF",
source: "CSV",
defaultForm: "form/Sales/invoice.xml",
data: {
name: "Invoice",
csvString: csvdata
}
});

[Return value]

{
artifactId: "411e2d3e-60c2-4f0d-9298-87e49b565b09",
actionId: "0afc1417-e564-4274-b224-49aeed29e3b2",
ticket: "18b2b4526cf8d3f7a6ecb1d23fed49f9602ab0d86acc272a7d49d52498cce33f"
}

$fn.svf.artifacts.info()

“Print” - Retrieve artifact information

Parameter

nametyperequiredescription
tokenstringaccess token
artifactIdstringdeliverable ID

Tips

Return value

Returns in JavaScript object format according to “Retrieve artifact information – Response”.

Tips

Sample

[Action]

const results = await $fn.svf.artifacts.info({
token: "fa074d728eef1bfb1da897de1f64b53dae7857e87dd0b8b96d9f65e06da43e9f",
artifactId: "411e2d3e-60c2-4f0d-9298-87e49b565b09"
});

$fn.svf.artifacts.download()

“Print” - Download artifacts

Parameter

nametyperequiredescription
tokenstringaccess token
artifactIdstringdeliverable ID
actionIdstringaction ID
ticketstringone-time ticket
filestringoutput file
timeoutnumbertimeout time (seconds)

Tips

Return value

None

Sample

[Action]

await $fn.svf.artifacts.download({
token: "fa074d728eef1bfb1da897de1f64b53dae7857e87dd0b8b96d9f65e06da43e9f",
artifactId: "411e2d3e-60c2-4f0d-9298-87e49b565b09"
actionId: "0afc1417-e564-4274-b224-49aeed29e3b2",
ticket: "18b2b4526cf8d3f7a6ecb1d23fed49f9602ab0d86acc272a7d49d52498cce33f",
file: "/sales/2022_06.pdf",
timeout: 60
});

$fn.svf.actions.status()

“Print status” - Retrieve the print status

Parameter

nametyperequiredescription
tokenstringaccess token
actionIdstringaction id

Tips

Return value

Return in JavaScript object format according to retrieve the print status – response

Tips

Sample

[Action]

const results = await $fn.svf.actions.status({
token: "fa074d728eef1bfb1da897de1f64b53dae7857e87dd0b8b96d9f65e06da43e9f",
actionId: "c31806dc-5f08-4aef-ab44-b03ce4a7a3a5"
});