You misunderstood how the datasources work. A datasource allows you to pick ONE of the datasource's returned items on the instantiation screen. It does not allow you to use all returned users as the "shared by" in a group task. Only the user you selected on the instantiation screen will be allowed to take ownership of the group task.The answer to your problem, dumb as it is, is that there's no easy way to accomplish what you want. I've always had to write an external task (PERL or Java) to calculate and set the sharedBy attributes on group tasks, where it can't simply be hardcoded $IW_USER/users/groups.
The WFM doesn't work that way. It only allows you to put "placeholders" in the group task, which must be resolved by the conclusion of the instantiation screen, otherwise you get an invalid jobspec. Those placeholders can't take multiple values either, so unless you know the exact number of users you're going to need (to put the same amount of placeholders), it's not happening.You choices boil down to external task, or a PreProcessor class (which, IMO, is a worse option).
External Task: I can do that but my question is : what would be the value(s) of the sharedBy variable that I need to set, or how to calculate and set the sharedBy attributes on group tasks. Could you share how to do that or a Snippet of code would really be appreciated
Quickest way is to just convert your Datasource to a URLExternalTask, simply by changing the interface you're implementing and modifying the method signature as required. Then, resolve the CSGroupTask you want to modify, clear out any existing sharedBy value and reset using the List or Set of users that your datasource was previously returning.
WFMGroupTask wfmGroupTask = null;try { CSTask[] tasks = workflowEngine.getTask(task.getId()).getWorkflow().getTasks(); for (int i = 0; i < tasks.length; i++) { log.debug( " Task Name : " + tasks.getName()); if(tasks.getName().equals("Approver Group Task")){ // Here I want to cast my task into WFMGroupTask wfmGroupTask = (WFMGroupTask) tasks; } }}catch (CSException cse) { log.error(cse.getMessage());}
Those are two completely different APIs and you can't cast between the two. You do want CSGroupTask, which has methods: addUser(), addGroup(), getSharedByUsers(), getSharedByGroups(), removeUser(), removeGroup(). You might want to check the Javadoc next time iw-home/cssdk/docs/cssdk_doc.jar
I got it working on Friday, but I wanted to thank you for your help.
No prob, HTH. Out of curiosity though, what did you get working? The cast to the other API, or the use of CSGroupTask.addUsers()?