Problem

Using multiapproval [Multiple Approval v2 (Thread safe)] while having forms in both parent and child process. You have 2 different processes while subprocess approve doesnt contain any row in database, so it can't be linked with List inbox only with inbox as in example, which takes data only from SHKAssignmentsTable, without any data from forms.

Motivation

You can simply use INBOX in userview, but this gives absolutely no info to users, I wanted to give them all relevant informations which were provided in apply, while retain opportunity to run actions for both processes from one List.

Solution

1.Create row in DB

Create new tool in process Apply

Using Preset Form Data Tool set ID for Approval Form, which leads to creating row in table with correct process ID (which List inbox uses for pairing with assignments through SHKAssignmentsTable ). Into field ID we assign #assignment.processId#, for Approval Form.




Ignore "Sample Form" it is my application with different names, there should be Form linked to Approval.


2. Store Child ID's

In main Process (Apply) in form Apply add hidden field childIDs so JW creates this column in table.

Add following lines into Generate Approvals Tool. This will save all child process ID's into childIDs column so we can have reference for List inbox.

Connection con = null;
try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jwdb?characterEncoding=UTF-8", "root", "/////////////");
    if (!con.isClosed()) {
        String sql = "UPDATE jwdb.app_fd_multiApproval_applications SET c_childIDs = ? WHERE id = ?";
        PreparedStatement stmt = con.prepareStatement(sql);
        String concated = approvalInstanceIds.substring(0, approvalInstanceIds.length() - 1); //cut out last ","
        stmt.setString(1, concated);
        stmt.setString(2, "#assignment.processId#");
        stmt.execute();
    }
} catch (Exception ex) {
    System.err.println("Exception: " + ex.getMessage());
} finally {
    try {
        if (con != null)
            con.close();
    } catch (SQLException e) {
        System.err.println("Exception: " + ex.getMessage());
    }
} 


3. Create List Inbox 

data binder: Database SQL Query

setup connection to JWDB


Now write your own query to UNION data of this 2 processes.

This is example one which I use.

select
	jwdb.app_fd_multiApproval_approvals.id,NR.dateCreated, NR.dateModified, NR.c_value, NR.c_number, NR.c_doc_org, NR.c_requester_name, NR.c_priority
from
  (select 1 n union all
   select 2 union all select 3 union all
   select 4 union all select 5) numbers  INNER JOIN jwdb.app_fd_multiApproval_applications NR
  on CHAR_LENGTH(NR.c_childIDs)
     -CHAR_LENGTH(REPLACE(NR.c_childIDs, ',', ''))>=numbers.n-1
JOIN jwdb.app_fd_multiApproval_approvals
ON SUBSTRING_INDEX(SUBSTRING_INDEX(NR.c_childIDs, ',', numbers.n), ',', -1) COLLATE utf8_general_ci = jwdb.app_fd_multiApproval_approvals.id 
where c_childIDs != '' and NR.c_requester  is not null
UNION 
select 
	id, dateCreated, dateModified,c_value, c_number, c_doc_org, c_requester_name, c_priority
from jwdb.app_fd_multiApproval_applications 
where  jwdb.app_fd_multiApproval_applications .c_requester  is not null


P.S. I would like to provide my application, but it is quite robust and this is only small part of it, I will try to provide edited Multiple Approval v2 (Thread safe) with List inbox as soon as possible.