About Me

About Me
Working with SOA technologies , implementing solution using IBM BPM , IBM Integration Designer,IBM WODM and IBM DataPower

About me

View Mahesh Dondeti's profile on LinkedIn

upcoming posts on IBM Bluemix,Devops,Worklight,Node js.

Sunday, 19 October 2014

How to change EPV and ENV values using JavaScript in BPMV8.5





 How to change  EPV and ENV values using JavaScript in BPMV8.5

Exposed Process Values (EPVs):-

Consider a business process that utilizes some business data value such as the current taxrate or the interest rate on loans. This value is obviously not a constant as it may change over time. What we want is a way to supply such values to processes while at the same time making them easy to modify as needed. The concept of Exposed Processes Values (EPVs) is the IBPM solution.An EPV is a named container that holds one or more variables where the values of those variables can be defined through the Process Administration console.
An EPV is defined within a Process Application or Toolkit from the Data catalog in the library

Environment Variables:-
Instead of hard-coding values in a process, we may wish to externalize these values and re-use them across our solution. IBPM PD allows us to define environment variables in either Process Applications or in Toolkits. Once defined in there, they can then be referenced in the solution

To change EPV values at run time  we have two ways
·        Change  EPV  values  using mange epv  Admin tool in Process Admin console.
·        Change  EPV  values  using Java script.


Change EPV  values  using Java script :-

  1. Create a simple epv with name TestEmail. 
  2. Create a simple human service  to test epvs.
  3. Create the  required variables and link EPV to use  in Human service.
  4. Take server script in Human service and add below code  to set values  to epv.

                     //Assing current date to  tempdate varaible
                       tw.local.tempdate=new TWDate();
                    //set 22 minutes to tempdate(i.e current date )
                       tw.local.tempdate.setMinutes(9);
                   //update epv vaule which can effect on 22nd minute of current day and hour
                      tw.epv.TestEmail.email.update("b@gmail.com",tw.local.tempdate);
                      tw.local.tempdate.setMinutes(28);
                  //update epv vaule which can effect on 28th minute of current day and hour
                      tw.epv.TestEmail.email.update("c@gmail.com",tw.local.tempdate);
                      tw.local.tempdate.setMinutes(30);
                 //update epv vaule which can effect on 30 minute of current day and hour
                      tw.epv.TestEmail.email.update("d@gmail.com",tw.local.tempdate);
                 //Update epv with custom date
                     tw.epv.TestEmail.email.update("e@gmail.com",new TWDate("2015-10-19 11:01:00.0"));

                   
                     //Get epv value at specified time
                     tw.local.test1=String(tw.epv.TestEmail.email.valueAt(newTWDate("2015-10-19 11:30:00.0")));


4.     Create a coach to display values.
5.     Test Human service and verify results  .









Note:-BPMv7.5.0   need install fix to work with above code


Change EPV  values  using Process Admin console :-


Change ENV  values  using JavaScript :-

  • Create  a ENV with name testEnv  at process app setting .
  • Give Default,Developement..etc values .
  • Use below code to change ENV value using java script.

tw.env.update(tw.system.model.env.testEnv, "USA");



I am so thankful to  my friend, who given me this scenario.



Saturday, 18 October 2014

How to filter users in a team using “Team Filter Service” in BPMv8.5.x.



Scenario:

How to filter users in a team using “Team Filter Service” in BPMv8.5.x.


LoanReviewBPD:-
 

Loan Review BPD process loan application submitted by application by sending it to review officer.”LoanApproveOfficers” lane was assigned Team1 which contains reviewers list. Here condition is “Loan Application Reviewer1” and “LoanApplicationReviewer2” task  have to perform by different users

In our example Team1 contains “User1”,User2” and”Admin” users, If  Loan Application Reviewer1 task completed   by “user 1 “, LoanApplicationReviewer2 task have to performed by either “User2” or ”Admin”




Creation Of  Team Filter Service:-
                
·         Create an integration service by  choosing template as “TeamFilterService”
·         Add  input variable called “userfilter” to filter team  based on the user.
·         Add server script to service add below code .

var origTeam = tw.system.org.findTeamByName(tw.local.originalTeam.name);
                 var allUsers = origTeam.allUsers;
                
                 // compute result team members
                 log.info("************Last Completed User ****"+tw.local.userFilter);
                 var resultTeam = new tw.object.Team();
                 resultTeam.members = new tw.object.listOf.String();
                 var userCount = 0;
                 for(var i=0; i<allUsers.length; i++) {
                     var user = allUsers[i].name;
                     if (tw.local.userFilter != user) {
                     log.info("Added Users %%%%%%%%%%%%%%% "+i+"   "+user);
                         resultTeam.members[userCount++] = user;
                     }
                 }
                
                 // set the result
                 tw.local.filteredTeam = resultTeam;


Add above filter team service to  User task 2 (Loan reviewer 2)  and map  “tw.local.lastuser”  contains user who completed last task  which we passed input to filter team service
 As shown below .









Get last user information by  using ” tw.system.user_loginname” in Human Service of User Task1 and pass it bpd variable “tw.local.lastuser”