Display DataType Item as Dropdown list in Forms

Hi community,

does somebody knows a way to display the DataType 'Item' like a List dropdown?

I currently modify a change process and want to use a team dropdown instead of the current team item selector. Of course I can define a separate list for my teams and use this one for my dropdown. The selected team from the dropdown could than be used as team_id.

But this would require that my teams are duplicated. I have to maintain teams in the List and the Team ItemType. For teams this still would be ok, but I want to do something similar for Identities. 

Any ideas?

Angela

Parents
  • Hi Chris,

    thanks again for your help! I can confirm that this variant works well. I right now have a nice process that changes the Team drop down based on Impact Matrix changes. The selected team is duplicated to the team_id and set´s a couple of reviewers based on team roles.

    But right now I need an additional list for the teams. Each time when I create a new Item in ItemType Team, I also have to add this one to the List used for the drop down. Is it somehow possible avoid the additional list? For the "team" use case, this solution works very well. But I am also thinking about using drop downs for the reviewers, as we sometimes have two identities for a certain team role. I do not want to build additional (filter) lists just for storing identities. There are too many of them. 

    Angela

Reply
  • Hi Chris,

    thanks again for your help! I can confirm that this variant works well. I right now have a nice process that changes the Team drop down based on Impact Matrix changes. The selected team is duplicated to the team_id and set´s a couple of reviewers based on team roles.

    But right now I need an additional list for the teams. Each time when I create a new Item in ItemType Team, I also have to add this one to the List used for the drop down. Is it somehow possible avoid the additional list? For the "team" use case, this solution works very well. But I am also thinking about using drop downs for the reviewers, as we sometimes have two identities for a certain team role. I do not want to build additional (filter) lists just for storing identities. There are too many of them. 

    Angela

Children
  • Hi Angela,

    Using a JavaScript method like the one outlined in the blog post, you can use any source of data to populate a dropdown. There's no need to duplicate the data inside of a List. For example, the code below populates the dropdown with all of the Team items in the database. The name of the Team is used as the label of an option and the id is used as the value.

    var dropdown = getFieldComponentByName('teams');
    var teams = aras.IomInnovator.newItem("Team", "get");
    teams.setAttribute("select", "id, keyed_name");
    teams = teams.apply();
    // List that will be passed into the dropdown control for typeahead functionality
    listOfTeams = [{
      label: '',
      value: ''
    }];
    // Add an entry to our list for each Team
    for (var i = 0, teamCount = teams.getItemCount(); i < teamCount; i++)
    {
      var team = teams.getItemByIndex(i);
      listOfTeams.push({
        label: team.getProperty("keyed_name"),
        value: team.getProperty("id")
      });
    }
    dropdown.component.setState({list: listOfTeams});

    After a user makes their selection in this dropdown list, you can retrieve the value by using getFieldComponentByName("YOUR_FIELD_NAME").component.state.value;. In this case, because we've set the value of our options to be the ID of the teams, this will return the ID of the selected team.

    Using this approach, the only limit to what can be populated inside of a dropdown is the ability to query for the information. :)


    Chris

    Christopher Gillis

    Aras Labs Software Engineer