Jump to content

Identical Formatting Rules Returning Different Results


DWilliams

Recommended Posts

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

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 '';

 

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:

http://www.rboweb.com/WASHU/IMGS/EXAMPLES/example.jpg

 

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?

Link to comment
Share on other sites

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):

return [TaggedDataField("Event1_title"),TaggedDataField("Event2_title")].filter(String).join(TaggedTextFromRaw("  |  "));

Link to comment
Share on other sites

@ 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?

Link to comment
Share on other sites

@ 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.

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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.

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.

Maybe I can stick it in where I'm appending my string of ' | ' in my original code.

Sure, you can try that.

Link to comment
Share on other sites

@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.

 

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 '';

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...