Saturday, 16 September 2017

OIM API - How to Update Process Form Data using tcFormInstanceOperationsIntf API?


To execute below code you have to add following jars in classpath:


  • commons-logging.jar
  • eclipselink.jar
  • jrf-api.jar
  • oimclient.jar
  • spring.jar
  • wlfullclient.jar

Stand Alone Code:


public class ProcessFormDataOps{
       static OIMClient oimClient = null;
        
        //identity self service details
        String username = "xelsysadm";
        String password = "<password>"; //xelsysadm password
        String t3url = "t3://<hostname>:<port>"; //OIM HostName and Port
        String authwl_location = "<location of authwl.conf file in your local machine>"; //eg. D:\\authwl.conf
        
        public void getOIMConnection() {
            System.out.println("getOIMConnection() : Start");
            //set system properties
            System.setProperty("java.security.auth.login.config", authwl_location);
            System.setProperty("OIM.AppServerType", "wls");
            System.setProperty("APPSERVER_TYPE", "wls");
    
            Hashtable oimenv = new Hashtable();
            oimenv.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
            oimenv.put(OIMClient.JAVA_NAMING_PROVIDER_URL,t3url); 
            oimClient = new OIMClient(oimenv);
            try {
                oimClient.login(username, password.toCharArray());
                System.out.println("Connected");
            } catch (LoginException e) {
                e.printStackTrace();
            }
            System.out.println("getOIMConnection() : End");
        }

      public void updateProcessFormData(long pkey, Map updateProFrmDataMap){
          tcFormInstanceOperationsIntf formInstanceIntf = oimClient.getService(tcFormInstanceOperationsIntf.class);
          try {
        System.out.println("Update Process From Data Map :: " + updateProFrmDataMap);
            formInstanceIntf.setProcessFormData(pkey, updateProFrmDataMap);
            System.out.println("Process form data updated successfully");
          } catch(Exception e){
        e.printStackTrace();
          }
       }
    
    public static void main(String[] args) {
        ProcessFormDataOps processFormDataOps = new ProcessFormDataOps();
        processFormDataOps.connect();
        
        //Process Instance Key
        long proInsKey = 140683; 
        
        //Add all attributes which need to be updated
        Map updateProFrmDataMap = new HashMap();

        //updateProFrmDataMap.put("<Column_Name>", "<Attribute_Value>");
        updateProFrmDataMap.put("UD_ADUSER_FIRSTNAME", "Anand");
        updateProFrmDataMap.put("UD_ADUSER_LASTNAME", "Badal");
        processFormDataOps.updateProcessFormData(proInsKey, updateProFrmDataMap);
    }
}


Happy Learning!!!

1 comment:

  1. Hi Anand,
    Very informative Blog. I am configuring EBS hrms Trusted user with OIM.
    By default user_login is mapped to person_id. As per our organization, Username must be firstname.lastname. I change in Lookup.hrms.trusted.recon user_id to firstname.lastname. It is provisioning the users but with firstname.lastname@xxxx.com. I don't know how it is creating with email address.
    Please help. I have reased SR also but no help.

    ReplyDelete