Sunday, June 14, 2015

Confirmation Dialog Coach View in IBM BPM

Display of Confirmation dialog is one of the very common use cases in any UI based application in such as "delete" operation, "cancel" operation etc. In this post let us see how to create a coach view which can used to display a confirmation dialog as shown below.

Confirmation Dialog
Figure 1

Steps to Create a Coach View to display Confirmation Dialog

Step 1 : Create a coach view and add the configuration variables as shown in the below figures.

variable section of coach view
Figure 2


Step 2:  Go to Behaviour Tab and add below script in load event handler.

this.confirmation= function(message){ if(this.context.options.isAlert.get("value")){   var r=confirm("Are you sure you want to delete?");
  if(r==true){
  this.context.trigger();
  }
 }
}

Add below script in change event handler.

if(event.type=="config"){
  if(event.property=="change"){
      this.confirmation();
  }
}

The configuration parameters "isAlert" should be made true when the required button (delete button) is clicked upon and increment the integer variable "change" every time delete button is clicked up on so that the change event handler is invoked.

Step 3 :  Now go to overview tab of the coach view and check the option "Can Fire a Boundary Event" as shown in the below figure.

overview tab of coach view
Figure 3



With this we are done with creating coach view.

Now let us see how to use this Coach view in the coach for "Delete" option as in the Figure 1.

Below is the setup of the Human Service with coach.


On click of Delete button in the coach, the variable "isAlert" is set to true and "change" is incremented by 1 in the server script "set flag". These variables are mapped to configuration parameters of the coach view created above, which will display the confirmation dialog.

In the confirmation dialog as shown in the figure 1, if "OK" is clicked up on it will the execute "this.context.trigger()", which make the control flow out of coach via the transaction "confirm Coach view" executing the desired script and if  "cancel" button in the dialog is click up on the control will stay in the coach itself.

Hope this is use full !!!!

Thanks for stopping by. If you like this post leave a comment, share it and do a g +1.



6 comments:

  1. If I m using tw.local.isAlert=true in coach level its showing error as isAlert not defined, please defined it for use, Explaing the steps in Detail, so it will be easy to under stand.

    ReplyDelete
  2. I guess you missed creating a local variable "isAlert" in the Human Service.

    ReplyDelete
  3. actually there is another more straight forward approach to implement this by just binding an click event handler to your button.

    ReplyDelete
  4. Yes I figured that later. There are many ways to do this. More easier approach is, copy the button coach view of coaches toolkit, Add the confirmation dialog script to control the context.trigger() event of the coach view.

    ReplyDelete
  5. Hi Pradeep,

    your tutorials are so nice and i'm very much following your posts.I need a small help.I would like to talk to you for a mintue.Could you please send an email to Venkata.silla4u@gmail.com Please.Thanks and Appreciated.

    ReplyDelete
  6. Hi Pradeep,

    your valuable guidance are very useful to us.Thanks for your knowledge.i would like to ask for your assistance to clarify my doubts on 2 process bcoz i tired very hard to figure it out but i failed....

    1. I'm trying to calculate the total no.of days excluding sat,sun as weekends and Monday is a holiday using server script in Human Service.But i failed to get the correct output means always i got all days including sat,sun and Monday.

    2. I'm unable to populate the values in Selected field(Suppose selecting a value in list and automatically it should be display the particular value of details in the next selected fields) as-well as in Text field also (Suppose selecting a value in list and automatically it should be display the particular value of details in the next text fields)

    my Email-Id:yarambalu@gmail.com....plz do the needy

    ReplyDelete