Aras Innovator Platform

How to Create a Dynamic List

Use the following code to create and populate a dynamic list:

var listDropdown = getFieldComponentById("{ID}");

//var listDropdown = getFieldComponentByName("{NAME}");

//you can use either getFieldComponentByName or getFieldComponentById to find the list

function addOption(selectbox, txt, val)

{

var options = selectbox.component.state.list

options.push({label: txt, value: val})

selectbox.component.setState({list: options});

}

function removeOption(selectbox, val)

{

var options = selectbox.component.state.list

for (var i = 0; i < options.length; i++) {

if (options[i].value == val) {

options.splice(i, 1)

break;

}

}

selectbox.component.setState

({

list: options

});

}

You can add and remove options using the following:

addOption(listDropdown, “option 1”, “opt-1”);removeOption(listDropdown, “opt-1”);