Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 15th, 2022, 06:07 AM
Fletch Fletch is offline
Regular Contributor
 
Join Date: Apr 2009
Posts: 99
Default Phone Labels appearing when cell is empty

I picked this rule in a post from 2013. What am I missing? The Labels (Office, Direct, Cell) still appear when the cell is empty. I should also add that I need to labels for each a particular font and color, and the actual phone numbers a separate font and color. I'll upload my csv file and a jpg image to show.

var numbers = ["Office: " + Field("Office"),"Direct: " + Field("Direct"),"Cell: " + Field("cell")];
return numbers.filter(function(s){return s.length>4;}).join(" ");
__________________
Using FusionPro Desktop 11.2 on Widows 10 Pro i7-8700 CPU, 3.2 Ghz with 16GBRam.(can you hear Tim Allen, yet?)
Acrobat DC (the Cloud)

Also Running FusionPro Producer on a Windows 7 Professional Virtual Machine.

Last edited by Fletch; March 15th, 2022 at 06:28 AM..
Reply With Quote
  #2  
Old March 15th, 2022, 06:33 AM
Fletch Fletch is offline
Regular Contributor
 
Join Date: Apr 2009
Posts: 99
Default Re: Phone Labels appearing when cell is empty

It will not let me attach the xlsx or csv file.
Attached Images
File Type: jpg Sample.jpg (195.0 KB, 1 views)
__________________
Using FusionPro Desktop 11.2 on Widows 10 Pro i7-8700 CPU, 3.2 Ghz with 16GBRam.(can you hear Tim Allen, yet?)
Acrobat DC (the Cloud)

Also Running FusionPro Producer on a Windows 7 Professional Virtual Machine.
Reply With Quote
  #3  
Old March 15th, 2022, 09:50 AM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 227
Default Re: Phone Labels appearing when cell is empty

It's not working because you are filtering on the length being greater than 4. Your shortest length is "Cell: " which is 6.

Anyways, that wont work with the formatting you want. Give this a shot:

Code:
function format_phone(prefix, phone_num)
{
	if (phone_num)
		return '<span color="Red">' + prefix + ": " + '</span><span color="Blue">' + phone_num + '</span>';
	else
		return false;
}

var numbers = [format_phone("Office", Field("Office")), format_phone("Direct", Field("Direct")), format_phone("Cell", Field("Cell"))];

return numbers.filter(Boolean).join(" ");

Edit: The forums turned my "& # 32;" into a space (without the spaces between them). You will need to use that entity instead of a literal space character in the join(" ")

Last edited by ThomasLewis; March 15th, 2022 at 09:58 AM..
Reply With Quote
  #4  
Old March 16th, 2022, 04:02 AM
Fletch Fletch is offline
Regular Contributor
 
Join Date: Apr 2009
Posts: 99
Default Re: Phone Labels appearing when cell is empty

That worked like a charm. I tweaked it a bit for the proper colors and to add a space between the numbers.
I also duped a section to add a extension to the Office number. I need the 'ext' to be black as well as the actual extension number, and a '.' after the ext instead of a ':' colon. Can that be done? (Code below)

function format_phone(prefix, phone_num)
{
if (phone_num)
return '<span color="PANTONE BLUE 072 U">' + prefix + ": " + '</span><span color="Black">' + phone_num + '</span>';
else
return false;
}

var numbers = [format_phone("<b> Office</b>", Field("Office")), format_phone("<b> ext</b>", Field("Ext")), format_phone("<b> Direct</b>", Field("Direct")), format_phone("<b> Cell</b>", Field("Cell"))];

return numbers.filter(Boolean).join(" ");
__________________
Using FusionPro Desktop 11.2 on Widows 10 Pro i7-8700 CPU, 3.2 Ghz with 16GBRam.(can you hear Tim Allen, yet?)
Acrobat DC (the Cloud)

Also Running FusionPro Producer on a Windows 7 Professional Virtual Machine.
Reply With Quote
  #5  
Old March 16th, 2022, 01:58 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,638
Default Re: Phone Labels appearing when cell is empty

Quote:
Originally Posted by Fletch View Post
I need the 'ext' to be black as well as the actual extension number, and a '.' after the ext instead of a ':' colon. Can that be done?
This should work:
Code:
function format_phone(prefix, phone_num)
{
    if (!Field(phone_num))
        return "";
    
    var endsWithDot = prefix.match(/\.$/);
    
    var result = '<span bold=true';
    
    if (!endsWithDot)
        result += ' color="PANTONE BLUE 072 U"';
    
    result +='>' + prefix;
    
    if (!endsWithDot)
        result += ":";
        
    result += " " + '</span>' + Field(phone_num);
    
    return result;
}

var numbers = { Office: "Office", "ext.": "Ext", Direct: "Direct", Cell: "Cell" };

var result = [];
for (var label in numbers)
    result.push(format_phone(label, numbers[label]));

return result.filter(String).join(" \n");
I've reduced the code a bit by having just the minimal data in the numbers object (which is now an object with a map of properties and values instead of an array), and calling the format_phone function in a loop, which includes the calls to Field. There's a little bit of Regular Expression magic to detect whether the prefix (label) ends with a dot, which is what we use to determine whether to change the color and append the colon. I also put the bold change into the span tag, and removed the code to set the color to Black, which is not needed if the variable for this rule is inserted in Black in the Text Editor, since the ending </span> tag restores the original color.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #6  
Old March 17th, 2022, 05:30 AM
Fletch Fletch is offline
Regular Contributor
 
Join Date: Apr 2009
Posts: 99
Default Re: Phone Labels appearing when cell is empty

That codes works perfectly! I do need one adjustment. I need the 'ext.' to be not bold.
__________________
Using FusionPro Desktop 11.2 on Widows 10 Pro i7-8700 CPU, 3.2 Ghz with 16GBRam.(can you hear Tim Allen, yet?)
Acrobat DC (the Cloud)

Also Running FusionPro Producer on a Windows 7 Professional Virtual Machine.
Reply With Quote
  #7  
Old March 17th, 2022, 09:44 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,638
Default Re: Phone Labels appearing when cell is empty

Quote:
Originally Posted by Fletch View Post
That codes works perfectly! I do need one adjustment. I need the 'ext.' to be not bold.
Sure, a minor change:
Code:
function format_phone(prefix, phone_num)
{
    if (!Field(phone_num))
        return "";
    
    var endsWithDot = prefix.match(/\.$/);
    
    var result = '<span';
    
    if (!endsWithDot)
        result += ' bold=true color="PANTONE BLUE 072 U"';
    
    result +='>' + prefix;
    
    if (!endsWithDot)
        result += ":";
        
    result += " " + '</span>' + Field(phone_num);
    
    return result;
}

var numbers = { Office: "Office", "ext.": "Ext", Direct: "Direct", Cell: "Cell" };

var result = [];
for (var label in numbers)
    result.push(format_phone(label, numbers[label]));

return result.filter(String).join(" \n");
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #8  
Old March 18th, 2022, 04:10 AM
Fletch Fletch is offline
Regular Contributor
 
Join Date: Apr 2009
Posts: 99
Default Re: Phone Labels appearing when cell is empty

Dan, thanks a million. I truly am grateful. For some reason, the 'ext.' is still Bold. I've examined the code to see if I could possibly figure it out and it's not really jumping out at me. So sorry. Can you adjust the code for the 'ext.' to not be bold?
__________________
Using FusionPro Desktop 11.2 on Widows 10 Pro i7-8700 CPU, 3.2 Ghz with 16GBRam.(can you hear Tim Allen, yet?)
Acrobat DC (the Cloud)

Also Running FusionPro Producer on a Windows 7 Professional Virtual Machine.
Reply With Quote
  #9  
Old March 18th, 2022, 11:23 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,638
Default Re: Phone Labels appearing when cell is empty

Quote:
Originally Posted by Fletch View Post
Dan, thanks a million. I truly am grateful. For some reason, the 'ext.' is still Bold. I've examined the code to see if I could possibly figure it out and it's not really jumping out at me. So sorry. Can you adjust the code for the 'ext.' to not be bold?
Hmm, it works for me. Though I don't have your job files, so I had to change the field names and use a different test job. Are you sure you have the exact code I posted? Anyway, there's nothing I can do to diagnose what's happening in your specific job without the files.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #10  
Old March 21st, 2022, 03:57 AM
Fletch Fletch is offline
Regular Contributor
 
Join Date: Apr 2009
Posts: 99
Default Re: Phone Labels appearing when cell is empty

I found my mistake. I had duped the original Rule you sent, to create the second Rule, but forgot to swap the Rules in the Text Frame. It works perfectly. Again, many thanks.
__________________
Using FusionPro Desktop 11.2 on Widows 10 Pro i7-8700 CPU, 3.2 Ghz with 16GBRam.(can you hear Tim Allen, yet?)
Acrobat DC (the Cloud)

Also Running FusionPro Producer on a Windows 7 Professional Virtual Machine.
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 08:10 AM.


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