Jump to content

Skipping records based on field values and reverse skipping


macfan55

Recommended Posts

I have a adreslist with zipcodes that has to be split into two outputfiles based on the zipcodes in a particular field. (2 separate companies deliver it)

Sofar I managed to create the output with the zipcodes of the first company with a java script rule but I can't figure out how to reverse the proces so that I get the missing zipcodes in a second output file for the second company.

Here's the OnRecordStart rule of company 1:

 

switch (Field("Postcode cijfers"))

{

case "1911":

case "1941":

case "1942":

case "1943":

case "9733":

case "9734":

case "9735":

case "9736":

case "9737":

case "9741":

case "9742":

case "9743":

case "9744":

case "9745":

case "9746":

case "9747":

case "9766":

 

FusionPro.Composition.composeThisRecord = false;

}

 

 

If I just change the last line in "true" it just outputs al the records and that's not what I want.

 

Any advice here?

Link to comment
Share on other sites

switch (Field("Postcode cijfers"))
{
 case "1911":
 case "1941":
 case "1942":  
 case "1943":
 case "9733":
 case "9734":
 case "9735":
 case "9736":
 case "9737":
 case "9741":
 case "9742":
 case "9743":
 case "9744":
 case "9745":
 case "9746":
 case "9747":
 case "9766":
   break;

 default:
   FusionPro.Composition.composeThisRecord = false;
}

Or:

var codes = 
[
 1911,
 1941,
 1942,  
 1943,
 9733,
 9734,
 9735,
 9736,
 9737,
 9741,
 9742,
 9743,
 9744,
 9745,
 9746,
 9747,
 9766
];

FusionPro.Composition.composeThisRecord = codes.indexOf(Int(Field("Postcode cijfers"))) >= 0;

Or, using ranges, as in this thread:

http://forums.pti.com/showthread.php?p=1157#post1157

function CheckRanges(val)
{
 for (var i in ranges)
 {
   if (ranges[i] instanceof Array)
   {
     if (val >= ranges[i][0] && val <= ranges[i][1])
       return true;
   }
   else if (val == ranges[i])
     return true;
 }

 return false;
}

var ranges = [ 1911, [1941,1943], [9733,9737], [9741,9747], 9766 ];
FusionPro.Composition.composeThisRecord = CheckRanges(Int(Field("Postcode cijfers"));
return FusionPro.Composition.composeThisRecord;

Edited by Dan Korn
Link to comment
Share on other sites

Thanks Dan! Great help - learned a few things.

 

I used the latter script with the range-numbers, very handy!

 

I only had to add another ) at the end of the 18th line like this and then it works.

 

var ranges = [ 1911, [1941,1943], [9733,9737], [9741,9747], 9766 ];

FusionPro.Composition.composeThisRecord = CheckRanges(Int(Field("Postcode cijfers")));

return FusionPro.Composition.composeThisRecord;

 

:)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...