cancel
Showing results for 
Search instead for 
Did you mean: 

How to code and start a Process

zlatan316
Champ on-the-rise
Champ on-the-rise
Hello,

I am trying to write some code which can start a particular process and make it appear under My Instances. Currently I have some code which can iterate through a list of names and allow the process to load a CallActivity which has its own underlying process. However each of these do not appear in My Instances. Below is my code:

   public void execute(DelegateExecution execution) {

      ArrayList<String> clientList = (ArrayList<String>)execution.getVariable("clientList");
      execution.setVariable("clientString", clientList.get(0));
      System.out.println("Setting the Client: " + clientList.get(0));
      
      String currentClientName = clientList.get(0);
      clientList.remove(0);
      
      if(clientList.isEmpty()) {
         execution.setVariable("moreClientsToProcess", false);
         System.out.println("Client List is now empty");
      }
      
      execution.setVariable("clientList", clientList);
   }


And below is a link to my Activiti Flow:
http://s21.postimg.org/xeo5znnbr/BPMNDIAGRAM.png


Does anybody know how I can get the processes to appear in My Instances?

With Regards
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
The 'my instances' page, is based on the 'START_USER_ID_' field in the historic process instance. When starting a normal process, this is retrieved from the AuthenticationUtil. In your code, can you check what the value of AuthenticationUtil.getCurrentUser() is, right befiore the call activity is executed? Chances are, that you're not setting AuthenticationUtil.setCurrentUser() before the actual API-call that causes the sub process to be spawned…

zlatan316
Champ on-the-rise
Champ on-the-rise
Thanks frederik that led me on the right pathSmiley Happy

I actually had to use <code>Authentication.setAuthenticatedUserId("InsetLoggedInNameHere");</code> in order to get them to appear under my login.

frederikherema1
Star Contributor
Star Contributor
Great, glad it's working out for you!