public void modifyAccountProcessFormData() throws Exception {
String userKey = "117507"; //Replace User Key
String resObjName = "LDAP User"; //Replace Resource Object Name
Account userActiveAccount = null;
ProvisioningService provisioningService = Platform.getService(ProvisioningService.class);
SearchCriteria criteria = new SearchCriteria(ProvisioningConstants.AccountSearchAttribute.OBJ_NAME.getId(), resObjName, SearchCriteria.Operator.EQUAL);
List<Account> accounts = provisioningService.getAccountsProvisionedToUser(userKey, criteria, null, true);
for(Account account : accounts) {
String accountStatus = account.getAccountStatus();
if(ProvisioningConstants.ObjectStatus.PROVISIONED.getId().equals(accountStatus) ||
ProvisioningConstants.ObjectStatus.ENABLED.getId().equals(accountStatus) ||
ProvisioningConstants.ObjectStatus.DISABLED.getId().equals(accountStatus)){
userActiveAccount = account;
break;
}
}
if(null != userActiveAccount){
//Add attributes which need to be modified
HashMap<String, Object> modParentFrmDataMap = new HashMap<String, Object>();
modParentFrmDataMap.put("UD_LDAP_USR_FIRST_NAME", "Anand");
modParentFrmDataMap.put("UD_LDAP_USR_LAST_NAME", "Badal");
String accountId = userActiveAccount.getAccountID();
String processFormInstanceKey = userActiveAccount.getProcessInstanceKey();
Account modAccount = new Account(accountId, processFormInstanceKey, userKey);
String parentFormKey = userActiveAccount.getAccountData().getFormKey();
String udTablePrimaryKey = userActiveAccount.getAccountData().getUdTablePrimaryKey();
AccountData accountData = new AccountData(parentFormKey, udTablePrimaryKey , modParentFrmDataMap);
modAccount.setAccountData(accountData);
modAccount.setAppInstance(userActiveAccount.getAppInstance());
provisioningService.modify(modAccount);
System.out.println("Process form data successfully updated!!!");
}
}
String userKey = "117507"; //Replace User Key
String resObjName = "LDAP User"; //Replace Resource Object Name
Account userActiveAccount = null;
ProvisioningService provisioningService = Platform.getService(ProvisioningService.class);
SearchCriteria criteria = new SearchCriteria(ProvisioningConstants.AccountSearchAttribute.OBJ_NAME.getId(), resObjName, SearchCriteria.Operator.EQUAL);
List<Account> accounts = provisioningService.getAccountsProvisionedToUser(userKey, criteria, null, true);
for(Account account : accounts) {
String accountStatus = account.getAccountStatus();
if(ProvisioningConstants.ObjectStatus.PROVISIONED.getId().equals(accountStatus) ||
ProvisioningConstants.ObjectStatus.ENABLED.getId().equals(accountStatus) ||
ProvisioningConstants.ObjectStatus.DISABLED.getId().equals(accountStatus)){
userActiveAccount = account;
break;
}
}
if(null != userActiveAccount){
//Add attributes which need to be modified
HashMap<String, Object> modParentFrmDataMap = new HashMap<String, Object>();
modParentFrmDataMap.put("UD_LDAP_USR_FIRST_NAME", "Anand");
modParentFrmDataMap.put("UD_LDAP_USR_LAST_NAME", "Badal");
String accountId = userActiveAccount.getAccountID();
String processFormInstanceKey = userActiveAccount.getProcessInstanceKey();
Account modAccount = new Account(accountId, processFormInstanceKey, userKey);
String parentFormKey = userActiveAccount.getAccountData().getFormKey();
String udTablePrimaryKey = userActiveAccount.getAccountData().getUdTablePrimaryKey();
AccountData accountData = new AccountData(parentFormKey, udTablePrimaryKey , modParentFrmDataMap);
modAccount.setAccountData(accountData);
modAccount.setAppInstance(userActiveAccount.getAppInstance());
provisioningService.modify(modAccount);
System.out.println("Process form data successfully updated!!!");
}
}
No comments:
Post a Comment