Export API
There are cases when your template needs to export some data to external file in a specific format, like CSV, JSON, etc. There's API designed for this purpose.
First, you need to add UserSetting of type ExportFile to the config.userSettings:
config: TemplateConfig = {
// Name and description to display in OpenSubmitter's UI:
name: '....',
description: '...',
// User's settings for OpenSubmitter UI:
userSettings: [
{
type: 'ExportFile',
name: 'outputFile',
title: 'Where to export the data',
value: 'CSV',
fileName: "",
required: false,
uiWidth: 100
}
]
};
Which provides user a setting which looks like this, where user can create a new file and select the output format:
During task execution you then use the postResultToStorage method, where you specify property list and their values. It appends data to a storage in OpenSubmitter's memory.
this.postResultToStorage({
fields: ['server', 'port', 'email', 'login', 'password'],
values: {
'server': task.data.imapServer,
'port': task.data.imapPort,
'email': task.data.email,
'login': task.data.emailLogin,
'password': task.data.emailPassword
}
})
At the end of all task OpenSubmitter exports collected records to the specified file. See the full example in manage-results-example.ts template.