Thursday 14 March 2019

OIM API - How to Remove Data From Child Form?

public void removeDataFromChildForm(long processInstanceKey) throws Exception {
String childTableName = "UD_LDAP_ROL";//child table name 
String columnName = "UD_LDAP_ROL_ROLE_NAME";//column name 
String columnValue = "TestRole";//role name which you want to delete
String childTablePrimaryKey = childTableName + "_KEY";

tcFormInstanceOperationsIntf formInstanceOperationsIntf = Platform.getService(Thor.API.Operations.tcFormInstanceOperationsIntf.class);

long processFormDefinitionKey = formInstanceOperationsIntf.getProcessFormDefinitionKey(processInstanceKey);
int processParentFormVersion = formInstanceOperationsIntf.getProcessFormVersion(processInstanceKey);
tcResultSet childFormDef = formInstanceOperationsIntf.getChildFormDefinition(processFormDefinitionKey,processParentFormVersion);

for(int k = 0; k < childFormDef.getRowCount(); k++){
childFormDef.goToRow(k);
String childFrmName = childFormDef.getStringValue("Structure Utility.Table Name");
if(childFrmName.equalsIgnoreCase(childTableName)){
long childKey = childFormDef.getLongValue("Structure Utility.Child Tables.Child Key");
tcResultSet childData = formInstanceOperationsIntf.getProcessFormChildData(childKey, processInstanceKey);

for (int i = 0; i < childData.getRowCount(); i++) {
childData.goToRow(i);
String roleName = childData.getStringValue(columnName);

if (roleName.equals(columnValue)) {
long rowKey = childData.getLongValue(childTablePrimaryKey);
formInstanceOperationsIntf.removeProcessFormChildData(childKey, rowKey);
System.out.println("Removed successfully!!!");
}
}
}
}
 }

No comments:

Post a Comment