KristenBalla Posted November 30, 2009 Share Posted November 30, 2009 I have a title field that needs to be all caps and allow special characters like the ampersand. I've tried a couple different rules.... I used the standard case selection rule while UNchecking "Treat returned strings as tagged text" and I tried this rule with the "treat returned strings as tagged text" checked: return '<uppercase>' + NormalizeEntities (Field("Title")) + '</uppercase>';Field("Title") The last one appeared to work when I composed the piece on my desk top, but both ways I get "& AMP;" when I type and ampersand in the online template. Can someone tell me what I'm doing wrong. thanks! Link to comment Share on other sites More sharing options...
marcuslayton Posted January 6, 2010 Share Posted January 6, 2010 seeing the same thing here - haven't seen a reply that works for the web Link to comment Share on other sites More sharing options...
marcuslayton Posted January 6, 2010 Share Posted January 6, 2010 not pretty - but this works return ToUpper(Field("Title")).replace(/&/gi, "&"); the filed named Title does a global non-case sensitive search for the "&" and replaces it with "&" uncheck the treat as tagged txt Link to comment Share on other sites More sharing options...
MikeVM Posted February 2, 2011 Share Posted February 2, 2011 (edited) I'm fighting with the same problem - in addition to having ampersand as is I need to add large space (larger then regular - kind of em-space) around ampersand... So either ampersand disappered, or spaces... Any help? Edited February 2, 2011 by MikeVM Link to comment Share on other sites More sharing options...
Dan Korn Posted February 2, 2011 Share Posted February 2, 2011 Replace instances of Field in your rules with TaggedDataField, and remove the calls to NormalizeEntities. Leave the "Treat returned strings as tagged text" box checked (on). Note that this is a new feature in FusionPro 7.1, and is supported on MarcomCentral. Link to comment Share on other sites More sharing options...
Modern Postcard Posted August 29, 2012 Share Posted August 29, 2012 I am having the same issues in Marcom Central. "&" looks fine on my template and the store but gets replaced with "&:" when processed for output. When i Leave the "Treat returned strings as tagged text" box checked (on) it drops the "&" all together. Link to comment Share on other sites More sharing options...
Dan Korn Posted August 29, 2012 Share Posted August 29, 2012 I'll reiterate the same solution I suggested in my last post: Use the TaggedDataField function instead of Field, and remove all calls to NormalizeEntities or TaggedTextFromRaw. You still need to have "Treat returned strings as tagged text" checked. Link to comment Share on other sites More sharing options...
Modern Postcard Posted August 30, 2012 Share Posted August 30, 2012 The issue I am having is that I am returning a case selection rule not a field so I'm not sure where I am supposed to be replacing the TaggedDataField function instead of Field. I am using your prebuilt rules for the case selection not straight javascript since I am not that fluent. Link to comment Share on other sites More sharing options...
Sean_Harman Posted September 23, 2015 Share Posted September 23, 2015 Dan I am having the same issue as Modern Postcard above, can you please address that scenario. thanks. Link to comment Share on other sites More sharing options...
Dan Korn Posted September 23, 2015 Share Posted September 23, 2015 Dan I am having the same issue as Modern Postcard above, can you please address that scenario. thanks. If you mean you're using the XML Template rule named "Case selection for a name field Rule", then you need to first convert the rule to JavaScript, then replace every instance of "Field" with "TaggedDataField". (You can use the "Find..." button in the Rule Editor to do a "Replace All".) The result should look like this: var Var1 = "Name"; // or whatever field you chose var CaseSelection = "propercase"; // or whatever case/mode you chose if(CaseSelection == "allcaps") return ToUpper(TaggedDataField(Var1)); if(CaseSelection == "smallcaps") return "<smallcap>" + TaggedDataField(Var1) + "</smallcap>"; if(CaseSelection == "propercase") return ToTitleCase(TaggedDataField(Var1)); if(CaseSelection == "lowercase") return ToLower(TaggedDataField(Var1)); However, the caveat here is that the "propercase" mode may not work exactly right, as the ToTitleCase function doesn't account for tagged markup. (And it's not really right for all names anyway.) Link to comment Share on other sites More sharing options...
miker Posted February 12, 2016 Share Posted February 12, 2016 Is this (Dan's last reply) still valid? I've changed my entries to match, and I'm returning the same error. The only other aspect of the template that I'm curious about, is that it's in a formatted text resource. Here's my converted javascript rule; var Var1 = "Title"; var CaseSelection = "allcaps"; if(CaseSelection == "allcaps") return ToUpper(TaggedDataField(Var1)); if(CaseSelection == "smallcaps") return "<smallcap>" + TaggedDataField(Var1) + "</smallcap>"; if(CaseSelection == "propercase") return ToTitleCase(TaggedDataField(Var1)); if(CaseSelection == "lowercase") return ToLower(TaggedDataField(Var1)); For now, I've disabled the function and asked the client to enter UPPER. I'd prefer to automate the solution. Many thanks. Link to comment Share on other sites More sharing options...
Dan Korn Posted February 12, 2016 Share Posted February 12, 2016 Is this (Dan's last reply) still valid? I've changed my entries to match, and I'm returning the same error. Nothing has changed about how tagged markup is handled. Every job is different, though. The only other aspect of the template that I'm curious about, is that it's in a formatted text resource. What do you mean "it's in a formatted text resource?" What exactly is "in" the resource? Do you mean that you're calling out the rule from a formatted text resource? If so, then you probably are re-encoding the tagged markup in another rule that's returning the resource. What happens if you call out the rule you posted directly in a text frame instead? Here's my converted javascript rule; var Var1 = "Title"; var CaseSelection = "allcaps"; if(CaseSelection == "allcaps") return ToUpper(TaggedDataField(Var1)); // Some other code that will never be reached below... If you only want uppercase text, you can just do this: return ToUpper(Field("Title")); And you do NOT need to check the "Treat returned strings as tagged text" box. (Although there's a small chance that existing tags and entities in the tagged markup data generated by MarcomCentral may not work properly when converted to uppercase.) Link to comment Share on other sites More sharing options...
David Miller Posted March 7, 2017 Share Posted March 7, 2017 (edited) Not sure why, but this seems to have stopped working for me: //My Field Title2 = Title & 2 return ToUpper(TaggedDataField("Title2")); //Rule Editor Validation Returns: TITLE & 2 //MarcomCentral Returns: TITLE 2 //It drops the ampersand. I tried replacing the above with this in MarcomCentral if the data might use an ampersand: var str = Field("Title2");//My Field Title2 = Title & 2 var res = str.toUpperCase(); return (res).replace(/&/gi, "&"); //Rule Editor Validation Returns: TITLE & 2 //MarcomCentral Returns: TITLE & 2 //It no longer drops the ampersand. Any idea why TaggedDataField stopped working in my rules? Edited March 7, 2017 by David Miller Link to comment Share on other sites More sharing options...
Dan Korn Posted March 8, 2017 Share Posted March 8, 2017 Any idea why TaggedDataField stopped working in my rules? TaggedDataField hasn't stopped working. It's returning the string with the ampersand converted to an entity, exactly as it's supposed to do, and as it has always done. Then you're converting that entity to all-caps. This will give you exactly the same results: //My Field Title2 = Title & 2 var res = ToUpper(TaggedDataField("Title2")); return (res).replace(/&/gi, "&"); If anything has changed, it's how the upper-cased & entity is being handled by FusionPro's tagged markup parser. But that's not really a valid entity. Your example may be purposefully trivial, but I think the correct way to do what you want is to uncheck the "Treat returned strings as tagged" box and do this: return ToUpper(UntaggedDataField("Title2")); Link to comment Share on other sites More sharing options...
Recommended Posts