cancel
Showing results for 
Search instead for 
Did you mean: 

Access to variables - When - Where - What

norgan
Champ in-the-making
Champ in-the-making
Good evening everybody,

I am a bit at a loss working with the workflow variables: The questions is rather simple - Which variable is accessible where - and how.

I learned there are
* task-related variables : The variables from the task form ?
* process-related variables: The variables from the workflow model ?
* more ?

And where are these accessible : Here is my code on "node-leave"
      <event type="node-leave">
         <script>
            <variable name="bpm_workflowDescription" access="read,write" />
            <variable name="chk_EAdescription" access="read,write" />
            <variable name="chk_EApriority" access="read,write" />
            <variable name="chk_Deadline" access="read,write" />
            <variable name="chk_EAname" access="read" />
            <variable name="bpm_workflowPriority" access="read"></variable>
            <variable name="bpm_description" access="read"></variable>
            <variable name="bpm_workflowDuedate" access="read"></variable>
            <expression>
               bpm_workflowDescription = chk_EAname;
                  if (bpm_workflowPriority != void) chk_EApriority = bpm_workflowPriority;
                  System.out.println("bpm_workflowDescription =" + bpm_workflowDescription);
                  System.out.println("bpm_description =" + bpm_description);
                  System.out.println("bpm_workflowDuedate =" + bpm_workflowDuedate);
                  System.out.println("bpm_workflowPriority =" + bpm_workflowPriority);
                  System.out.println("Token =" + token.comments.get(0).getMessage());
                  System.out.println("Workflowpriority =" + bpm_workflowPriority);
                  if (bpm_description != void) chk_EAdescription = bpm_description;
                  System.out.println("chk_EAdescription =" + chk_EAdescription);
                  if (bpm_workflowDuedate != void) chk_Deadline = bpm_workflowDuedate;
                  System.out.println("bpm_workflowDuedate =" + bpm_workflowDuedate);
                  System.out.println("chk_Deadline =" + chk_Deadline);
            </expression>
         </script></event>

Result :
the bpm_variables are null - except for workflowdescription - which I set from another field I use - and bpm_workflowPriority.

Any ideas ? More infos for the basics ? I seem to be too stupid for the wiki explanations

Norgan
4 REPLIES 4

jayjayecl
Confirmed Champ
Confirmed Champ
I'm surprised that you could do that.
In 3.1, You cannot declare several variables in a script with the "write" access.

norgan
Champ in-the-making
Champ in-the-making
It says that in the Alfrescolog, when I use AlfrescoJavascript, with jBPL Beanshell, it seems to be ok.

Norgan

norgan
Champ in-the-making
Champ in-the-making
Hi,
I had some time to look into this again and I tried following code with following strange result. Is anybody using the beanshell and javascript to work with task & process variables at all - or shlud I just move to java actions ?

Two times the same debug lines, trying to find out what values are stored or accessibale at all. The output is completely different, however, depending on event task-end and node-leave. Can anyone explain this to me ?

<start-state name="Auftrag erfassen">
      <task name="chkwf:enterEAdata" >
          <event type="task-end">
              <script>
                  System.out.println("========================================================");
                  System.out.println("=============== task-end ===================");
                  System.out.println("========================================================");
                  if (bpm_workflowPriority != void) {
                     chkwf_EApriority = bpm_workflowPriority;
                     System.out.println("bpm_workflowPriority: " + bpm_workflowPriority);
                  }
                  if (taskInstance.description != void) {
                     bpm_description = taskInstance.description ;
                     System.out.println("taskInstance.description : " + taskInstance.description );
                  }
                  if (bpm_description != void) {
                     chkwf_EAdescription = bpm_description;
                     System.out.println("bpm_description: " + bpm_description);
                  }
                  if (bpm_workflowDuedate != void) {
                     chkwf_Deadline = bpm_workflowDueDate;
                     System.out.println("bpm_workflowDuedate: " + bpm_workflowDuedate);
                  }              </script>
           </event>       
      </task>
      <event type="node-leave">
         <script>
                  System.out.println("========================================================");
                  System.out.println("=============== node-leave ===================");
                  System.out.println("========================================================");
                  if (bpm_workflowPriority != void) {
                     chkwf_EApriority = bpm_workflowPriority;
                     bpm_priority = bpm_workflowPriority;
                     System.out.println("bpm_workflowPriority: " + bpm_workflowPriority);
                  }
                  if (bpm_description != void) {
                     chkwf_EAdescription = bpm_description;
                     System.out.println("bpm_description: " + bpm_description);
                  }
                  if (bpm_workflowDuedate != void) {
                     chkwf_Deadline = bpm_workflowDueDate;
                     System.out.println("bpm_workflowDuedate: " + bpm_workflowDuedate);
                  }
         </script></event>
      <transition to="gogogo" name="toGoGoGo"></transition>
   </start-state>


Following 9 lines from my log:
========================================================
=============== task-end ===================
========================================================
taskInstance.description : Anfrage mit EA-Nr und EA-Namen erfassen
bpm_description: Anfrage mit EA-Nr und EA-Namen erfassen
========================================================
===============node-leave ===================
========================================================
bpm_workflowPriority: 1

jayjayecl
Confirmed Champ
Confirmed Champ
Hi Norgan, here is one of the mainproblems I had with scripting.
I don't know if it was me or scripting API in workflows, but many times, I could notice that accessing and/or logging variables in scripting API could "alter" them.