Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 19th, 2014, 01:36 AM
jimmyhartington jimmyhartington is offline
Regular Contributor
 
Join Date: Nov 2012
Posts: 65
Default Skip record or filtering the database

Hi

I have a FusionPro template, where I skip records based on the zipcode range using a rule OnRecordStart.

The rule is like this:
Code:
//Skip records based on postcenter
FusionPro.Composition.composeThisRecord = false;
if (Field("Postcenter") == "KHC") {
    if (Field("Postnr") >= 0 && Field("Postnr") <= 4999) {
        FusionPro.Composition.composeThisRecord = true;
    } else {
        FusionPro.Composition.composeThisRecord = false;
    }
} else if (Field("Postcenter") == "FAC") {
    if ((Field("Postnr") >= 5000 && Field("Postnr") <= 7999) || (Field("Postnr") >= 8700 && Field("Postnr") <= 8799)) {
        FusionPro.Composition.composeThisRecord = true;
    } else {
        FusionPro.Composition.composeThisRecord = false;
    }
} else if (Field("Postcenter") == "ARC") {
    if ((Field("Postnr") >= 8000 && Field("Postnr") <= 8699) || (Field("Postnr") >= 8800 && Field("Postnr") <= 9999)) {
        FusionPro.Composition.composeThisRecord = true;
    } else {
        FusionPro.Composition.composeThisRecord = false;
    }
}
The field "Postcenter" is chosen from a drop-down in MarcomCentral.
When previewed it does not always create a preview because the first or last record perhaps is not in the interval defined in the skip record.

I was wondering if there was a way to do this with a OnJobStart rule, which instead of skipping records, then filtered the data and the only processed the data with the zip-code range defined.

Does anybody know if this is possible?
__________________
Kind regards Jimmy Hartington

-------
Happy MarcomCentral® customer - OS version: macOS 10.15.7 - Acrobat DC - FusionPro version: 11.2.1
Reply With Quote
  #2  
Old February 19th, 2014, 07:03 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Skip record or filtering the database

If preview is the only thing you are concerned about, you could just put your existing code within an if statement with a condition checking for whether or not the code is being executed in preview. Like so:
Code:
if (!IsPreview()){
    //Skip records based on postcenter
    FusionPro.Composition.composeThisRecord = false;
    if (Field("Postcenter") == "KHC") {
        if (Field("Postnr") >= 0 && Field("Postnr") <= 4999) {
            FusionPro.Composition.composeThisRecord = true;
        } else {
            FusionPro.Composition.composeThisRecord = false;
        }
    } else if (Field("Postcenter") == "FAC") {
        if ((Field("Postnr") >= 5000 && Field("Postnr") <= 7999) || (Field("Postnr") >= 8700 && Field("Postnr") <= 8799)) {
            FusionPro.Composition.composeThisRecord = true;
        } else {
            FusionPro.Composition.composeThisRecord = false;
        }
    } else if (Field("Postcenter") == "ARC") {
        if ((Field("Postnr") >= 8000 && Field("Postnr") <= 8699) || (Field("Postnr") >= 8800 && Field("Postnr") <= 9999)) {
            FusionPro.Composition.composeThisRecord = true;
        } else {
            FusionPro.Composition.composeThisRecord = false;
        }
    }
}
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old February 19th, 2014, 07:08 AM
jimmyhartington jimmyhartington is offline
Regular Contributor
 
Join Date: Nov 2012
Posts: 65
Default Re: Skip record or filtering the database

Hi

This could be a work around.

Still it could be nice to filter the data.
Because my data file contains 1790 records.
When ordering through MarcomCentral the count in the product is 1790, because the data contains this, but the file output only contains the records merged based on the zip-code.
So this is misleading.
__________________
Kind regards Jimmy Hartington

-------
Happy MarcomCentral® customer - OS version: macOS 10.15.7 - Acrobat DC - FusionPro version: 11.2.1
Reply With Quote
  #4  
Old February 19th, 2014, 07:39 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Skip record or filtering the database

Oh I see, well let me preface this by saying: I have no experience with MarcomCentral and I'm not sure how "product count" is determined in MarcomCentral. Does it also have to be the total number of records or can it be modified?

Anyway, with that caveat in mind, you could link to your input data file as an external data file, and run through it to push the values into a sorted array and reference your data from that.

Keep in mind I have no way of testing this, but I would think you could potentially trick FP (using the IsPreview function) into thinking it has the correct "product count" by setting an end record number to the value of the array length (during preview only). You'd want to ignore that block of code if it's not in preview though so that it tests all records. Maybe this can get you started (OnJobStart):
Code:
if (IsPreview()){
    var data = new ExternalDataFileEx(FusionPro.Composition.inputFileName,',') // assuming comma delimited
    var records = data.recordCount;
    var composeThese = [];

    // Add record numbers to an array of files to compose
    for (var i=1; i<=records; i++){
        var postcenter = data.GetFieldValue(i, "Postcenter");
        var postnr = data.GetFieldValue(i, "Postnr");

        if (postcenter == "KHC") {
            if (postnr >= 0 && postnr <= 4999) {
                composeThese.push(i);
            } 
        } 
        else if (postcenter == "FAC") {
            if ((postnr >= 5000 && postnr <= 7999) || (postnr >= 8700 && postnr <= 8799)) {
                composeThese.push(i);
            } 
        } 
        else if (postcenter == "ARC") {
            if ((postnr >= 8000 && postnr <= 8699) || (postnr >= 8800 && postnr <= 9999)) {
                composeThese.push(i);
            } 
        }
    }

    FusionPro.Composition.endRecordNumber = composeThese.length;
}
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #5  
Old February 19th, 2014, 12:59 PM
jimmyhartington jimmyhartington is offline
Regular Contributor
 
Join Date: Nov 2012
Posts: 65
Default Re: Skip record or filtering the database

Hi Ste

Thanks. I will try to pursue this direction.
Thanks.
__________________
Kind regards Jimmy Hartington

-------
Happy MarcomCentral® customer - OS version: macOS 10.15.7 - Acrobat DC - FusionPro version: 11.2.1
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:50 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.