Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to get the value of a task variable?

xliu
Level 2
Level 2

Hi there, 

I am using Adobe Campaign Classic. And when I use activity Update Data, I found that this activity updated an task variable. How to get this number?

I tried get this value in Advanced -> Initialization script, but failed. And also tried to get the value in next activity, failed.

1 Accepted Solution
_Shubham_Goyal
Correct answer by
Level 2
Level 2

Hi @xliu 

 

Try to follow the below steps in your workflow:

Step 1: Select the activity where the task variable is allocated.

Step 2: Click on the 'Display the task an logs' icon.

Step 3: Select 'Tasks' tab.

Step 4: Select the transition for which you need to see the task details.  

Step 5: From Elementary task click on 'Variables'.

Step 6: Here under the 'Task Variables' field you will see the task variable data.

Adding screenshot of all the above steps.

taskVariablestaskVariables

Br,
Shubham

View solution in original post

9 Replies
Krishnanunni
Level 4
Level 4

Hi @xliu ,

 

As per my understanding, task variables are like a local variable itself. It is used by an activity for temporary storage of data. I don't think it would be accessible in next activities. Also, advanced script executes prior to the update action. So the variable wouldn't have been set at the time of advanced script execution. Honestly, I haven't used a task variable at all. But if you wanted to use it, then may be inside the update operation (in the expression) would be a possibility.

xliu
Level 2
Level 2

Hi Krishnanunni,

 

Thanks for your reply!

 

The reason I want to use task variable is there is a value indicate the number of records which have no change. So we need that variable to do reconciliation. By the way, what do you mean by inside the update operation?

 

Thanks again for your help!

_Shubham_Goyal
Correct answer by
Level 2
Level 2

Hi @xliu 

 

Try to follow the below steps in your workflow:

Step 1: Select the activity where the task variable is allocated.

Step 2: Click on the 'Display the task an logs' icon.

Step 3: Select 'Tasks' tab.

Step 4: Select the transition for which you need to see the task details.  

Step 5: From Elementary task click on 'Variables'.

Step 6: Here under the 'Task Variables' field you will see the task variable data.

Adding screenshot of all the above steps.

taskVariablestaskVariables

Br,
Shubham

View solution in original post

xliu
Level 2
Level 2

Hi Shubham,

 

Thanks very much for your reply!

 

And yes, that's the way I found this variable. But I'm wondering if there is a way to read that value in the next activity? For example, get task variable in the End activity in your example.

 

Thanks again for your help!

 

_Shubham_Goyal
Level 2
Level 2

Hi @xliu 

That's a good ask 🙂 but unfortunately the 'Task variables' are like local variables and can only be used by the current task. (task.vars.xyz) 
Instance variables on the other hand are like global variables and are shared by all activities in a workflow.

The only way I can suggest is you can use logInfo(<task_variable_name>), and extract the value of the task variable in the output of the workflow logs.

Br,
Shubham

xliu
Level 2
Level 2

Thanks Shubham,

 

I tried to add logInfo(<task_variable_name>) in Advanced->Initialization script, but failed. The task variable hasn't defined yet at that point. But there is indeed a log indicates the variable.

 

I think the output log maybe a solution. Do you know how to get the activity log ID or content by javascript?

 

Thank you very much!

_Shubham_Goyal
Level 2
Level 2

Hi @xliu ,

You can use the following command in the Advanced>Intialization script to log the output of the task:

logInfo('My Task Id: ' + task.taskIdentifier)   //task identifier
logInfo('My Activity Name: ' + task.activity)   //activity name

Br,
Shubham

xliu
Level 2
Level 2

Hi @_Shubham_Goyal ,

 

Your solution works! Thanks again.

 

And I have another question, how is the task.taskIdentifier generated? Will there be two different tasks with the same id?