-order
-----customer
---------item
---------item
-----state1
-----other info
-order
-----customer
---------item
---------item
---------item
-----state2
-----other info
The XML is organized so the records with the same states are in consecutive order. My problem is that I am creating labels for each customer but I need a different label to be triggered every time the state changes. My first thought was to create a conditional script in designer but I don’t have that deep of knowledge yet. Am I going about this the wrong way?
Let me guess, you used to use that function in PlanetPress Suite 7
I have a method of achieving that using a Boolean field in the datamapper. Maybe it will help in your case. Really wish OL would build it into the designer or mapper though. The below script needs to be placed into a JavaScript field AFTER you have extracted your country field.
You can rename some of the variables in the code if you wish as the script was built to trigger true/false base on a Postal code change (code/pcode/newCode etc.).
But there are two main lines that need to be changed to your field name. (I have changed it already to COUNTRY.
//this fields script must go after the PCode is extracted in a extract step.
var code, newCode, results = false;
var startValue = 1;
var incrementValue = 1;
var stepToReset = 2;
var counter = record.index;
if(stepToReset) counter = ((record.index-1) % stepToReset) + 1;
if(incrementValue) counter = (counter * incrementValue)-incrementValue;
if(startValue) counter = startValue + counter;
if(counter == 1) code = record.fields.COUNTRY;
if(counter == 2) newCode = record.fields.COUNTRY;
if(record.index == 1){
results = false;
}else{
if(code == newCode){ results = false; }else{ results = true; }
}
I have an old post here with a sample mapper using CSV data, template and output that you can look at.
I was planning to ask the mods if I can update it as I have added more functionality to this concept. In my revised version of this, the mapper counts how many fields were equal to each other and gives a total of how many there were in another field as well as putting the previous value into another field. (I created this to trigger a section that would act as a slip sheet with variable data when the job was printed)
Going back to this been based on Postal code on change:
E.G.
Field:
PCode
0190
0190
0190
0190
0190
0190
1401
The mapper would report after PCode changes to 1401 that On Change = true, PCode = 6 x 0190 postal codes with the same value and previous PCode was 0190. Like below screen.
Disclaimers:
Use the above concept at your own risk.
This only works with data that has been presorted by the field you want to trigger the On Change.