fill in a filtered list dynamically
- 6 years ago
Hi Mouad
Can you try the below steps and let me know if it works
Step 1: Navigate to Administration --> List
Step 2: Create new list
Step 3: Navigate to Filter Value
Step 4: Fill your list values
Example:
Step 5: Create New JavaScript Method and copy below code
var UpdateListValuesAPI = function() {
var dropdown = getFieldComponentByName('listeone');
var teams = aras.IomInnovator.newItem("ItemType", "get");
teams.setAttribute("select", "id, keyed_name");
teams = teams.apply();
var listOfTeams = [];
for (var i = 0; i < teams.getItemCount(); ++i)
{
var team = teams.getItemByIndex(i);
listOfTeams.push({
label: team.getProperty('keyed_name'),
value: team.getProperty('keyed_name')
});
}
dropdown.component.setState({
list: listOfTeams,
calculatedWidth: '',
value: listOfTeams[0].value
});
};
UpdateListValuesAPI.prototype.updateSecondList = function() {
var selectListValue = document.querySelector("input[name='listeone']").value;
var dropdown2 = getFieldComponentByName('listetwo');
var values = aras.IomInnovator.newItem("Filter Value", "get");
values.setAttribute("select", "label,value");
values.setProperty("filter", selectListValue);
values.setProperty("source_id", "38EEFD3D9AB749478495D437D9919D7D"); // TO BE REPLACED
values = values.apply();
if (values.isError())
{
aras.AlertError(values.getErrorString());
return;
}
else
{
var listTwo = [];
for (var i = 0; i < values.getItemCount(); ++i)
{
var listVal = values.getItemByIndex(i);
listTwo.push({
label: listVal.getProperty('label'),
value: listVal.getProperty('value')
});
}
dropdown2.component.setState({
list: listTwo,
calculatedWidth: '',
value: listTwo[0].value
});
}
};
objUpdateListValuesAPI = new UpdateListValuesAPI();Step 6: Replace Source_ID with ID of the above created list
Step 7: Open Form where your need to use this (example Part Form)
Step 8: Ensure that form has the listeone and listetwo fields
Step 8: Add above method in Form Event --> On Load
Step 9: Create New JavaScript Method and copy below code
objUpdateListValuesAPI.updateSecondList();
Step 10: Add this method in field listetwo --> Field Event --> On Focus
Step 11: Unlock form and test the data
Thank You
Gopikrishnan R