Skip to content

Sample

This is a sample action code for SVF Cloud integration.

Download the form with a browser

// Access token acquisition
const elapse_sec = 300;
const exp = Math.trunc(Date.now() / 1000) + elapse_sec;
const { token } = await $fn.svf.oauth2.token({
exp: exp,
sub: "xxxx@api.svfcloud.com",
userName: "John D"
});
// Print data creation/display
await $fn.svf.artifacts.print({
token: token,
name: "Invoice ",
printer: "PDF",
source: "CSV",
defaultForm: "form/Sales/invoice.xml",
// Display on client side
redirect: true,
data: {
name: "Invoice",
// Place CSV data files in a predetermined path in S3
csvFile: "/data/tokyo.csv"
}
});
// ※warning
// If you use redirect,
// token will not be destroyed($fn.svf.oauth2.revoke)

Storing forms in the cloud

// Access token acquisition
const elapse_sec = 300;
const exp = Math.trunc(Date.now() / 1000) + elapse_sec;
const { token } = await $fn.svf.oauth2.token({
exp: exp,
sub: "xxxx@api.svfcloud.com",
userName: "John D"
});
// Printing Data Creation
const { artifactId, actionId, ticket } = await $fn.svf.artifacts.print({
token: token,
name: "Tokyo Sales",
printer: "PDF",
source: "CSV",
defaultForm: "form/Sales/sales.xml",
redirect: false,
data: {
name: "Tokyo Sales",
// Place CSV data files in a predetermined path in S3
csvFile: "/data/tokyo.csv"
}
});
// Save print data to file
await $fn.svf.artifacts.download({
token: token,
artifactId: artifactId,
actionId: actionId,
ticket: ticket,
// Specify destination S3 file path
file: "/pdfs/tokyo.pdf"
});
// Access token destruction
await $fn.svf.oauth2.revoke({ token: token });