AnsweredAssumed Answered

Bad URL

Question asked by anakin59490 on Mar 22, 2018

Hi,

 

i have process that opens task automatically. 

The problem is it opens it in "embedded-documentlibrary" dashlet instead the current windows :

 

 

 

I have tried to change document.URL before edit the task but same result ..

 

Javascript :

 

 

window.onload = function() {

 

var me = this;
var allActiveTasks = document.location.origin+"/share/page/my-tasks";
var dashboard = document.location.origin+"/share/page/site/documed/dashboard";
var lastUrlLoading = document.location.origin+"/share/page/site/documed/embedded-documentlibrary";
console.log("document.URL : " +document.URL);
console.log("lastUrlLoading : "+lastUrlLoading);

var taskIdList=[] ;
var dashletNameList=[] ;
var nextTask = "";

// depuis le dashboard
   if (document.URL == lastUrlLoading){
   console.log("localStorage.getItem('oldDashlet') = "+ localStorage.getItem('oldDashlet'));
      if(localStorage.getItem('oldDashlet') != "") {

      // requête qui récupère TOUTES les tâches actives du user
      Alfresco.util.Ajax.request({

         url: Alfresco.constants.PROXY_URI+ "api/task-instances?authority="+Alfresco.constants.USERNAME,   
         method: Alfresco.util.Ajax.GET,
         responseContentType: Alfresco.util.Ajax.JSON,
         successCallback: {
            fn: function generateForm_onSuccess(response){

               var json = JSON.parse(response.serverResponse.responseText);
               if(json.data!="") {

 

                     for(var i = 0; i < json.data.length; i++) {
                        taskIdList.push(json.data[i].id);
                        dashletNameList.push(json.data[i].properties["wfvd_nomService"]);
                     }

                     for(var i = 0; i < dashletNameList.length; i++) {
                           if (dashletNameList[i] == localStorage.getItem('oldDashlet')) {
                                 nextTask = taskIdList[i];
                                 i = dashletNameList.length;
                             }
                     }

                     if (nextTask != ""){
                        console.log("nouvelle tâche - même dashlet " +nextTask)
                        history.pushState({}, null, dashboard);
                        console.log("nouvel url : "+document.URL);
                         window.location.href = document.location.origin+'/share/page/site/documed/task-edit?taskId=' +nextTask;

                     } else {
                           console.log("toutes les tâches de la dashlet ont été traitées");
                           localStorage.setItem('oldDashlet', '');
                     }
                  }
               }
            }
         });
      }
   }
};

 

 

Thank's

Outcomes