Wednesday, 27 September 2017

Teamcenter Model : Real name for object type in BMIDE

How do you find the real name for object type ?

Here we will understand how to find  the real name value from display name value of object type. I came across one use case where client has not provided the real name for object type but we needed it because we were writing the code to cleanup the data but some property has references to it that we need to clear /remove value so we  need to check the type of property( i.e runtime ,reference etc ... ).

Find the real name for object type : "Item Revision" see the highlighted part in snapshot



If you search in BMIDE for Item Revision then you find nothing ... why? because its a display value .
so lets find out its real value and then search in BMIDE :-)

To find the real value you need to know the tcdata location ( when we install Teamcenter we specify the tcdata location which contains model folder ).

Search in model folder the display value using notepad++ software  ctrl + f option .
Please check the snapshot for more detail ...



If you check second last line in the snapshot you find the real value(ItemRevision) for display value(Item Revision).

Another example :



If you check second last line last line in the snapshot you find the real value(FM9_MtrPrtsItemRevision) for display value(Motorparts Item Revision).


Real value and display value is define in the   *_en_US.xml file (star(*) define the template name)
Confirm above statement : To confirm above statement I created one sample project in BMIDE and added one business object as child of Item and provided the display value to it different than actual value  and saved the data model.Then I checked the *_en_US.xml file which actually define the display value and real value , no other file contain this informaton .
Please check the snapshot for more details ...







Thursday, 31 August 2017

NX Utility : ug_import : How to use

How to upload data using ug_import.bat which uses ugmanager_import.exe internally 

If you want to create the structure like below 
assembly1
 |_comp1

using ug_import utility then

1) create assembly1 and comp1 in Teamcenter of required type and note down their item_id
2) You must have  Comp1.prt and assembly1.prt available [I have at  C:\AB\NX_Test\Assembly_Test\ location ]
3) create comp.clone file for uploading of component first
it has field like below

[comp1.prt] .prt for component mentioned in step 2
existing_data=$USE_EXISTING
db_part_no=011167 Item_id for component created in Teamcenter check step 1
!db_part_name=Tooling-Other                             no need its commented line
db_part_rev=A                                           initial revision
db_part_type=MY_MtrPToolingI                           Part type of object you want to create



3) create .clone file for uploading of assembly 
it has field like below

[assembly1.prt] .prt for assembly mentioned in step 2
existing_data=$USE_EXISTING
db_part_no=011168 Item_id for assembly created in Teamcenter check step 1
!db_part_name=Tooling-Other no need its commented line
db_part_rev=A initial revision
db_part_type=MY_MtrPToolingI Part type of object you want to create

[comp1.prt] .prt for component mentioned in step 2
existing_data=$USE_EXISTING
db_part_no=011167 Item_id for component created in Teamcenter check step 1
!db_part_name=Tooling-Other                             no need its commented line
db_part_rev=A                                           initial revision
db_part_type=MY_MtrPToolingI                           Part type of object you want to create


4) execution for component
5) Start TC commond prompt
C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tc_menu>FMVMDEV_FMVMDEV.bat

C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tc_menu>SET TC_ROOT=C:\apps\siemens\te
amcenter\FMVMDEV\tcroot

C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tc_menu>SET TC_DATA=C:\apps\siemens\te
amcenter\FMVMDEV\tcdata

C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tc_menu>C:\apps\siemens\teamcenter\FMV
MDEV\tcdata\tc_profilevars

//First Load the child part
//Start loading child part

C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tc_menu>"C:\eng_apps\siemens\NX10\UGMANAGER\ug_import" -u=infodba -p=infodba -part="C:\AB\NX_Test\Assembly_Test\Comp1.prt" -mapping="C:\AB\NX_Test\Assembly_Test\comp.clone"
-------------------------------------------------------------------

Warning: The utility "ugmanager_import" has been deprecated.

Use the "tcin_import" utility instead.

-------------------------------------------------------------------

******************** NX Import Utility  ********************
Using NX 10
Using assembly load options - Load from directory.
Using supplied mapping file: [C:\AB\NX_Test\Assembly_Test\comp.clone]
Loaded [C:\AB\NX_Test\Assembly_Test\Comp1.prt]
Connecting to the database...
FCC interface version fms.11.1.0.20150425.00.
Loaded implementation library 'C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tccs\lib\FCCClientProxyDllv11064.dll'.
FCC Interface Implementation fms.10.1.5.20160212.00 initialized.
FCC interface version fms.10.1.0.20130514.00.
Loaded implementation library 'C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tccs\lib\FCCClientProxyDllv11064.dll'.
Import parts to database using Teamcenter (UG/Manager mode) V10000.1.0
Connected to the database.

The NX assembly [C:\AB\NX_Test\Assembly_Test\Comp1.prt] comprises [1] parts
Part # 1, [C:\AB\NX_Test\Assembly_Test\Comp1.prt]
          Part number in Teamcenter is [011167/A] in folder [Newstuff]
          Part will be created with type [MY_MtrPToolingI].

Part Name for Part [011167/A] will be changed to "011167"
Part Description for Part [011167/A] will be changed to "Comp1"

Starting Save.............
Saved part [011167/A] successfully.

All parts were successfully saved.

************ UG_IMPORT finished without error ************

C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tc_menu>

6) //Make sure child part is loaded in Teamcenter
7) //Now load the assembly 
 //Start loading the assembly
 C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tc_menu>"C:\eng_apps\siemens\NX10\UGMANAGER\ug_import" -u=infodba -p=infodba -part="C:\AB\NX_Test\Assembly_Test\assembly1.prt" -mapping="C:\AB\NX_Test\Assembly_Test\assy.clone"
-------------------------------------------------------------------

Warning: The utility "ugmanager_import" has been deprecated.

Use the "tcin_import" utility instead.

-------------------------------------------------------------------

******************** NX Import Utility  ********************
Using NX 10
Using assembly load options - Load from directory.
Using supplied mapping file: [C:\AB\NX_Test\Assembly_Test\assy.clone]
Loaded assembly [C:\AB\NX_Test\Assembly_Test\assembly1.prt]
Connecting to the database...
FCC interface version fms.11.1.0.20150425.00.
Loaded implementation library 'C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tccs\lib\FCCClientProxyDllv11064.dll'.
FCC Interface Implementation fms.10.1.5.20160212.00 initialized.
FCC interface version fms.10.1.0.20130514.00.
Loaded implementation library 'C:\apps\siemens\teamcenter\FMVMDEV\tcroot\tccs\lib\FCCClientProxyDllv11064.dll'.
Import parts to database using Teamcenter (UG/Manager mode) V10000.1.0
Connected to the database.

The NX assembly [C:\AB\NX_Test\Assembly_Test\assembly1.prt] comprises [2] parts
Part # 1, [C:\AB\NX_Test\Assembly_Test\assembly1.prt]
          Part number in Teamcenter is [011168/A] in folder [Newstuff]
          Part will be created with type [MY_MtrPToolingI].

Part # 2, [C:\AB\NX_Test\Assembly_Test\Comp1.prt]
          Part number in Teamcenter is [Comp1/A] in folder [Newstuff]
          Part will be created with type [Item].

Creating Comp1/A
Part Description for Part [Comp1/A] will be changed to "Comp1"
Part Name for Part [011168/A] will be changed to "011168"
Part Description for Part [011168/A] will be changed to "assembly1"

Starting Save.............
Saved part [Comp1/A] successfully.
Saved part [011168/A] successfully.

All parts were successfully saved.

************ UG_IMPORT finished without error ************









Thursday, 10 August 2017

Teamcenter Login Issue : ITK_internal_error : Unclassified error/exception:See system log file for possible explanation.

Today, I was trying to execute the batch program to fetch the item .Program was working previously  but it got failed with following exception
 ITK_internal_error:Unclassified error/exception:See system log file for possible explanation.

Then I tried to login using Teamcenter and faced the same error 



So, I checked the syslog file some of the statement was 

Teamcenter Engineering could not connect to the DBMS specified in the
TC_DB_CONNECT environment variable.
This could be because the DBMS is not online or the server
is not accessible from your node.

and 


ITK_init_module_prelogin failed - Teamcenter.CoreModelGeneral.tc at D:\workdir\tc10132x_win64\src\core\tc\infomanager_itk.cxx(1980)

So I tried to login DB using command prompt 
>sqlplus

and provided the user as infodba and it has shown that password has expired so I changed it to same password and it worked.

Note : Before starting Teamcenter close all the TAO window and run genregxml.bat available at location TC_ROOT/portal/registry





Friday, 14 July 2017

Teamcenter License Issue : Pointing to TC License

Problem Statement :Point customer Teamcenter VM to different TC license server

Before finding the solution for that lets visit different kind of error users faces in case of license server issue...

License server which was mentioned in the tc_profilevars.bat was not available so the below errors.







Solution :
To point to license server modify tc_profilevars.bat
edit the value for variable 
SPLM_LICENSE_SERVER = 28000@iporhostnameoflicenseserver

in above line 28000 is default port for license server and after @ you should mention the IP address or host name of license server m/c

if you still face the same error then other reason should be
License server m/c not accessible from the Teamcenter VM or License server is down 




Friday, 12 May 2017

Teamcenter Preference : Project Assignment

User Scenario : User was trying to assign the project to object in Teamcenter (Right Click -> Project->Assign) and he was able to assign it ,but when he checked the object  project property property was empty .

Solution : The issue was solved by editing the TC_Project_Validate_condition' preference value to 1

Preference Description :
TC_Project_Validate_condition default value 0

VALID VALUES

0  The system confirms the user is a privileged member of the
   project before allowing the user to assign/remove objects to/from    a project.

1  The system confirms the user is either a privileged member of
   the project, or that the user has the ASSIGN_TO_PROJECT
   privilege before allowing the user to assign object to a project.
   Likewise, a user must be either a privileged member of              the project, or have the REMOVE_FROM_PROJECT privilege to       remove an object from a project.

2 The system confirms the user is a regular project member and has     the ASSIGN_TO_PROJECT privilege before allowing the user to assign   object to a project. Likewise, a user must have the              REMOVE_FROM_PROJECT privilege to remove an object from a project.

3 The system confirms the user is a privileged member of the project   and that the user has the ASSIGN_TO_PROJECT privilege before      allowing the user to assign object to a project.Likewise, a user     must be a privileged member of the project and have the      REMOVE_FROM_PROJECT privilege to remove an object from a project.



Thursday, 11 May 2017

Teamcenter WorkFlow : Create form and attach to root task

Problem Statement : Create workflow which will create form in Teamcenter and attach it to the root task and display it to user.

Here you will understand how OOTB handler can be used in the workflow for form creation and display...
Please follow the snapshot with details,it will help you to understand workflow and handlers use.




 - Available the workflow for use

 - Visible this workflow for some of user using Template filter



SUBMIT TO WORK FLOW : Create object for which workflow is available (Defined in previous snapshot (Object Type for which workflow will be avialable)).

- Submit object to created workflow
- Select the MY worklist and expand Task to Perform as shown in    snapshot

     
 - Select the task in the worklist and on the right side in viewer  tab you will see workflow process in process view as shown in snapshot

 - Select the form which workflow has created and check


 - You can checkout the form and modify it

 - Complete the task

-----------------------------------------------------------
This section is just for understanding what else you can do
- You can remove the form which you have created and attached .please refer the snapshot for the same(Argument value for handler is Form object class name)


- You can execute ITK code as well from workflow or some shell .Please refer below snapshot for the same


Wednesday, 10 May 2017

Teamcenter Workflow : Glimpse on workflow Important part







Teamcenter Workflow : Use Case

Scenario : Admin user were unable to see the reference attachment for workflow submitted task so that he can open and see the attached file.



We tried changing the 'EPMTask_PseudoFolder' preference Protection Scope value to 'Site' and it worked

Wednesday, 3 May 2017

Teamcenter SOA Client : Use case for BOM creation

Scenario : Create a BoM structure under multiple part revisions already existing in Teamcenter.(eg: Revision A and B already exist in Teamcneter and now creating bom under Revision A and then under revision B and so on )

Details :
We were trying to use the com.teamcenter.services.strong.bom.StructureManagementService API named addOrUpdateChildrenToParentLine.
This API tries to create the BOMView object per revision and hence worked for the first revision however failed for the next revision since the BOMView already existed.

This scenario was working fine in Teamcenter and we figured out that Teamcenter was calling a different API to create the BOM structure.
In the communication monitor we found the api named 'add' under class com.teamcenter.services.strong.structuremanagement.StructureService.


Other Way to handle scenario is to add the existing item bomview object to the CreateBOMWindowsInfo object when you create the BOMWindow.  Then it will not try to create another BOMView at the item level but just use the one provided.

Thursday, 13 April 2017

SOA Client : Open BOM with packed lines

Problem Statement : Get the packed BOMLines for Particular Item Revision ?

Here is the answer:-)...By setting property on bomwindow

Steps to follow...

 i) Open BOM for ItemRevision
    Please refer the link to openBOMWindow
    This will provide you the ArrayList containing the bomwindow and     top bomline.
    BOMWindow bomWindow  =  ArrayList.get(0);
    BOMLine parentLine =  ArrayList.get(1);

 ii) Set property on BOMWindow
VecStruct vecStructPackedBom = new VecStruct();

vecStructPackedBom = new VecStruct();
vecStructPackedBom.stringVec = new String[]{ "true" };
mapOfAttributes.put( "is_packed_by_default",vecStructPackedBom );

ServiceData setProperties = DM_Service.setProperties( new ModelObject[]{bomWindow}, mapOfAttributes );


 iii) Get bomLines
 ModelObject[] arrChildLines  = null;
 DataManagementService datamantService =    DataManagementService.getService(m_tcConn);
 datamantService .getProperties( new ModelObject[] { parentLine }, new String[] { "bl_child_lines" } );

 arrChildLines = parentLine.get_bl_child_lines();

Wednesday, 22 March 2017

Soa Client : Activity Pert Chart

Teamcenter pert chart for activity automatically get create/updated when we create the activities.



When we use code to create the activity objects the activities are not linked.
To link the activity you need to set predecessor for the activity and in turn you create the per chart 

Code section to set the predecessor for the activity is 

Activityfolderinfo     = new MEActivityFolderInfo[1];
Activityfolderinfo[0]    = new MEActivityFolderInfo();
Activityfolderinfo[0].activity  = (MEActivity) meactivityOrFormObject;
Activityfolderinfo[0].predecessors  = new MEActivity[]{ (MEActivity) auditInterface.getPinnedObject( spinkeypredecessoractivity ) };
       
createOrUpdateMEActivityFoldersResponse = dataManagementService.createOrUpdateMEActivityFolders(Activityfolderinfo);

Wednesday, 15 February 2017

Frequent Questions

  • OOTB  Rule handler : (create-status,add-status,set-status,CR-check-item-status,CR-assert-targets-checked-in,disallow-adding-targets,disallow-removing-targets,EPM-attach-related-objects,require-authentication,demote-on-reject)

  • Utility to delete the Workflow created job(Workflow job got hung/corrupted then utility to delete this object) : verify_tasks

  • Export Preference utility:preferences_manager
  • Utility to creates new users, groups, persons, roles, and volumes outside of a Teamcenter session: make_user
  • Utility to export saved queries:import_export_reports
  • Handler to invoke some utility from workflow : invoke-system-action     -system=script 
  • Executes a specific action on a specific task in the workflow process from which the related background process was initiated : invoke-system-action    -system=script 
  • Email send from workflow on completion(Handler to use is):   system     
     eg: system mailx -s "Notification: Task has been approved"    smith /tmp/approval_note.txt
  • clearlocks : Utility to clear the locks in case of dead process
  • Interdependent LOV : You can create an interdependent attachment so that the user is prompted to enter values for each level in a cascading LOV
  • TC_project_validate_conditions:Determines how the ASSIGN_TO_PROJECT and REMOVE_FROM_PROJECT Access Manager privileges are validated in conjunction with privileged membership validation.Make it 0 to assign project to object in Teamcenter  
  • Multiple concurrent user session to rich client: To start multiple rich client you need to change activation_mode="NORMAL"  to activation_mode="PER_CLIENT" in the tcserver.xml file. File will be available at location TC_ROOT/iiopservers/. 



Thursday, 9 February 2017

Teamcenter SOA Service : Expand BOM

Problem Statement : Given top bom line, you need to expand and store all of it's child line in HashMap.

Answer is ...Checkout the below code


Load property by default when object loaded.Get the item_id against which we store the bom line
SessionService sessionService = SessionService.getService( connection );

//Set Property Policy to get the required property as default

ObjectPropertyPolicy objectpropertypolicy = new ObjectPropertyPolicy();
PolicyType policytype = new PolicyType( "BOMLine", new String []    { "bl_item_item_id" } );
objectpropertypolicy.addType(policytype );

sessionService.setObjectPropertyPolicy(objectpropertypolicy);


Expand the topline and get all child lines
StructureManagementService structureManagementService = StructureManagementService.getService(connection);

com.teamcenter.services.strong.cad._2008_06.StructureManagement.ExpandPSAllLevelsInfo info = new com.teamcenter.services.strong.cad._2008_06.StructureManagement.ExpandPSAllLevelsInfo();


info.parentBomLines = new BOMLine[]{ (BOMLine) topline };
info.excludeFilter = "None2";

com.teamcenter.services.strong.cad._2008_06.StructureManagement.ExpandPSAllLevelsPref pref = new com.teamcenter.services.strong.cad._2008_06.StructureManagement.ExpandPSAllLevelsPref();

ExpandPSAllLevelsResponse2 expandPSAllLevelsResponse = structureManagementService.expandPSAllLevels(info, pref);

for (int i = 0; i < expandPSAllLevelsResponse.output.length; i++) 
{

  try 
  {

 BOMLine childline = expandPSAllLevelsResponse.output[i].parent.bomLine;
           hmstructureLine.put( childline.get_bl_item_item_id(), childline );
   
   catch (NotLoadedException e) 
   {
 StringBuilder sErrorMessage = new StringBuilder();

   sErrorMessage.append( "Exception occurred while fetching the item id for loaded structure. " );

throw new Exception( sErrorMessage.toString() );
   }

}

Important thing above is info.excludeFilter = "None2";
if you see help document it has mention about using 'None' but it won't work (Error : Invalid enum value)

If you  check service reference guide it has mentioned 'None2' value for BOMLineFilter2

Wednesday, 11 January 2017

Teamcenter SOA Service : WorkFlow Submit And Complete with Form Attribute Modifcation

Problem statement :

1) Initiate the workflow 
2) Interact with workflow to provide the input
3) Complete the workflow
At the end of this section you will be able to deal with workflow related activities in Teamcenter

Visual of what we wanted through code ...


String item_uid="E_Sh3sWzY95QJC#ABSEP#EuRh3sWzY95QJC#ABSEP#01fh3sWzY95QJC#ABSEP#0lUh3sWzY95QJC";
String[] arrObjectUID = item_uid.split("#ABSEP#"); int[] arrTypes = new int[arrObjectUID.length]; Arrays.fill(arrTypes, 1); arrTypes[arrObjectUID.length-1]=3;//Reference Attachement //One to One Relation between attachment and attachment types //attachment type=1 //Target attachmetn //attachment type=3 //Reference attachment //Above statement says that last object defined in the item_uid string is attached in the workflow as //reference attachment WorkflowService wfService = WorkflowService.getService(connection); if(wfService==null) { System.out.println("Unable to find WorkflowService.please try again"); } //DataManagementService smService = DataManagementService.getService(connection); for(int i=0;i<arrObjectUID.length;i++) {   System.out.println("arrObjectUID["+i+"]="+arrObjectUID[i]); } for(int i=0;i<arrTypes.length;i++) {   System.out.println("arrTypes["+i+"]="+arrTypes[i]); } ContextData contextData = new ContextData(); contextData.attachmentCount = arrObjectUID.length; contextData.attachments = arrObjectUID; contextData.attachmentTypes = arrTypes; contextData.processTemplate = "Create XYZ Report";//"Simple Release"; System.out.println("Context data initialized"); InstanceInfo instanceResponse = wfService.createInstance(true, null, "TestGENERATION", null,"GENERATION DESC", contextData); if(instanceResponse.serviceData.sizeOfPartialErrors() == 0) System.out.println("Process created Successfully"); else {   System.out.println("Error :"+instanceResponse.serviceData.getPartialError(0).getMessages());   System.out.println("Error :"+instanceResponse.serviceData.getPartialError(0).getErrorValues()); } ModelObject taskobject=instanceResponse.serviceData.getCreatedObject(0); System.out.println("Task Object = "+taskobject.getClass()); DataManagementService dmServiceTI = DataManagementService.getService(connection); Folder userinbox; try { String[] attributes = { "contents","object_name" }; userinbox = (Folder)user.get_userinbox();//Get Inbox for User dmServiceTI.getProperties( new ModelObject[]{ userinbox }, attributes ); //userinbox.get_contents(); System.out.println("userinbox = "+userinbox); System.out.println("userinbox = "+userinbox.get_object_name()); WorkspaceObject[] contents = null; WorkspaceObject UserInboxFolderList[]=null; WorkspaceObject[] tasks_to_perform=null; EPMTask epmtasks[]=null; ModelObject targetattachment[]=null; ModelObject referenceattachment[]=null;  contents = userinbox.get_contents();//Get the Actual Inbox for user which we see in My Worklist dmServiceTI.getProperties( contents, attributes ); for ( WorkspaceObject folder : contents ) { System.out.println("Folder Name = " +folder.get_object_name()); System.out.println("Folder Name = " +folder.getClass()); TaskInbox taskinbox = ( TaskInbox )folder; dmServiceTI.getProperties( new ModelObject[] { taskinbox }, new String[]{ "tasks_to_perform" } ); tasks_to_perform = taskinbox.get_tasks_to_perform(); EPMDoTask dotask=(EPMDoTask) tasks_to_perform[0]; dmServiceTI.getProperties( new ModelObject[]{dotask}, new String[]{ "root_target_attachments" } ); targetattachment = dotask.get_root_target_attachments(); for( ModelObject attachment : targetattachment ) { if ( attachment instanceof Form ) { HashMap hmformupdateattr = new HashMap(); hmformupdateattr.put("rr_report_type", new String[]{ "RR Technical Instruction (PDF)" } ); FormInfo[] inputsTIGenForm = new FormInfo[1]; inputsTIGenForm[0] = new FormInfo(); inputsTIGenForm[0].formObject = attachment; inputsTIGenForm[0].attributesMap = hmformupdateattr; inputsTIGenForm[0].saveDB = true; inputsTIGenForm[0].formType = "RR_CMEReports_Form"; CreateOrUpdateFormsResponse response = dmServiceTI.createOrUpdateForms(inputsTIGenForm); processServiceDataForPartialErrors(response.serviceData); try { wfService.performAction(dotask , "SOA_EPM_complete_action" , ""  , null , "SOA_EPM_completed" , null ); } catch (ServiceException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } } catch (NotLoadedException e1) { e1.printStackTrace(); }
ANOTHER WAY

SessionService service2 = SessionService.getService( connection );

ObjectPropertyPolicy objPropPolicy = new ObjectPropertyPolicy();
PolicyType policyType = new PolicyType( "EPMTask", new String[]{ "real_state", "object_name", "parent_task" } );
objPropPolicy.addType( policyType );
service2.setObjectPropertyPolicy( objPropPolicy );

DataManagementService dmServiceTI = DataManagementService.getService(connection);
ModelObject targetattachment[]=null;

System.out.println("Inside submit_to_workflow");
String item_uid="E_Sh3sWzY95QJC#ABSEP#EuRh3sWzY95QJC#ABSEP#01fh3sWzY95QJC#ABSEP#0lUh3sWzY95QJC";

String[] arrObjectUID = item_uid.split("#ABSEP#");
int[] arrTypes = new int[arrObjectUID.length];
Arrays.fill(arrTypes, 1);
arrTypes[arrObjectUID.length-1] = 3;//Reference Attachement
WorkflowService wfService = WorkflowService.getService(connection);

if(wfService==null)
{
  System.out.println("Unable to find WorkflowService.please try again");
}
//DataManagementService smService = DataManagementService.getService(connection);
for(int i=0;i<arrObjectUID.length;i++)
{
   System.out.println("arrObjectUID["+i+"]="+arrObjectUID[i]);
}
for(int i=0;i<arrTypes.length;i++)
{
   System.out.println("arrTypes["+i+"]="+arrTypes[i]);
}
ContextData contextData = new ContextData();
contextData.attachmentCount = arrObjectUID.length;
contextData.attachments = arrObjectUID;
contextData.attachmentTypes = arrTypes;
contextData.processTemplate = "Create XYZ Report";//"Simple Release";
System.out.println("Context data initialized");
InstanceInfo instanceResponse = wfService.createInstance(true, null, "TestGENERATION", null,"GENERATION DESC", contextData);

EPMTask taskToForward = null;
if(instanceResponse.serviceData.sizeOfPartialErrors() == 0)
{
  System.out.println("Process created Successfully");
  int sizeOfUpdatedObjects = instanceResponse.serviceData.sizeOfUpdatedObjects();
  for (int i = 0; i < sizeOfUpdatedObjects; i++)
  {
     ModelObject updatedObject = instanceResponse.serviceData.getUpdatedObject( i );
     try
     {
      if ( updatedObject instanceof EPMTask )
      {

       String sName = updatedObject.getPropertyObject( "object_name" ).getStringValue();
       String sParent = updatedObject.getPropertyObject( "parent_task" ).getDisplayableValue();

       if ( sName.equalsIgnoreCase( "Select Report Type" )

         && sParent.equalsIgnoreCase( "Select CAPP Report Type for Op" ) )
       {
        taskToForward = (EPMTask) updatedObject;
        System.out.println( "taskToForward.get_real_state() - " + taskToForward.get_real_state() );
        break;
      }
     }
   }
   catch (NotLoadedException e) {

      // TODO Auto-generated catch block

      e.printStackTrace();

  }
 }
}
else
{
       System.out.println("Error :"+instanceResponse.serviceData.getPartialError(0).getMessages());
       System.out.println("Error :"+instanceResponse.serviceData.getPartialError(0).getErrorValues());

}
try
{
    Job wrkjob=(Job) instanceResponse.serviceData.getCreatedObject(0);
    EPMTask root_task=null;
    dmServiceTI.getProperties( new ModelObject[]{wrkjob}, new String[]{ "root_task" } );
    root_task = wrkjob.get_root_task();
    dmServiceTI.getProperties( new ModelObject[]{root_task}, new String[]{ "target_attachments" } );
    targetattachment=root_task.get_target_attachments();

     for( ModelObject attachment : targetattachment )
     {//Here We are going to update the form
      if ( attachment instanceof Form )
      {
       HashMap hmformupdateattr = new HashMap();
       //LOV type attribute
       hmformupdateattr.put("rr_report_type", new String[]{ "RR Technical Instruction (PDF)" } );
       
       FormInfo[] inputsTIGenForm = new FormInfo[1];
       inputsTIGenForm[0] = new FormInfo();
       inputsTIGenForm[0].formObject = attachment;
       inputsTIGenForm[0].attributesMap = hmformupdateattr;
       inputsTIGenForm[0].saveDB = true;
       inputsTIGenForm[0].formType = "RR_CMEReports_Form";

       CreateOrUpdateFormsResponse response = dmServiceTI.createOrUpdateForms(inputsTIGenForm);
       processServiceDataForPartialErrors(response.serviceData);

       //dmServiceTI.refreshObjects( new ModelObject[]{ taskToForward } );
       System.out.println( "taskToForward.get_real_state() - " + taskToForward.get_real_state() );
       //Here we are going to complete the task using api
       ServiceData performAction = wfService.performAction( taskToForward, "SOA_EPM_complete_action" , ""  , null , "SOA_EPM_completed" , null );
       System.out.println( performAction );

      }
     }
 }
 catch (NotLoadedException e2)
 {
   // TODO Auto-generated catch block
   e2.printStackTrace();
  }
  catch (ServiceException e)
  {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }