Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 24th, 2015, 03:57 PM
DWilliams DWilliams is offline
Forum n00b
 
Join Date: Dec 2014
Location: St. Louis, MO
Posts: 8
Post Identical Formatting Rules Returning Different Results

Hello, I am new and jumping in head first per usual.

I am working on an invite for a client and that will allow them to have multiple sub events (reception, dinner, lecture, movie, etc.) under the date of the main event on the invitation. They are required to enter one and at maximum allowed to have four. The sub events are broken in a 1 | 2 & 3 | 4 format.

Format Example:
Event 1 00:00 p.m. | Event 2 00:00 p.m.
Event 3 00:00 p.m. | Event 4 00:00 p.m.
*note two spaces on either side of pipeline (|)


FusionPro Rules
Code:
if (Field("Event1_title") != "" && Field("Event2_title") != "")
    return Field("Event1_title") + ' ' + Field("Event1_time") + ' ' + Field("Event1_ap") + ' '  + ' | ' + ' '  + Field("Event2_title") + ' ' + Field("Event2_time") + ' ' + Field("Event2_ap");

else if (Field("Event1_title") != "" && Field("Event2_title") == "")
    return Field("Event1_title") + ' ' + Field("Event1_time") + ' ' + Field("Event1_ap");

else if (Field("Event1_title") == "" && Field("Event2_title") != "")
    return Field("Event2_title") + ' ' + Field("Event2_time") + ' ' + Field("Event2_ap");

else return '';
Code:
if (Field("Event3_title") != "" && Field("Event4_title") != "")
    return Field("Event3_title") + ' ' + Field("Event3_time") + ' ' + Field("Event3_ap") + ' '  + ' | ' + ' '  + Field("Event4_title") + ' ' + Field("Event4_time") + ' ' + Field("Event4_ap");

else if (Field("Event3_title") != "" && Field("Event4_title") == "")
    return Field("Event3_title") + ' ' + Field("Event3_time") + ' ' + Field("Event3_ap");

else if (Field("Event3_title") == "" && Field("Event4_title") != "")
    return Field("Event4_title") + ' ' + Field("Event4_time") + ' ' + Field("Event4_ap");

else return '';
Text Generated out of MarcomCentral Portal when I test my template:


It works and I'm not receiving any errors, but it's loosing my double spacing on either side of my pipeline in just the first rule only on MC and I can't figure out why.
Validating the code in FP gives me the correct output and the second rule is formatting correctly. You can see that I have already attempting appending the second space separately to see if that fixed it.

Any thoughts?
Reply With Quote
  #2  
Old April 24th, 2015, 04:51 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,361
Default Re: Identical Formatting Rules Returning Different Results

Look at the "Treat returned strings as tagged text" box in both rules. I'll bet it's checked in one and not the other. When dealing with tagged markup, multiple spaces, tabs, and newlines are collapsed by FusionPro's tagged markup parser.

If this were just a Desktop/Creator job, you would probably want to have that box UNchecked in both rules, since there are no actual markup tags involved. However, you need to be careful, because MarcomCentral will generate a tagged markup data file, and some characters (ampersands, quotes, and angle brackets) will be represented with entities, so you need to account for that possibility. The way to do this is to check the box, and call the TaggedDataField function instead of Field. But when you have that box checked, you're back to the same problem with losing the multiple spaces, so also need to convert those to markup; fortunately, the TaggedTextFromRaw function will do this for you.

Therefore, the ultimate solution to handle anything that MarcomCentral may throw at you is to check the box in both rules and use this rule syntax (with a couple of other changes to reduce the amount of repetitive code):
Code:
return [TaggedDataField("Event1_title"),TaggedDataField("Event2_title")].filter(String).join(TaggedTextFromRaw("  |  "));
__________________
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
  #3  
Old April 27th, 2015, 09:02 AM
DWilliams DWilliams is offline
Forum n00b
 
Join Date: Dec 2014
Location: St. Louis, MO
Posts: 8
Default Re: Identical Formatting Rules Returning Different Results

@ Dan Korn

Thanks for your fast response, my rules are already set to "treat returned strings as tagged text". The only issue I am having with my existing code is that the double spaces are not correct in output.

I am attempting to understand your code suggestion but it looks like it will return a line without my variables for time and am/pm designation. I am unfamiliar with the TaggedDataField function and do not know what arguments are allowed.
If I used your code as provided my MC jpg sample would read:
Sing Along | Snacks

Is there a way to use the TaggedTextFromRaw a more expanded code that gives me the correct formatting of multiple appended variable fields?
Reply With Quote
  #4  
Old April 27th, 2015, 10:01 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,361
Default Re: Identical Formatting Rules Returning Different Results

Quote:
Originally Posted by DWilliams View Post
@ Dan Korn

Thanks for your fast response, my rules are already set to "treat returned strings as tagged text". The only issue I am having with my existing code is that the double spaces are not correct in output.

I am attempting to understand your code suggestion but it looks like it will return a line without my variables for time and am/pm designation. I am unfamiliar with the TaggedDataField function and do not know what arguments are allowed.
If I used your code as provided my MC jpg sample would read:
Sing Along | Snacks

Is there a way to use the TaggedTextFromRaw a more expanded code that gives me the correct formatting of multiple appended variable fields?
I can't offer any more specific suggestions without seeing the job 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
  #5  
Old April 27th, 2015, 02:06 PM
DWilliams DWilliams is offline
Forum n00b
 
Join Date: Dec 2014
Location: St. Louis, MO
Posts: 8
Default Re: Identical Formatting Rules Returning Different Results

@Dan Korn

Unfortunately my manager has informed me that the nondisclosure agreement with our client will prevent me from uploading their templates for your review. I have a theory I'm willing to test if you can confirm that the TaggedTextFromRaw function behaves like the HTML <pre> tag?

Maybe I can stick it in where I'm appending my string of ' | ' in my original code.
Reply With Quote
  #6  
Old April 27th, 2015, 02:34 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,361
Default Re: Identical Formatting Rules Returning Different Results

Quote:
Originally Posted by DWilliams View Post
Unfortunately my manager has informed me that the nondisclosure agreement with our client will prevent me from uploading their templates for your review.
Can you "dummy out" the data, and remove everything else not directly relevant to this question, to create a minimal example? Simply going through that exercise may lead you to what the problem is.
Quote:
Originally Posted by DWilliams View Post
I have a theory I'm willing to test if you can confirm that the TaggedTextFromRaw function behaves like the HTML <pre> tag?
Well, sort of. But it's more complicated than that, depending on what else the rule is doing.
Quote:
Originally Posted by DWilliams View Post
Maybe I can stick it in where I'm appending my string of ' | ' in my original code.
Sure, you can try that.
__________________
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
  #7  
Old April 28th, 2015, 07:29 AM
DWilliams DWilliams is offline
Forum n00b
 
Join Date: Dec 2014
Location: St. Louis, MO
Posts: 8
Default Re: Identical Formatting Rules Returning Different Results

@Dan Korn

So the following code…totally worked. I can in no way explain why; but now my event times are all displaying correctly. I can also not explain why the second rule continues to work without modification.

Thank you for alerting me to the TaggedTextFromRaw function for this instance.

Code:
if (Field("Event1_title") != "" && Field("Event2_title") != "")
    return Field("Event1_title") + ' ' + Field("Event1_time") + ' ' + Field("Event1_ap") + TaggedTextFromRaw("  |  ")  + Field("Event2_title") + ' ' + Field("Event2_time") + ' ' + Field("Event2_ap");

else if (Field("Event1_title") != "" && Field("Event2_title") == "")
    return Field("Event1_title") + ' ' + Field("Event1_time") + ' ' + Field("Event1_ap");

else if (Field("Event1_title") == "" && Field("Event2_title") != "")
    return Field("Event2_title") + ' ' + Field("Event2_time") + ' ' + Field("Event2_ap");

else return '';
Reply With Quote
Reply

Tags
javascript, rule, text formatting

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 10:08 AM.


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