prim80805:API Sample Code to list all Activity Codes that are assigned to a Project.
| Solution ID: prim80805 |
| API Sample Code to list all Activity Codes that are assigned to a Project. |
| Status: Reviewed |
| Version(s): 6.0, 6.1, 6.2, 6.2.1 |
| Problem: | API Sample Code to list all Activity Codes that are assigned to a Project. |
| Fix: | The following sample code will list all Activity Codes that are assigned in a specific project. In this example, it will list all Activity Codes assigned in project ‘APEX’: HashSet set = new HashSet(); BOIterator boiCodeAssignments = elm.loadActivityCodeAssignments(new String[]{“ProjectId”,”ActivityCodeTypeName”}, “ProjectId = ‘APEX’”,null); while (boiCodeAssignments.hasNext()){ ActivityCodeAssignment codeAssignment = (ActivityCodeAssignment)boiCodeAssignments.next(); set.add(codeAssignment.getActivityCodeTypeName()); } Iterator iter = set.iterator(); // Loop through the list of Unique Codes while(iter.hasNext()){ System.out.println(“\t”+ iter.next()); } |
| Fix: | The following sample code will list all projects that contain Activity Code Assignments along with a list of the Activity Codes that are assigned in each project: HashSet hashset = new HashSet(); BOIterator boiActCodeAssignments = elm.loadActivityCodeAssignments(new String[]{“ActivityCodeTypeName”,”ProjectId”}, null, “ProjectId”); ActivityCodeAssignment codeAssignment = (ActivityCodeAssignment)boiActCodeAssignments.next(); if(currentProj == null){ if (currentProj.equals(codeAssignment.getProjectId())==false){ Iterator iter = hashset.iterator(); hashset.add(codeAssignment.getActivityCodeTypeName()); |