# Access Error with custom form script

**URL:** <https://connective.celigo.com/t/access-error-with-custom-form-script/208>\
**Category:** Integrator.io\
**Tags:** script, connection, myapi, error-handling, export\
**Created:** [March 1, 2024, 11:42am UTC](https://connective.celigo.com/t/access-error-with-custom-form-script/208 "2024-03-01T11:42:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sukhbirsinghkhalsa](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@sukhbirsinghkhalsa](https://connective.celigo.com/u/sukhbirsinghkhalsa)\
**Post date:** [March 1, 2024, 11:42am UTC](https://connective.celigo.com/t/access-error-with-custom-form-script/208/1 "2024-03-01T11:42:16Z")

</div>

I'm getting access issue while trying to use export.runVirtual() function in form builder!  
Let me know if any additional data is needed to understand it better, or what should be added on it to make it run?

I'm having a \_connectionId, also it works well with MY API section but not here.

 ![5301043caa20740200000001-fffae3e747c14d9890674ee413592b46.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/b/b239f0c7ec2981c75c8569d5dce30181d0ae2e00.png)

---

<div class="post-metadata">

**Author:** ![sreevaniamara](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/sreevaniamara/32/6926_2.png) [@sreevaniamara](https://connective.celigo.com/u/sreevaniamara)\
**Post date:** [March 1, 2024, 1:19pm UTC](https://connective.celigo.com/t/access-error-with-custom-form-script/208/2 "2024-03-01T13:19:06Z")

</div>

Hi @sukhbirsinghkhalsa,

Please refer to the [document](https://docs.celigo.com/hc/en-us/articles/360059205112-Common-form-fields#type_exportSelect) to use virtual export within a form.

Let us know if you have any further questions!

Thanks.

---

<div class="post-metadata">

**Author:** ![sukhbirsinghkhalsa](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@sukhbirsinghkhalsa](https://connective.celigo.com/u/sukhbirsinghkhalsa)\
**Post date:** [March 1, 2024, 2:05pm UTC](https://connective.celigo.com/t/access-error-with-custom-form-script/208/3 "2024-03-01T14:05:58Z")

</div>

Hey @sreevaniamara Thanks for your comment, I'm in in need to get more than 100 options in my exportSelect

I referred [this](https://connective.celigo.com/t/querying-netsuite-records-in-custom-form-builder-settings/566) one doc, where @tylerlamparter wrote if we want more than 100 we need to go with script path. but I get that access error as I have highlighted in my post.

So, need help to get more than 100 options, if you can please help with access error.

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [March 1, 2024, 2:51pm UTC](https://connective.celigo.com/t/access-error-with-custom-form-script/208/4 "2024-03-01T14:51:46Z")

</div>

@sukhbirsinghkhalsa it's tough to say what you've got wrong here, but this is working for me.

 ![5301043caa20740200000001-a67a2e82a1004c55ad379af97a92eff8.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/a/a98c2eb643efff2a13ba909f988006171f190aba.png)

```
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;

}

```

---

<div class="post-metadata">

**Author:** ![sukhbirsinghkhalsa](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@sukhbirsinghkhalsa](https://connective.celigo.com/u/sukhbirsinghkhalsa)\
**Post date:** [March 1, 2024, 4:22pm UTC](https://connective.celigo.com/t/access-error-with-custom-form-script/208/5 "2024-03-01T16:22:22Z")

</div>

Hey @sreevaniamara and @tylerlamparter, thanks a bunch for your quick input and solutions.

I'm able to see the select dropdown now. The problem was when we click the flow builder button and write a script there it doesn't allowed me to execute it and throws that error and for some reason after saving too it was not displaying the results I'm getting now.

You guys rock, cheers!

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [March 1, 2024, 4:27pm UTC](https://connective.celigo.com/t/access-error-with-custom-form-script/208/6 "2024-03-01T16:27:32Z")

</div>

@sukhbirsinghkhalsa yes you can't preview these scripts when using integrator api calls in them and you need to save it to check if it works. We'll take your feedback to enhance the preview functionality when using integrator apis in scripts.

---

<div class="post-metadata">

**Author:** ![sukhbirsinghkhalsa](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@sukhbirsinghkhalsa](https://connective.celigo.com/u/sukhbirsinghkhalsa)\
**Post date:** [March 2, 2024, 5:19am UTC](https://connective.celigo.com/t/access-error-with-custom-form-script/208/7 "2024-03-02T05:19:04Z")

</div>

@tylerlamparter yes, that will be great if you write it somewhere those areas are restricted and you need to save the script to see the changes in form builder UI. or it can be small thread explaining how to go with forminit() script with video or screenshots.
