@sukhbirsinghkhalsa it's tough to say what you've got wrong here, but this is working for me.
import {
connections,
integrations,
exports,
imports,
flows,
request
} from 'integrator-api'
class Form {
// { fieldMap: {}, layout: { fields: } }
constructor() {
this.fieldMap = {};
this.layout = {};
this.layout.containers = ;
}
fields(...fields) {
this.layout.fields = fields;
}
container(type, label, ...fields) {
this.layout.containers.push({
type: type,
containers: [{
label: label,
fields: fields
}]
});
}
column(label, ...fields) {
this.layout.type = 'column';
this.layout.containers.push({
label: label,
fields: fields
});
}
}
class Field {
constructor(id, name, label, type) {
this.id = id;
this.name = name;
this.label = label;
this.type = type;
}
isRequired() {
this.required = true;
}
removeInvalidValues() {
this.removeInvalidValues = true;
}
canBeDeleted() {
this.showDelete = true;
}
isMultiline() {
this.multiline = true;
}
description(description) {
this.description = description;
}
help(helpText) {
this.helpText = helpText;
}
typeOfInput(type) {
this.inputType = type;
}
default(defaultValue) {
this.defaultValue = defaultValue;
}
delimiter(delimiter) {
this.delimiter = delimiter;
}
keyNamePlaceholder(keyName) {
this.keyName = keyName;
}
valueNamePlaceholder(valueName) {
this.valueName = valueName;
}
mode(mode) {
this.mode = mode;
}
addOption(arg1, arg2) {
if (!this.hasOwnProperty('options')) {
this.options = [{
items: []
}];
}
if (arg2) {
this.options[0].items.push({
label: arg1,
value: arg2
});
} else {
this.options[0].items.push(arg1);
}
}
addStaticMapOptions(keyName, keyLabel, keyOptions, valueName, valueLabel, valueOptions) {
this.keyName = keyName;
this.keyLabel = keyLabel;
this.keyOptions = keyOptions;
this.valueName = valueName;
this.valueLabel = valueLabel;
this.valueOptions = valueOptions;
}
}
function formInit(options) {
let form = new Form();
// reference: https://docs.celigo.com/hc/en-us/articles/360059205112-Common-form-fields
// deconstruct form to make access to fieldMap for prop assignment simpler
let { fieldMap } = form;
//create field for staticMap
fieldMap.errorList = new Field('errorList','errorList','Errors(s)', 'multiselect');
let ioConnectionId = "";
for (let c of options.parentResource.aliases) {
if (c.alias === "io") {
ioConnectionId = c._connectionId;
}
}
let selectOptions = getErrorList(ioConnectionId);
for (let s of selectOptions) {
fieldMap.errorList.addOption(s.label,s.value);
}
fieldMap.errorList.description('Select the errors you want to retry.');
fieldMap.errorList.removeInvalidValues();
//set the layout for the form
form.fields(...['errorList']);
// wrap up by assigning form to options.resource.settingsForm prop; return the form as well
options.resource.settingsForm.form = form;
return form;
}
function getErrorList(integrator_io_http) {
return exports.runVirtual({
“export”: {
“name”: “Get errors”,
“_connectionId”: integrator_io_http,
“asynchronous”: true,
“oneToMany”: false,
“sandbox”: false,
“http”: {
“relativeURI”: “/v1/flows/6526bcdc901c6d2a153973d7/6526bccd901c6d2a153972f9/errors”,
“method”: “GET”,
“formType”: “http”,
“paging”: {
“method”: “url”,
“path”: “nextPageURL”
},
“response”: {
“resourcePath”: “errors”
}
},
“transform”: {
“type”: “expression”,
“expression”: {
“rules”: [
],
“rulesTwoDotZero”: {
“mappings”: [
{
“generate”: “value”,
“dataType”: “string”,
“extract”: “$.errorId”,
“status”: “Active”,
“sourceDataType”: “string”
},
{
“generate”: “label”,
“dataType”: “string”,
“extract”: “$.code”,
“status”: “Active”,
“sourceDataType”: “string”
}
],
“mode”: “create”
},
“version”: “2”
},
“rules”: [
],
“version”: “2”
},
“adaptorType”: “HTTPExport”
}
}).data;
}