SDK 3 - create SHARE constant accessible anywhere

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Established Member II

SDK 3 - create SHARE constant accessible anywhere

Hi,

I have different dashlets on my site dasboard. Each dashlet contains its active tasks.

For the moment when i click on task , form appears, and when i submit it, the dashboard is reloaded  with all active tasks of ALL dashlets (dashboard update)

The aim is to iterate all the active tasks for a specific dashlet i.e. :

I click on the first task of dashlet "A", it opens associate form, and when i submit it, the form of next task of the SAME dashlet appears automatically and so on, until all active tasks of dashlet A are handled.

For that I need to save dashlet name when the form is loaded.

Then when  dashboard is reloaded , i would like to retrieve this value and use it as filter in order to open the next task of the same dahlet.

I try to save dashlet name when the first form is launched (click on first task) .

I would like to create constant accessible anywhere to store this value but i don't know how to retrieve it :

SDK 3 : how to acces non displayed form variable 

If the dashlet name could be stored, this is a javascript snippet that could be done during dashboard reloading:

window.onload = function() {

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

   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 != "")   {

                              
                              if(OLD DASHLET NAME != null) {   // need to retrieve dashlet name stored during previous task handling (CONSTANT, SESSION VALUE, OTHER WAY???)
                                    // retrieve task id et and dashlet name 
                                    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] == OLD DASHLET NAME ) {
                                             nextTask = taskIdList[i];
                                             i = dashletNameList.length;
                                      }
                                 }
                       

                          if (nextTask != ""){
                              console.log("new task - same dashlet")
                          Alfresco.util.navigateTo("task-edit?taskId="+nextTask+"&referrer=tasks&myTasksLinkBack=true");
                          } else {
                              console.log("toutes les tâches de la dashlet ont été traitées");
                              Alfresco.util.navigateTo("site/documed/dashboard");
                         }
                  }
             }
      });

};

What is the best way to do it in Alfresco ?

Thank you for your help

1 Reply
Highlighted
Established Member II

Re: SDK 3 - create SHARE constant accessible anywhere

OK, it works by using "localStorage"

ex : localStorage.setItem('id', value');