macfan55 Posted June 14, 2018 Share Posted June 14, 2018 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? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted June 14, 2018 Share Posted June 14, 2018 (edited) 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 June 14, 2018 by Dan Korn Quote Link to comment Share on other sites More sharing options...
macfan55 Posted June 15, 2018 Author Share Posted June 15, 2018 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; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.