START BIZ ACTION

The ACTION tab of the Component Showcase application demonstrates the use of the startBizAction operation from the BPMBusinessActionsService component service.

To view or edit the source files for this example, open the Component Showcase application and browse to the componentDemos/startBizAction folder.

StartBusinessActions.html

The page:

  • displays a form in which you can enter and submit the details of the business action that you want to start.
  • defines an element to be used to display the started business action form.
    <div flex="60">
        <md-tabs flex md-selected="selectedIndex" md-border-bottom md-autoselect="" md-dynamic-height>
            <md-tab ng-repeat="bizActionFormTab in bizActionFormTabs" ng-disabled="bizActionFormTab.disabled" label="{{bizActionFormTab.businessActionItemData.processName}}">
                <div class="demo-tab tab{{$index%4}}">
                    <div id="{{bizActionFormTab.formDiv}}" style="overflow:auto;"></div>
                </div>
            </md-tab>
        </md-tabs>
    </div>

js/StartBizActionSample.js

The StartBizActionSampleCtrl controller:

  1. uses the supplied parameters to create a businessActionTemplate object that contains the data required by the startBizAction operation.
    $scope.startBizAction = function(){
    
        for(i=0;i<$scope.bizActionFormTabs.length;i++)
                {
                    if($scope.bizActionFormTabs[i].businessActionItemData.processName==$scope.processName)
                return;
        }
    
        var businessActionTemplate = {};
        businessActionTemplate.businessActionItemData = {};
        businessActionTemplate.businessActionItemData.moduleName =  $scope.moduleName;
        businessActionTemplate.businessActionItemData.processName = $scope.processName;
        businessActionTemplate.businessActionItemData.version = $scope.version;    
        businessActionTemplate.payload =  $scope.payload;
        
        businessActionTemplate.formDiv = "formBizDiv#"+$scope.processName;
    
        $scope.bizActionFormTabs.push(businessActionTemplate);
  2. calls the startBizAction operation, passing the businessActionTemplate in the request.
      if (BPMBusinessActionsService){
            BPMBusinessActionsService.startBizAction(businessActionTemplate, {onSuccess: function(){
                    $scope.bizActionFormTabs.splice($scope.bizActionFormTabs.indexOf(businessActionTemplate),1);
                    $scope.$apply("");
                },
                onFailure: function(){
                    $scope.bizActionFormTabs.splice($scope.bizActionFormTabs.indexOf(businessActionTemplate),1);
                    $scope.$apply("");
                }
            });
        }
    
  3. uses the callback function of the request to render the business action form in the <div> element identified by businessActionTemplate.formDiv.