Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

How to get the value of a task variable?

Avatar

Level 3

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

Avatar

Correct answer by
Employee

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

Avatar

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.

Avatar

Level 3

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!

Avatar

Correct answer by
Employee

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

Avatar

Level 3

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!

 

Avatar

Employee

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

Avatar

Level 3

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!

Avatar

Employee

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

Avatar

Level 3

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?