Last active
October 9, 2018 13:40
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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