Reload Task from within TaskForm

233 views
Skip to first unread message

Bernd Rücker

unread,
Sep 30, 2015, 11:14:54 AM9/30/15
to camunda-...@googlegroups.com

Hey guys.

 

Can I reload the current task from WITHIN the task form?

 

Background: I have a task form which starts a new event sub process. This event sub process might change the current task, e.g. setting a follow-up-date. Now I would like to update the current UI to reflect this change. I know how to load the task via REST – but how can I change the visible task in the Camunda  Angular Surrounding?

 

Hopefully understandable? Maybe this screenshot helps:

 

 

Thanks

Bernd

Roman Smirnov

unread,
Oct 1, 2015, 3:17:26 AM10/1/15
to camunda BPM users
Hi Bernd,

You can change the search part of the current url.

So, when the user click on the task "Beurteilung durch Underwriter notwendig" then you can do the following inside your form:


$scope.selectTask = function(task) {
  $location.search('task', task.id);
};
 

Therefore you have to inject the angular $location service.

This would change the search param "task" of the url and Tasklist will be notified about this and reload the task.

Does it help you?

Cheers,
Roman

Bernd Rücker

unread,
Oct 1, 2015, 4:14:50 AM10/1/15
to camunda-...@googlegroups.com

Hi Roman.

 

Sounds great – but unfortunately does not work for me:

 

<script cam-script type="text/form-script">

   inject([ '$location', function($location) {

 

    function loadCaseStatus() {

    };

   

     $scope.sendMessage = function(messageName) {                

          $.ajax('/camunda/api/engine/engine/default/message/', {

                success: function (result) {

                   loadCaseStatus();

                   //window.location.reload();

                  

                   // reload task

                  $location.search('task', camForm.taskId);

                }

           });

    };

   

       }]);

  </script>

 

Nothing changes on the UI (but I also do not get any error on the console).

 

Cheers

Bernd

--
You received this message because you are subscribed to the Google Groups "camunda BPM users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/camunda-bpm-users/6e9d0fb1-923b-4b7c-b64d-6e5be1740998%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roman Smirnov

unread,
Oct 1, 2015, 5:13:52 AM10/1/15
to camunda-...@googlegroups.com
Hi Bernd,

Sorry, I misunderstood your requirement. So you want to "refresh" the current selected task, so that the "follow-up data" in Tasklist gets updated, when you start for example the task "Beurteilung durch Underwriter notwendig".

So

$location.search('task', camForm.taskId);

will not work, because the current search url does not change.

We do not offer some service to achieve it.

However, a solution could be to reload the whole page by


$route.reload() // you have to inject the $route service
 

or 


window.location.reload();
 

Another solution would be the following "dirty hack":


<script cam-script type="text/form-script">

  // get the angular-data-depend service 'taskData'
  var getTaskData = function(scope) {
    if (scope.taskData) {
      return scope.taskData;
    }  
    return scope.$parent && getTaskData(scope.$parent);
  };

  $scope.taskData = getTaskData($scope);

  $scope.sendMessage = function(...) {

    ...

      success: function(result) {
        if ($scope.taskData) {
          $scope.taskData.set('taskId', {taskId: camForm.taskId});
          // or
          $scope.taskData.changed('task');       
        }
      }

    ...

  };

  </script>
 

The difference is that with "$scope.taskData.changed('task')" (or "$scope.taskData.set('taskId', {taskId: camForm.taskId})") only the task colum will be refreshed and not the whole page.

Cheers,
Roman

Bernd Rücker

unread,
Oct 1, 2015, 5:37:24 AM10/1/15
to camunda-...@googlegroups.com

The hack works – thanks a lot! That gives a much better feeling than a whole page reload (which was my workaround so far).

 

Von: camunda-...@googlegroups.com [mailto:camunda-...@googlegroups.com] Im Auftrag von Roman Smirnov


Gesendet: Donnerstag, 1. Oktober 2015 11:14
An: camunda BPM users <camunda-...@googlegroups.com>

 

<script cam-script type="text/form-script">

        $scope.taskData.set('taskId', {taskId: camForm.taskId});
        // or
        $scope.taskData.changed('task');       
      }

    ...

  };

  </script>

 

 

--

You received this message because you are subscribed to the Google Groups "camunda BPM users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages