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

AUTOMATE SEGMENT CODES

Avatar

Level 3

Hi,

 

can someone explain me how to automate the creation of segment codes? Cant find any documentation about it...

bcollado_0-1718291927610.png

Maybe using javascript?

 

Thank you and kind regards,

Blanca

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @bcollado ,

Go to Split activity > Advanced tab > paste the below script in initialization script

vars.subset1_variable = formatDate(new Date(), "%4Y/%2M/%2D");
vars.complement_variable = formatDate(new Date(), "%4Y");

//for Subset 1
activity.transitions.extractOutput[0].code = vars.subset1_variable;

//For complement segment code
activity.transitions.remainder.code = vars.complement_variable;

The above script will automate segment code by adding current date to subset 1 and current year in complement's segment code. Instead of current date and year, replace it with your logic and store in the same above variable and run the workflow.

 

If you have multiple subsets, then add one more line and modify it as extractOutput[1], extractOutput[2] and so on...

//Subset 1
activity.transitions.extractOutput[0].code = vars.subset1_variable;

//Subset 2
activity.transitions.extractOutput[1].code = vars.subset2_variable;

//Subset 3
activity.transitions.extractOutput[2].code = vars.subset3_variable;

//Subset 4
activity.transitions.extractOutput[3].code = vars.subset4_variable;

//Complement
activity.transitions.remainder.code = vars.complement_variable;

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @bcollado ,

Go to Split activity > Advanced tab > paste the below script in initialization script

vars.subset1_variable = formatDate(new Date(), "%4Y/%2M/%2D");
vars.complement_variable = formatDate(new Date(), "%4Y");

//for Subset 1
activity.transitions.extractOutput[0].code = vars.subset1_variable;

//For complement segment code
activity.transitions.remainder.code = vars.complement_variable;

The above script will automate segment code by adding current date to subset 1 and current year in complement's segment code. Instead of current date and year, replace it with your logic and store in the same above variable and run the workflow.

 

If you have multiple subsets, then add one more line and modify it as extractOutput[1], extractOutput[2] and so on...

//Subset 1
activity.transitions.extractOutput[0].code = vars.subset1_variable;

//Subset 2
activity.transitions.extractOutput[1].code = vars.subset2_variable;

//Subset 3
activity.transitions.extractOutput[2].code = vars.subset3_variable;

//Subset 4
activity.transitions.extractOutput[3].code = vars.subset4_variable;

//Complement
activity.transitions.remainder.code = vars.complement_variable;