Single user is getting added to Job function

I am trying to update the users in a job function. While doing so i am able to add only single user how can i add multiple users:

void addApprover(IUserGroup grp,IBaseScriptObj obj,IDataObject users,IAgileSession session) {
ITable table =grp.getTable(UserGroupConstants.TABLE_JOBFUNCTION)
Iterator it = table.iterator()
IRow row
while (it.hasNext()) {
row = (IRow) it.next()
String rName=row.getCell(2000017205).toString()
if (rName.equals(“Developer”)) {
obj.logMonitor(“Job Name: “+rName )
row.setValue(“UsersUserGroups”, users)

}
}
}

Tried giving IDataObject[] to row.setValue throws invalid parameter

how to add multiple user to a job function using SDK?

Agile User Asked on June 2, 2021 in Agile PLM (v9).
Add Comment
1 Answer(s)

Hi Richard,

Please try this piece of code:

IRow row; IAgileList list;
IUser user1 = (IUser)session.getObject(IUser.OBJECT_TYPE, "userId1");
IUserGroup user2 = (IUserGroup)session.getObject(IUserGroup.OBJECT_TYPE, "userGroupName");
IUserGroup ug = (IUserGroup)session.getObject(IUserGroup.OBJECT_TYPE, "Test_Functional_Team");
for(Object obj : ug.getTable(UserGroupConstants.TABLE_JOBFUNCTION).where("["+UserGroupConstants.ATT_JOB_FUNCTION_NAME+"] In %0", new String[] {"Your_Job_Function"})) {
      row = (IRow)obj;
      list = row.getCell(UserGroupConstants.ATT_JOB_FUNCTION_USERS_USERGROUPS).getAvailableValues();
      list.setSelection(new IDataObject[] {user1, user2});
      row.setValue(UserGroupConstants.ATT_JOB_FUNCTION_USERS_USERGROUPS, list);
}

Just to keep in mind that the users/user groups you’re going to add have the required Job Functions assigned to them (as per the value in the Name column of the row where you are adding them).

Hope this helps.

Regards,
Swagoto

Agile Professional Answered on June 4, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.