title: Primavera API create udfcode local mode
body: <p>Knows someone where I can find a sample of adding primavera UDF through API?
  My code is below but nothing happens when I run it.
  I can connect to the database, read the UDF, delete the udf, but not to create</p>
  
  <p>Thank you</p>
  
  <pre><code>package apitest;
  
    import com.primavera.bo.base.u;
    import com.primavera.common.value.ObjectId;
    import com.primavera.integration.client.*;
    import com.primavera.integration.client.Session;
    import com.primavera.integration.client.EnterpriseLoadManager;
    import com.primavera.integration.client.RMIURL;
    import com.primavera.integration.common.DatabaseInstance;
    import com.primavera.integration.client.bo.BOIterator;
    import com.primavera.integration.client.bo.object.Project;
    import com.primavera.integration.client.bo.object.UDFCode;
    import com.primavera.integration.client.bo.InternalBOHelper;
    import com.primavera.integration.client.bo.helper.UDFCodeHelper;
    public class API
    {
  
   public static void main( String[] args )
  {
      System.setProperty("primavera.bootstrap.home","C:\\P6IntegrationAPI_1");
      Session session = null;
      try
      {
          DatabaseInstance[] dbInstances = Session.getDatabaseInstances(
              RMIURL.getRmiUrl( RMIURL.LOCAL_SERVICE ) );
  
          // Assume only one database instance for now, and hardcode the username and
          // password for this sample code
          session = Session.login( RMIURL.getRmiUrl( RMIURL.LOCAL_SERVICE ),
              dbInstances[0].getDatabaseId(), "admin", "admin" );
  
  
          //u.delete(session, (UDFCode)(new String ("High")));
  
          UDFCode u = new UDFCode(session);
  
          u.setCodeValue("cdc");
          u.setDescription("cdcds");    
          u.setObjectId(ObjectId.USESSION_OVERRIDE_ID);
          u.setCodeTypeObjectId(ObjectId.USESSION_OVERRIDE_ID);
          u.setSequenceNumber(0);
  
          u.create();            
  
  
          System.out.println("cdcx");
  
  
      }
      catch ( Exception e )
      {
          System.out.println(e.getCause());
      }
      finally
      {
          if ( session != null )
              session.logout();
      }
  }
  </code></pre>
  
  <p>}</p>