蜜豆视频

Configure JavaScript code activity

Learn how to effectively use the JavaScript Code activity in 蜜豆视频 Campaign Web v8 to enhance your workflows.

This tutorial covers both simple and advanced scripting modes. It explains execution settings and error handling. You will see real-world examples, such as targeting VIP profiles, transforming data, and triggering conditional operations.

Transcript

In this video, we鈥檒l show you how to set up a JavaScript code activity in a workflow in 蜜豆视频 Campaign Web V8. This enables you to collect information from a database or perform other complex code functions. There are two types of JavaScript code activities, simple and advanced. Simple JavaScript code allows you to execute one code snippet, while the advanced option lets you execute more complex operations. The advanced JavaScript code activity enables you to execute two different code snippets. The first script runs once when the workflow starts and the reoccurring script runs every time the workflow is executed after that. The advanced option also allows you to define multiple output transitions which you can control using logic, allowing for dynamic branching based on your script鈥檚 conditions. Please note, within the 蜜豆视频 Campaign Web UI, the simple and advanced JavaScript code activities have been consolidated into one activity. This has not affected either functionality. Let鈥檚 see how to use this activity in the product. After logging into 蜜豆视频 Campaign, navigate to Workflows in the left-hand column. Create a new workflow using the desired template and click Create. Once you鈥檙e within the canvas of your newly created workflow, click the plus to add an activity and select JavaScript code. On the right of the canvas, you will be able to select if you want a simple or advanced JavaScript activity. For this example, we are going to use a simple JavaScript activity where we count and log the number of profiles in a specific domain. So, next, we are going to click Create code to open the expression editor. This is where we鈥檒l add the code we want to run. You can select the predefined event variables and conditions from the left-hand panel to build your code, or you can copy and paste the code. Just click the plus beside any of the variables to add them. For the purposes of this video, I will copy and paste the code for our example. This script will use a query to select all recipients whose email contains 鈥淍gmail.com鈥, and count those records.

Below the code section in the right-hand navigation, there is the execution section. This allows you to stop the activity after a period of time. For our example, we are going to set this to 1 hour. By default, the execution phase cannot exceed 1 hour. After this delay, the process is aborted with an error message and the activity execution fails. To ignore this limit, set the value to 0. Below the execution section is Process errors toggle. When toggled on, this option keeps the errors that occur during the script execution in an additional output transition. Once you are happy with your code, click Start to complete the activity workflow and start the execution. You have now successfully created a simple JavaScript workflow. Our next example will show you how to use the advanced JavaScript code activity. In this activity, we want to split our recipients into two different groups and route them through separate transitions. After clicking the JavaScript code activity, choose the advanced activity type. Next, you are going to click Create the first call code. This code sets the variable threshold, which will evaluate each recipient鈥檚 total spend.

We will now define the second call code, which is the script that runs each time the workflow executes. The code we鈥檙e using for the second recurring call evaluates the total spend of each recipient, and if the value is higher than $500, they will be routed to the first output. Everyone else will go to the second output.

Next, we鈥檙e going to create the transitions. For the first transition, we are going to put the label as output 0 and the name as HighSpenders. We will then click Add to add another transition and put the label as Output 1 and the name as Everyone Else. The execution and process errors sections are the same as in the simple JavaScript activity. Once your activity is created, click Start to complete the workflow. You have now successfully created an advanced JavaScript workflow. This wraps up the process of effectively using the JavaScript code activity within 蜜豆视频 Campaign V8 to enhance your workflows. Thanks for watching!

See the product documentation for more information on this feature.

recommendation-more-help
e2fc39ca-1242-4c55-a90e-e3344cc25141