Skip to content

Instantly share code, notes, and snippets.

@cgillis-aras
Last active October 9, 2018 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgillis-aras/5904959bf4ff79e48fd8a5d2ca9a68cb to your computer and use it in GitHub Desktop.
Save cgillis-aras/5904959bf4ff79e48fd8a5d2ca9a68cb to your computer and use it in GitHub Desktop.
Sample code for an onFormPopulated event that dynamically populates an empty dropdown field
// Get the field we want to populate dynamically
var dropdown = getFieldComponentByName('authoring_tool');
/* Construct a filtered list that contains only Microsoft Office authoring tools */
var listItm = aras.IomInnovator.newItem("List", "get");
listItm.setAttribute("select", "id");
listItm.setProperty("name", "Authoring Tools");
var itms = aras.IomInnovator.newItem("Value", "get");
itms.setAttribute("select", "value,label");
itms.setPropertyItem("source_id", listItm);
itms.setProperty("value", "Microsoft%");
itms.setPropertyAttribute("value", "condition", "like");
itms = itms.apply();
// List that will be passed into the dropdown control for typeahead functionality
listOfValues = [{
label: '',
value: ''
}];
// Add an entry to our list for each Office tool
for (var i = 0, itmCount = itms.getItemCount(); i < itmCount; i++) {
var itm = itms.getItemByIndex(i);
listOfValues.push({
label: itm.getProperty("label"),
value: itm.getProperty("value")
});
}
// Pass this list into our dropdown field
dropdown.component.setState({list: listOfValues});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment