My scenario here involves two questions. Please go through the below lines:
Basically, let us consider that I have a workflow with 3 Tasks namely T1, T2 and T3. The workflow execution flows from T1-> T2-> T3 → T1.
Q1. Each of the above Tasks saves some data into the bdm. Similarly, if i consider that T1 saves the data A1 into bdm and moves forward to T2 and T3 respectively. Once the T1 task is again initiated[as T3-> T1], any data entered to A1 field would necessarily overwrite the existing bdm data for A1! How can i stop this overwriting to create a new row for storing both the values of A1 in successive iterations.
**Q2.**Supposedly, the A1 data exists for all the iterations, without getting overwritten. I need a solution for finding out the A1 data content for the nth iteration where {n=1 to the present iteration}
Please get back if you need any more clarifications on the questions!
Q1. Each of the above Tasks saves some data into the bdm. Similarly, if i consider that T1 saves the data A1 into bdm and moves forward to T2 and T3 respectively. Once the T1 task is again initiated[as T3-> T1], any data entered to A1 field would necessarily overwrite the existing bdm data for A1! How can i stop this overwriting to create a new row for storing both the values of A1 in successive iterations.
My Solution:
Create a business variable a1 of type A1. In the operations of T1, instantiate a1 using the script
def ob = new A1();
ob.x = …
ob.y = …
return ob;
This would guarantee a new row is created in each iteration
Q2.Supposedly, the A1 data exists for all the iterations, without getting overwritten. I need a solution for finding out the A1 data content for the nth iteration where {n=1 to the present iteration}
My solution:
Create a process variable iterationMap of type Map. In the operations of T1, after a1 is instantiated(as mentioned in the solution for Q1), save the entry into iterationMap with iteration number as the key and the a1.persistenceId as the value. So later you can use iterationMap.get(n) to get the persistence id of the A1 row saved in the nth iteration using a1DAO.findByPersistenceId(iterationMap.get(n))
P.S.: If you find this answer as a solution to your problem, please mark it as solved.
Raji MALLA
Hi rjrjswrdvi,
Thanks for the response… It is really very helpful!
For the second question, where you mentioned:
Create a process variable iterationMap of type Map.
In my pool for creating Process variables, the type of the variable doesnt have any Map type variable. The available variables are Boolean, Object, Long etc…
Where can i create a Map type variable?
Hi Raji,
I understood the context of your answer:
However, i also had a solution and i’m stuck at a point.
With regards to: upposedly, the A1 data exists for all the iterations, without getting overwritten. I need a solution for finding out the A1 data content for the nth iteration where {n=1 to the present iteration}
→ Present Solution: {Groovy script in the Operations section of a task:}
I have a parent table and a child table, the parent table will contain a reference to the child table.
Content of Parent Table: comments
Content of Child Table: comment_text , task_id, task_name, iteration_id
When the workflow runs, values are getting filled in the child table columns {script provided below}, but, if an iteration is encountered, I am not able to figure out how do i increment the value of the iteration_id field.
def commentsList = []
def iteration_id = 1;
// testbv is the initializing business variable.
commentsList.addAll(testbv.comments)
//testbvInput is actually the formInput
testbvInput.comments.each{
//Add a new composed child comments instance
commentsList.add({ currentlcommentsInput ->
def commentsVar = new com.company.model.childcomments()
commentsVar.iteration_id = iteration_id;
commentsVar.comment_text = currentlptmidmcbonfoarcommentsInput.comment_text
commentsVar.task_id = currentlptmidmcbonfoarcommentsInput.task_id
// taskMap = new HashMap<String, String>();
// taskMap.put(lptmidmcbonfoarcommentsVar.iteration_id, lptmidmcbonfoarcommentsVar.comment)
// logger.info(taskMap);
return commentsVar
}(it))
}
return commentsList
In this case, I am appending the existing values of the child table to commenrsList array and appending a new set of child columns. In my case, the iteration_id is statically set to 1. How can i configure it dynamically so that if i encounter the same task id once again {which is basically the same task is repeated in an iterative manner} i can fetch the current iteration id and update{increment} it ?
Any help will be of utmost value!!
Thanks in advance!
This can be achieved using groovy Script.
on the Left hand side select the database and choose instantiate with as function and on right hand side use groovy script to return a set of values.
Each task should would then insert a new row in the BDM .
reagrds
Hello!
You need to select ‘Java Object’ and then click on ‘Browse’ button and type ‘Map’
Regards,
Raji Malla
P.S.: If you find this answer as a solution to your problem, please mark it as solved.