Thursday, 1 August 2013

Teamcenter Unified Architecture Workflow Action Handler Registration for the Task

Action Handler :
Action Handler is ITK program written to customize the task action.

Suppose we want to get some of the information from the particular task, when that task is executed in workflow in such case we register our Handler(ITK program) with the task in workflow designer. Handler will get called when task is executed. As a beginner it is difficult to write task handler , so I thought to present you with simple example of writing Action Handler. We will write Custom exit for the Handler program.

Description of Function is written as comment just above the functions .

//Call back function which is executed when library is loaded by teamcenter 
//In below function simple_custom_handlers  function is register to execute when
//library is loaded .
 extern DLLAPI int tata_register_callbacks()
{
     CUSTOM_register_exit("tata","USER_gs_shell_init_module",(CUSTOM_EXIT_ftn_t)simple_custom_handlers);
     printf("\nTata custom ets_Test_Workflow registering");
     JOURNAL_comment ("Tata custom ets_Test_Workflow registering");
         return ( ITK_ok );
}
//This function is executed from tata_register_callbacks() function above on library load
extern DLLAPI int simple_custom_handlers( int *decision , va_list args)
{
        int retcode = ITK_ok;
        retcode = ActionHandler_register_action_handlers();
        *decision  = ALL_CUSTOMIZATIONS;
        args = NULL;
        return retcode;
}
//This function is executed from simple_custom_handlers(int *decision , va_list args) function   
//above on library load in this function we have registed our Our Funciton or Handler //(ets_Test_Workflow) using EPM_register_action_handler .
int ActionHandler_register_action_handlers()
{
    int retcode = ITK_ok;
        if ( retcode == ITK_ok )
        {
                retcode = EPM_register_action_handler (
                                                        "ets_Test_Workflow",
                                                        "Description Assigned",
                                                        ets_Test_Workflow
                                                        );
printf("\nTata custom ets_Test_Workflow registering***************************");
        }
        return retcode;
}
//This function is executed at the task where you have registered it 
int ets_Test_Workflow(EPM_action_message_t msg)
{
          tag_t     *attachments      = NULLTAG;
          int n_items =0;   
          tag_t    *item_tags        = NULLTAG;
          int  noAttachment =0,t=0,R=0;
          tag_t    rootTask  = NULLTAG;
          char    *inTask    = NULL;
          int ifail =0;
          printf("\nets_Test_Workflow\n");
      /* ifail=(WSOM_find("eTS",&n_items,&item_tags));
          printf("\n  item %d \n",n_items);*/
          ifail=(EPM_ask_root_task(msg.task,&rootTask));      
          AOM_ask_value_string(msg.task,"object_name",&inTask) ;
          printf("\nInput Task Name:%s\n",inTask);fflush(stdout);
          ifail=(EPM_ask_attachments(rootTask,EPM_target_attachment,&noAttachment,&  attachments));     
     printf("Target Attachment:%d\n",noAttachment);
        return 0;
}

How to Compile :
Set MSDEV_HOME Variable if you have not done it before or set it as environment variable
1) Set MSDEV_HOME=c:\Program Files (x86)\Microsoft Visual Studio 8\VC
2) compile -DIPLIB=none eTs_Workflow.c
3) link_custom_exits tata

{Note: Parameter for link_custom_exits is library name/sitename}

Handler is written and library is generated ,to make it available in Handler pane for registration with task please refer my previous article of Teamcenter Unified Architecture Register Custom exit

WorkFlow Designer :
Now we will use workflow designer to attach Handler to Task. I am considering here that you have created a simple workflow using workflow designer .We will edit the workflow to attach our Action handler to task.

Select Process Template >> select edit mode as shown in snap below :





click ok and Part will get submitted to life cycle.

Action Handler get executed once task of workflow get executed.

1 comment: