Jump to content

Ampersand in external data file


dml1280

Recommended Posts

I am using an external data file to bring in different location addresses.

 

The names of the locations uses an ampersand rather than "and". This is how their logos are set up and I would like to keep it all consistent.

 

When I code the card with Fusion Pro, everything works fine and it composes correctly, but when I upload onto MarcomCentral, the list doesn't work with the ampersand.

 

Is there a way to make it work without replacing "&" with "and"?

Link to comment
Share on other sites

This rule should do what you want:

{code}

var title = TaggedDataField("Address"); // Handles both flat-file data in Acrobat and tagged data generated by DSF.

title = ReplaceSubstring(title, "&", "&"); // "Normalize" numeric entities for ampersands to the named entity.

title = ReplaceSubstring(title, "&", '<f name="Times New Roman">&</f>'); // Replace the font just for ampersands.

return title;

Link to comment
Share on other sites

This is the "record walker" code. I have a separate rule for each variable I am bringing in from the external data file:

 

returnStr = '';

if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true)
{
   Rule("OnJobStart");
}

numRecsExtDF = externalDF.recordCount;

for (recordWalker=1; recordWalker <= numRecsExtDF; recordWalker++)
{
   if (externalDF.GetFieldValue(recordWalker, 'Facility') == Field("Facility"))
   {
       returnStr += externalDF.GetFieldValue(recordWalker, 'Facility');
   }
}

return returnStr;

 

The facility names have "&" in them. The issue is that in Fusion Pro it pulls the record correctly. Once uploaded to MarcomCentral, the record doesn't get pulled when the facility name is selected from the dropdown.

 

I tried adding "TaggedDataField" before "Facility"

 if (externalDF.GetFieldValue(recordWalker, 'Facility') == TaggedDataField("Facility"))

 

But that didn't work.

 

Any other ideas? Or is there somewhere else I should add the "TaggedDataField"?

 

Thanks for your help!

Link to comment
Share on other sites

Thanks but that didn't work.

 

It shows up fine in FusionPro but not in MarcomCentral.

 

It's not pulling the address and website.

 

returnStr = '';

if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true)
{
   Rule("OnJobStart");
}

numRecsExtDF = externalDF.recordCount;

for (recordWalker=1; recordWalker <= numRecsExtDF; recordWalker++)
{
   if (externalDF.GetFieldValue(recordWalker, 'Facility') == Field("Facility"))
   {
       returnStr += TaggedTextFromRaw(externalDF.GetFieldValue(recordWalker, 'Address'));
   }
}

return returnStr;

 

p.png?fv_content=true&size_mode=5

 

p.png?fv_content=true&size_mode=5

Link to comment
Share on other sites

Thanks but that didn't work.

 

It shows up fine in FusionPro but not in MarcomCentral.

 

It's not pulling the address and website.

Okay, well, I'm trying to diagnose this through a keyhole, with no actual files to examine.

 

I'm assuming that the XDF itself is the same in both the local composition and the online MarcomCentral composition, and that it's the primary data file that's different, as it's being generated as tagged markup by MarcomCentral.

 

So you might need to do this to match up the tagged value in the main data file with the value in the XDF:

for (recordWalker=1; recordWalker <= numRecsExtDF; recordWalker++)
{
   if (TaggedTextFromRaw(externalDF.GetFieldValue(recordWalker, 'Facility')) == TaggedDataField("Facility"))
   {
       returnStr += externalDF.GetFieldValue(recordWalker, 'Facility');
   }
}

Or, more succinctly:

for (recordWalker=1; recordWalker <= numRecsExtDF; recordWalker++)
{
   var val = externalDF.GetFieldValue(recordWalker, 'Facility');
   if (TaggedTextFromRaw(val) == TaggedDataField("Facility"))
       returnStr += val;
}

Whether you want to call TaggedTextFromRaw on the value you're appending to the return string depends on whether the rule itself is returning tagged markup.

p.png?fv_content=true&size_mode=5

 

p.png?fv_content=true&size_mode=5

Not sure what you're trying to show here; I don't see anything. I think you need to make the pictures publicly accessible, or upload them here.

Link to comment
Share on other sites

I am sorry, I thought I had sent the files previously. Attached here. I also included in the package the screenshots I tried to post.

 

It shows that the code works in FusionPro but doesn't work once up on MarcomCentral.

Okay, thanks. What I suggested in my previous post should work. Did you try that?

Link to comment
Share on other sites

No, I still can't get it to work.

 

I also checked in MarcomCentral to make sure I have the file linked correctly and that the drop down list is exact.

 

I even tested the settings by changing one of the facilities on the drop down to use "and" instead of "&" and it worked...so it's definitely the tagged text.

 

Did you see the file I attached? Did I place the code correctly?

 

Otherwise I will just have to bite the bullet and forget about using the "&" and hopefully I won't run into consistency issues.

 

Thanks,

Dena

Link to comment
Share on other sites

No, I still can't get it to work.

 

I also checked in MarcomCentral to make sure I have the file linked correctly and that the drop down list is exact.

 

I even tested the settings by changing one of the facilities on the drop down to use "and" instead of "&" and it worked...so it's definitely the tagged text.

 

Did you see the file I attached? Did I place the code correctly?

 

Otherwise I will just have to bite the bullet and forget about using the "&" and hopefully I won't run into consistency issues.

 

Thanks,

Dena

Well, first of all, there's a reason why I always suggest that MarcomCentral-specific issues get posted to the MarcomCentral-specific sub-forum, rather than to the general FusionPro forum, because people who know more about MarcomCentral (the application) than I do answer questions there.

 

What I don't know specifically here is exactly what MarcomCentral is putting into the XML (tagged markup) data file that it's generating based on the user input into the web form, which is then presented to FusionPro as the input data file. The easiest way find this out is to ask your MarcomCentral Support person; the next easiest is to post on that MarcomCentral-specific sub-forum.

 

The thing is, there are multiple ways in which MarcomCentral could be representing the value in that XML data file, all of which are valid, and we don't know for sure which one it's using. So, without knowing exactly what's in that data file, it's hard to know what we're trying to match.

 

It might work better to use NormalizeEntities rather than TaggedTextFromRaw. There are some subtle differences in how those two functions handle spaces after entities. Again, it all depends on how MarcomCentral is generating the data on its end.

 

Or, maybe the right answer here is to use UntaggedDataField, and compare that to the XDF value directly, like so:

for (recordWalker=1; recordWalker <= numRecsExtDF; recordWalker++)
{
   var val = externalDF.GetFieldValue(recordWalker, 'Facility');
   if (val == UntaggedDataField("Facility"))
       returnStr += externalDF.GetFieldValue(recordWalker, 'Address');
}

In which case you probably want to UNcheck the "Treat returned strings as tagged text" box in your rule, and remove all other calls to TaggedTextFromRaw.

 

That will probably work, regardless of how MarcomCentral is encoding the data.

 

Also, the whole rule can be simplified quite a bit, to just this:

var XDF = new ExternalDataFileEx('PHFacilities_Data_PTI.txt');
if (!XDF.valid)
   return 'Failed to link to the external data file';

var rec = XDF.FindRecord("Facility", UntaggedDataField("Facility"));
return XDF.GetFieldValue(rec, 'Address');

You can put the call to new ExternalDataFileEx in as many rules as you need; in later versions of FusionPro (9.3 and newer), external data files are cached, so that calling new ExternalDataFileEx on a file you've already opened incurs no penalty. Also, note the use of the FindRecord function instead of iterating all the records yourself in the code.

Link to comment
Share on other sites

Can you try this

returnStr = '';

 

if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true)

{

Rule("OnJobStart");

}

 

numRecsExtDF = externalDF.recordCount;

 

for (recordWalker=1; recordWalker <= numRecsExtDF; recordWalker++)

{

if (ReplaceSubstring(externalDF.GetFieldValue(recordWalker, 'Facility'), "&", "&") == Field("Facility"))

{

returnStr += (ReplaceSubstring(externalDF.GetFieldValue(recordWalker, 'Facility'), "&", "&");

}

}

 

return returnStr;

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