-Lisa- Posted October 29, 2009 Share Posted October 29, 2009 Hi everyone, I've been running into this a lot lately.... I have several customers that call out to a recipient's first name on their VDP pieces. Many of these customers have mailing lists which consist of records that have only a first initial instead of a full name. I'd like to be able to return no value in these instances and I'm at a loss as to how to get JavaScript to determine whether there is a full name or only one initial in a given record. Anyone have any suggestions? Thanks in advance!! Link to comment Share on other sites More sharing options...
Dan Korn Posted October 29, 2009 Share Posted October 29, 2009 Is the first initial in its own "FirstName" field, or is it part of a field containing the last name as well? If you could provide a few records of sample data, that would be helpful. Link to comment Share on other sites More sharing options...
-Lisa- Posted October 30, 2009 Author Share Posted October 30, 2009 Hi Dan, No, the first initial is part of the original FirstName field. For instance, here is a sample of four records: FirstName LastName John Smith M Jones Joe Martin L Miller I need to be able to write a rule which will determine which records have only a first initial as opposed to a full name and return a null value. Thanks! Link to comment Share on other sites More sharing options...
tobarstep Posted October 30, 2009 Share Posted October 30, 2009 Hi Dan, No, the first initial is part of the original FirstName field. For instance, here is a sample of four records: FirstName LastName John Smith M Jones Joe Martin L Miller I need to be able to write a rule which will determine which records have only a first initial as opposed to a full name and return a null value. Thanks! I don't know if an actual Null value is what you want; an empty string would probably be better. If it's always either a single initial or a full name you could use something along the lines of this: return (Field("FirstName").length==1) ? "" : Field("FirstName"); Link to comment Share on other sites More sharing options...
-Lisa- Posted November 4, 2009 Author Share Posted November 4, 2009 I don't know if an actual Null value is what you want; an empty string would probably be better. If it's always either a single initial or a full name you could use something along the lines of this: return (Field("FirstName").length==1) ? "" : Field("FirstName"); I think this is close to what I'm looking for, thanks! I tried entering it exactly as entered but I'm receiving a syntax error. Also, I want to add a line where if the First Name field is empty, it also returns an empty string. Normally I can compose this into a rule with no problem but I'm not sure how to include it in the code above..... Link to comment Share on other sites More sharing options...
tobarstep Posted November 4, 2009 Share Posted November 4, 2009 I think this is close to what I'm looking for, thanks! I tried entering it exactly as entered but I'm receiving a syntax error. Also, I want to add a line where if the First Name field is empty, it also returns an empty string. Normally I can compose this into a rule with no problem but I'm not sure how to include it in the code above..... You could just change your comparison to accommodate an empty string: return (Field("FirstName").length<=1) ? "" : Field("FirstName"); What is the error you are getting? Maybe your field isn't called FirstName? Link to comment Share on other sites More sharing options...
-Lisa- Posted November 5, 2009 Author Share Posted November 5, 2009 What is the error you are getting? Maybe your field isn't called FirstName? I changed the name of my field to correspond with my datafile so that wasn't it. I wasn't really familiar with the format you provided for the rule so I tried using your components to build a JS rule I was more familiar with. I think that's probably why it wasn't working. Once I copied and pasted the new code you provided adding a provision for an empty string, it worked! Thank you so much for helping me through this! Link to comment Share on other sites More sharing options...
esmith Posted November 5, 2009 Share Posted November 5, 2009 This: return (Field("FirstName").length<=1) ? "" : Field("FirstName"); is "shorthand" for this: if (Field("FirstName").length<=1) { return ""; } else return Field("FirstName"); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.