The below sample code will be helpful in scenarios like below
Child Form Auto Prepopulate Doesn't Work (Doc ID 1672861.1)
Currently in OIM custom pre-pop adapters are not supported on child forms
As a workaround you can use a adapter to add a record in child form on success of "create user" task. This will update the child form as expected.
Let me try to explain what I am doing in the code below
Well, this code adds a dsee group in a child table based on the role to which a user belong.
pKey - Process Instance Key
tcdp - OIM Database Reference available via adapter variable mapping
lookupName - This lookup holds User Role to DSEE Group Mappings
userKey - USR Key
childTableColumName - Child Table Column Name
package com.dubey.deepak.oim.dsee.provisioning; import Thor.API.Operations.tcFormInstanceOperationsIntf; import Thor.API.Operations.tcLookupOperationsIntf; import Thor.API.Operations.tcUserOperationsIntf; import Thor.API.tcResultSet; import Thor.API.tcUtilityFactory; import com.thortech.util.logging.Logger; import com.thortech.xl.dataaccess.tcDataProvider; import java.util.HashMap; import java.util.Map; public class AddChildData {
public AddChildData() { } public String AddProcessChildData(long pKey, tcDataProvider tcdp, String lookupName, long userKey, String childTableColumName) throws Exception { String result = "false"; try { tcUserOperationsIntf userOp = (tcUserOperationsIntf) tcUtilityFactory .getUtility(tcdp, "Thor.API.Operations.tcUserOperationsIntf"); Thor.API.tcResultSet groupResults = userOp.getGroups(userKey); for (int i = 0; i < groupResults.getRowCount(); i++) { groupResults.goToRow(i); String roleName = groupResults .getStringValue("Groups.Group Name"); System.out.println("roleName--->" + roleName); tcLookupOperationsIntf lookupOp = (tcLookupOperationsIntf) tcUtilityFactory .getUtility(tcdp, "Thor.API.Operations.tcLookupOperationsIntf"); tcResultSet lookupRes = lookupOp.getLookupValues(lookupName); for (int j = 0; j < lookupRes.getRowCount(); j++) { lookupRes.goToRow(j); String CodeKey = lookupRes .getStringValue( "Lookup Definition.Lookup Code Information.Code Key") .trim(); if (CodeKey.equalsIgnoreCase(roleName)) { String groupName = lookupRes .getStringValue( "Lookup Definition.Lookup Code Information.Decode") .trim(); System.out.println("groupName----->" + groupName); tcFormInstanceOperationsIntf formOp = (tcFormInstanceOperationsIntf) tcUtilityFactory .getUtility(tcdp, "Thor.API.Operations.tcFormInstanceOperationsIntf"); tcResultSet childFormDef = formOp .getChildFormDefinition(formOp .getProcessFormDefinitionKey(pKey), formOp.getProcessFormVersion(pKey)); long childKey = childFormDef .getLongValue("Structure Utility.Child Tables.Child Key"); Map attrChildData = new HashMap(); attrChildData.put(childTableColumName, groupName); formOp.addProcessFormChildData(childKey, pKey, attrChildData); result = "true"; } } } } catch (Exception e) { System.out.println("exception ---->" + e.getMessage()); e.printStackTrace(); } return result; } }
This can be hooked to a dependent task like below
Create a Task and add a dependent task on it which will trigger this