Community
Showing results for 
Search instead for 
Do you mean 
Reply

How do I populate a dropdown with a group lookup

Accepted Solution Solved
Copper Contributor
Posts: 11
Country: United States
Accepted Solution

How do I populate a dropdown with a group lookup

I am trying to create a dropdown (combobox) that has the names of groups as options.

 

I've created the combobox but I don't know what the best way to lookup the groups is. I really just need pointed in the right direction.

 

Here's an outline of what I'm trying to do. I assume I should do this in the OnDropDown method of the combobox.

 

* Lookup all groups satisfying some criteria (say createdate in the last 30 days)

* Add the names of those groups as options to the combobox.

 

Any hints?

 

Thanks,

 

Chad


Accepted Solutions
Solution
Accepted by topic author chad
‎09-25-2015 03:20 AM
Copper Contributor
Posts: 11
Country: United States

Re: How do I populate a dropdown with a group lookup

I think I have it working.

 

 

protected override void OnDropDown(EventArgs e)
{
base.OnClick(e);

ActApplication ActApp = Act.UI.ActApplication.Instance;
ActFramework ActFwk = ActApp.ActFramework;

// Lookup all groups in date range

GroupFieldDescriptor cfd1 = ActFwk.Groups.GetGroupFieldDescriptor("TBL_GROUP.CREATEDATE", true);
SortCriteria[] sCriteria = { new SortCriteria(cfd1, ListSortDirection.Descending) };
GroupList gList;

System.DateTime d1;
System.DateTime d2;

d1 = System.DateTime.Parse("05/01/2009");
d2 = System.DateTime.Parse("05/29/2009");

IFilterCriteria[] oFilterCriteria = { new DateFilterCriteria(cfd1, d1, d2) };
gList = ActFwk.Groups.GetGroups(sCriteria, oFilterCriteria);

// Add each group name to combobox
for (int i = 0; i < gList.Count; i++)
{
this.Items.Add(gList[i].Name);
}
}

 

View solution in original post


All Replies
Copper Contributor
Posts: 5
Country: United States

Re: How do I populate a dropdown with a group lookup

[ Edited ]

Is this for a custom control or an add-on?

 

Does it need to change for every record? If so I would create some sort of loaddata method that you could call whenever your current record changes.

i.e

 

private void LoadData()
{
//Lookup the data you want here
combo1.Items.Clear();
foreach(Item i in LookupGroup)
{
combo1.Items.Add(i);
}
}

 Or something like that.

 

 

Message Edited by DougDiehnelt on 05-28-2009 11:32 AM
Copper Contributor
Posts: 11
Country: United States

Re: How do I populate a dropdown with a group lookup

This is for a custom control. It does not need to change for each record. Using my example, the dropdown will contain all goups created in the last 30 days. So the only time the dropdown items will change is if a new group is created.

 

My concerns are:

- If I create a lookup to populate the dropdown won't that show up as the current lookup when browsing groups?

- Will the lookup be fast enough to populate the dropdown?

 

Thanks for your help, I will test the lookup method for the moment but any other suggestions are welcome.

 

Chad

Solution
Accepted by topic author chad
‎09-25-2015 03:20 AM
Copper Contributor
Posts: 11
Country: United States

Re: How do I populate a dropdown with a group lookup

I think I have it working.

 

 

protected override void OnDropDown(EventArgs e)
{
base.OnClick(e);

ActApplication ActApp = Act.UI.ActApplication.Instance;
ActFramework ActFwk = ActApp.ActFramework;

// Lookup all groups in date range

GroupFieldDescriptor cfd1 = ActFwk.Groups.GetGroupFieldDescriptor("TBL_GROUP.CREATEDATE", true);
SortCriteria[] sCriteria = { new SortCriteria(cfd1, ListSortDirection.Descending) };
GroupList gList;

System.DateTime d1;
System.DateTime d2;

d1 = System.DateTime.Parse("05/01/2009");
d2 = System.DateTime.Parse("05/29/2009");

IFilterCriteria[] oFilterCriteria = { new DateFilterCriteria(cfd1, d1, d2) };
gList = ActFwk.Groups.GetGroups(sCriteria, oFilterCriteria);

// Add each group name to combobox
for (int i = 0; i < gList.Count; i++)
{
this.Items.Add(gList[i].Name);
}
}