Tuesday, 14 April 2015

Create Work item through existing Workflow (Process Engine API)

//Create Work item through existing Workflow (Process Engine API)


public VWCreateLiveWOResult[] createLiveWorkObject( java.lang.String[] fieldNames, 
java.lang.Object[] fieldValues, 
java.lang.String workflowIdentifier, 
int numberToCreate) 
throws VWException

will creates (initializes, saves, and dispatches) work items from a transferred workflow definition, specified by its workflow identifier. Multiple work classes on one roster are supported

fieldNames - A String array containing the names of the fields to update in the new work items, in the same order that the values for those fields are supplied in the fieldValues parameter.

fieldValues - An array of Objects whose values are supplied, in order, to the fields named in the fieldNames parameter. 

workflowIdentifier - The workflow definition name (work class name) as returned by VWWorkflowDefinition.getName method, or the workflow version (version property) as returned by VWTransferResult.getVersion. You can get a VWTransferResult object using the transfer method. If a translation source exists, the authored work class name is translated.

numberToCreate - An integer for the number of work items to create. 


try {
      String[] myWorkObjectNumbers = (String[])null;
      String[] myRosterNames = (String[])null;

      VWCreateLiveWOResult[] createWORes = this.peSession
        .createLiveWorkObject(myFieldNames, myLaunchValues, myWorkflowName, 1);

      if (createWORes[0].success())
      {
        myWorkObjectNumbers = new String[createWORes.length];
        myRosterNames = new String[createWORes.length];
        for (int i = 0; i < createWORes.length; i++) {
          myWorkObjectNumbers[i] =
            createWORes[i].getWorkObjectNumber();
          log.info("New workflow with Wob Number [" +
            myWorkObjectNumbers[i] +
            "] launched successfully");
          myRosterNames[i] = createWORes[i].getRosterName();
          log.debug("Workflow Roster Name is [" + myRosterNames[i] +
            "]");
        }

      }

    }
    catch (Exception ex)
    {
      log.error("Exception occured while launching workflow:" +
        ex.getMessage(), ex);
      throw ex;
    }

  






Sunday, 12 April 2015

JavaScript for Dynamic in-basket Filter (Case Manager Scipt)

//JavaScript for Dynamic in-basket Filter based on role and In-basket. 

Script: 

var um = parent.com.ibm.mashups.enabler.model.Factory.getUserModel();                                                        
var dfr = um.findCurrentUser();                                                         
var currentUserObj = dfr.start();                                                        
var currUser = currentUserObj.getDisplayName();                                         
var currRole =  ecmwdgt.getBean("spaceConfig").getEffectiveRole();                
fmsCurrInbasket = payload.currentInbasket ;
console.log('currUser = '+currUser+"  currRole="+currRole + "  Inbasket="+payload.currentInbasket);

if (currRole=='Employee' && payload.currentInbasket=='My Work')
 {
 console.log("inside Requestor if loop "); 
    console.log("Current User" + currUser);
 var filter= {                    
    "queueName":payload.queueName,                    
    "inbasketName":payload.currentInbasket,                    
    "hideFilterUI":false,                    
    "filters":[                               
  {                    
   "name": "EmpID",                    
   "value":currUser                     
  },     
  {                    
     "name": "Pointer",                    
     "value":'2'                     
  }
    ]                    
 };                    
    console.log("inside loop: " +filter);               
    return filter;
 }
 
return payload;
   
Wiring:

 



Saturday, 14 March 2015

Example DB2 Stored Procedures for DbExecute step in Work flow

//Example DB2 Stored Procedures for DbExecute step in Work flow

DbExecute system function: Use the DbExecute system function to run a stored procedure in a specified database.

The datatypes must match the types specified in the stored procedure and can be of the following types:
Designer Param Type Oracle Param Type SQL Server Param Type DB2 Param Type
String varchar varchar varchar
Integer number int int
Boolean number bit number
Float number float float
Time date datetime timestamp

DB2 Stored Procedure:

A stored procedure is unusable until it is defined. Use the CREATE PROCEDURE command to do this. You can either use the DB2 command prompt or place the command in a program and compile and run it. If you use the DB2 command prompt, you first connect to the DB2 LUW Server where the stored procedure will be executed. 

Syntax:

CREATE [OR REPLACE] PROCEDURE [qualifier.]<procedure_name>
([<argument_name> IN | OUT | IN OUT <datatype>
                                    [DEFAULT <default>],...])
{IS | AS}
  [<variable_name <datatype> [DEFAULT <default>];],...
BEGIN
  <procedure_body>
[EXCEPTION
  <exception_statements>]
END;
 
Example1: Simple data Insertion into DOC_SCHEEMA.USER_DETAILS table
 
 
 

Note: The order of Parameters and  arguments in the db2 stored procedure must be same.

CREATE PROCEDURE DOC_SCHEEMA.USER_DATA
(
INOUT P_NAME VARCHAR(64),
INOUT P_FIRST_NAME VARCHAR(64),
INOUT P_NUMBER INTEGER,
INOUT P_DATE_OF_JOINING TIMESTAMP,
INOUT P_CASEID INTEGER
)
    LANGUAGE SQL
BEGIN
 INSERT INTO DOC_SCHEEMA.USER_DETAILS(NAME, FIRST_NAME, NUMBER1, DATE_OF_JOINING, CASEID)  VALUES(P_NAME, P_FIRST_NAME, P_NUMBER, P_DATE_OF_JOINING, P_CASEID);
END

  

Example 2: updating status and number1  into DOC_SCHEEMA.CASE_DETAILS table

CREATE PROCEDURE DOC_SCHEEMA.STATUS_UPDATE
(
INOUT P_CASEID INTEGER,
INOUT P_STATUS VARCHAR(64),
INOUT P_NUMBER INTEGER
)
    LANGUAGE SQL
BEGIN
    UPDATE DOC_SCHEEMA.CASE_DETAILS set STATUS = P_STATUS, NUMBER1 = P_NUMBER WHERE CASEID=P_CASEID;
END



Example 3: Update Workflow properties from different db2 tables.

updating Workflow properties name,email_ID, location and phone number based on region and location from different db2 database tables.

CREATE PROCEDURE DOC_SCHEEMA.UPDATE_WORKFLOW_PROPERTIES
(
INOUT P_COUNTRY VARCHAR(64),
INOUT P_REGION VARCHAR(64),
OUT P_NAME VARCHAR(64),
OUT P_EMAIL_ID VARCHAR(64),
OUT P_LOCATION VARCHAR(64),
OUT P_PHONE_NO VARCHAR(64)
)

LANGUAGE SQL
BEGIN

FOR myCursor AS SELECT NAME,EMAIL_ID FROM DOC_SCHEEMA.USER_DETAILS WHERE COUNTRY = P_COUNTRY AND REGION = P_REGION

DO
--updating work flow properties: name and email_id into
SET P_NAME = myCursor.NAME;
SET P_EMAIL_ID = myCursor.EMAIL_ID;

END FOR;
--updating work flow properties: location and phone number

SET P_LOCATION =(SELECT LOCATION FROM DOC_SCHEEMA.LOCATION_DETAILS WHERE COUNTRY = P_COUNTRY AND REGION = P_REGION);
SET P_PHONE_NO =(SELECT PHONE_NO FROM DOC_SCHEEMA.USER_DETAILS WHERE COUNTRY = P_COUNTRY AND REGION = P_REGION);
END