dkent Posted April 30, 2013 Share Posted April 30, 2013 Business card set-up? 3 phone numbers I have a business card where I need have Variable data using three phone number sample of want I'm trying to get- 1 (p) 000-000-0000 (f) 000-000-0000 © 000-000-0000 2 (p) 000-000-0000 (f) 000-000-0000 3 (p) 000-000-0000 © 000-000-0000 4 (p) 000-000-0000 Each staff member uses different phone numbers on there business card some will use (p) (F) and (p) © and (p) (f) © and any combo of the three But they only want the phone that are on the data to show But I keep getting this ( see sample A and B) A---(p) 000-000-0000 (f) © 000-000-0000 B---(p) 000-000-0000 (f) 000-000-0000 © C-- (p) 000-000-0000 (f) © as you see in A--- there is no phone number in (f) but I still got a blank spot there and in B-- I still get the © the then blank and in C-- both (f) and © have blank spots Any help on this would be great D Quote Link to comment Share on other sites More sharing options...
step Posted April 30, 2013 Share Posted April 30, 2013 Try this: var numbers = ["(p) " + Field("phone"),"(c) " + Field("cell"),"(f) " + Field("fax")]; return numbers.filter(function(s){return s.length>4;}).join(" "); Quote Link to comment Share on other sites More sharing options...
dreimer Posted April 30, 2013 Share Posted April 30, 2013 Is that numbers.filter a version 8 specific function? Quote Link to comment Share on other sites More sharing options...
step Posted April 30, 2013 Share Posted April 30, 2013 It's a specific to JavaScript 1.6. FP8 uses JavaScript 1.7 and earlier releases use 1.5. I guess if dkent is using FP7, this solution might work better for him: var result = ""; result += (Field("phone") != "" ) ? "(p) " + Field("phone") : ""; result += (Field("cell") != "" ) ? "(c) " + Field("cell") : ""; result += (Field("fax") != "" ) ? "(f) " + Field("fax") : ""; return result; Or: var phone = "(p) " + Field("phone"); var cell = "(c) " + Field("cell"); var fax = "(f) " + Field("fax"); return (phone + cell + fax).replace(/\(\D\)\s(?!\d)/g,""); Quote Link to comment Share on other sites More sharing options...
dreimer Posted April 30, 2013 Share Posted April 30, 2013 Thanks for the clarification!! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted April 30, 2013 Share Posted April 30, 2013 It's a specific to JavaScript 1.6. FP8 uses JavaScript 1.7 and earlier releases use 1.5. Yes, I remember hearing this somewhere. If you're using an earlier version of FusionPro, you can patch the Array.filter function in by copying the code from this page and pasting it into your JavaScript Globals: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter#Compatibility Quote Link to comment Share on other sites More sharing options...
dkent Posted May 3, 2013 Author Share Posted May 3, 2013 thanks I'm to work on the this week and I'm running of 8 D Quote Link to comment Share on other sites More sharing options...
dkent Posted June 11, 2013 Author Share Posted June 11, 2013 (edited) Ok they change it up on me here the old code is working great I got but now they to see a proof with this now sample of want I'm trying to get- 1 (p) 000-000-0000 l (f) 000-000-0000 l © 000-000-0000 2 (p) 000-000-0000 l (f) 000-000-0000 3 (p) 000-000-0000 l © 000-000-0000 4 (p) 000-000-0000 5 (f) 000-000-0000 l © 000-000-0000 6 © 000-000-0000 But I keep getting this ( see sample A and B) A--- l (f) 000-000-0000 l © 000-000-0000 B--- l © 000-000-0000 The problem I now running into is the line in the front look at B and A For B only the cell is want but they do not want the line in front of it Edited June 11, 2013 by dkent Quote Link to comment Share on other sites More sharing options...
step Posted June 11, 2013 Share Posted June 11, 2013 What does the code currently look like? Quote Link to comment Share on other sites More sharing options...
dkent Posted June 11, 2013 Author Share Posted June 11, 2013 this is the code that is working the best var result = ""; result += (Field("phone") != "" ) ? "(P)" + Field("phone") : ""; result += (Field("cell") != "" ) ? " I ©" + Field("cell") : ""; result += (Field("fax") != "" ) ? " I (F)" + Field("fax") : ""; return result; Quote Link to comment Share on other sites More sharing options...
step Posted June 11, 2013 Share Posted June 11, 2013 Use this code instead: var numbers = ["(p) " + Field("phone"),"(c) " + Field("cell"),"(f) " + Field("fax")]; return numbers.filter(function(s){return s.length>4;}).join(" | "); Quote Link to comment Share on other sites More sharing options...
dkent Posted June 11, 2013 Author Share Posted June 11, 2013 works great thanks one more question do you know a rule to -if this field is blank move line up like this field department - the rock Dave Dent -- name field Couch-- title field The Rock-- here is the department field that some people will need and others will not dave.dent@ - if the they leave the department field blank I need to move this up Quote Link to comment Share on other sites More sharing options...
step Posted June 11, 2013 Share Posted June 11, 2013 You could just repurpose the code I just posted, like this: var contact = [Field("name"),Field("title"),Field("department"),Field("email")]; return contact.filter(String).join("<br>"); Quote Link to comment Share on other sites More sharing options...
dkent Posted June 11, 2013 Author Share Posted June 11, 2013 yes Well I have some rules for the name and tile to lock the style - and it like I will lose those can I just make a rule for the department only Quote Link to comment Share on other sites More sharing options...
step Posted June 11, 2013 Share Posted June 11, 2013 You did not specify what your current rule was. Why don't you just set the text frame to "suppress if empty"? Quote Link to comment Share on other sites More sharing options...
dkent Posted June 11, 2013 Author Share Posted June 11, 2013 thanks that work wish I remember that was there before I asked but thanks for all the help Quote Link to comment Share on other sites More sharing options...
dkent Posted June 12, 2013 Author Share Posted June 12, 2013 new question on this code what is the best way made add a Style lock to the phone part so will only show up x3312 no extension, no ext if they have a extension var numbers = ["(p) " + Field("phone"),"© " + Field("cell"),"(f) " + Field("fax")]; return numbers.filter(function(s){return s.length>4;}).join(" | "); Quote Link to comment Share on other sites More sharing options...
dkent Posted June 12, 2013 Author Share Posted June 12, 2013 samply of what i'm trying to get Dave Dent Print Shop David.dent@--- (P) 703-770-6676 x3313 l © 809-990-4000 Quote Link to comment Share on other sites More sharing options...
step Posted June 12, 2013 Share Posted June 12, 2013 I'm not entirely sure what you're trying to accomplish. Your first post says you want to drop the extension if it's present in the data. Your example shows an extension. Under the assumption you want to drop the extension: var numbers = ["(p) " + Field("phone"),"(c) " + Field("cell"),"(f) " + Field("fax")]; return numbers.filter(function(s){return s.length>4;}).join(" | ").replace(/\s?[ext](\w*)?\s?\d+/gi,""); Quote Link to comment Share on other sites More sharing options...
dkent Posted June 14, 2013 Author Share Posted June 14, 2013 OK let me try and clear what I need help on I found to need to use dashes for all phone numbers we want this (p) 703-557-0000 x3344 (p) 706-990-9000 not this (p) 703.577.3000 on all phone - cell - fax number - we must now use dashes not dots can we add a global find and replace to this code var numbers = ["(P) " + Field("phone"),"© " + Field("cell"),"(F) " + Field("fax")]; return numbers.filter(function(s){return s.length>4;}).join(" | "); to find . and replace with - in the phone cell and fax fields d 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.