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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 13th, 2021, 11:41 AM
dml1280 dml1280 is offline
Junior Community Member
 
Join Date: Apr 2016
Posts: 22
Default Using external data file to pull in image

I have been using this rule to pull address information into a text box based on the Facility field. It works great.

Code:
returnStr = '';

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

numRecsExtDF = externalDF.recordCount;

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

return returnStr;
With this code, when a new location is brought on, I am able to just add a new facility to the library drop down in MarcomCentral and add a line in my external database file and now all products that use this code will automatically have the new location added without having to update individual products.

I want to add a field for the facility logos but I can't figure out how to have it called back.

Can a graphic be called in using an external database file? I have all of the logos saved in libraries to use across multiple products.

Any insight would be appreciated.

Thank you.
Reply With Quote
  #2  
Old July 14th, 2021, 10:19 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,591
Default Re: Using external data file to pull in image

Sure, assuming the XDF has the file name, you can do something like this, in a Graphic rule:
Code:
var externalDF = new ExternalDataFileEx("yourfilename.txt");

var r = externalDF.FindRecord("Facility", Field("Facility"));
if (r < 1)
    throw "No XDF record for Facility " + Field("Facility");

return CreateResource(externalDF.GetFieldValue(r, "Logo"));
You may need to add the path to the graphics in the job's Search Path, on the Advanced tab of the Composition Options.
__________________
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 July 14th, 2021, 12:19 PM
dml1280 dml1280 is offline
Junior Community Member
 
Join Date: Apr 2016
Posts: 22
Default Re: Using external data file to pull in image

Thank you. It works perfectly.

I am using the URL for our store image library in MarcomCentral as the search path. Is there any issue that you can for-see with that?
Reply With Quote
  #4  
Old July 26th, 2021, 05:17 PM
dml1280 dml1280 is offline
Junior Community Member
 
Join Date: Apr 2016
Posts: 22
Default Re: Using external data file to pull in image

Follow up question...this works great for almost all entries.

It doesn't work if my facility name has an apostrophe or an ampersand in it. Is there a way to be able to include the apostrophe or an ampersand in the facility name?

Sometimes I will need to use the facility name as a field that will be filled in as well.

Thank you

Last edited by dml1280; July 26th, 2021 at 05:21 PM..
Reply With Quote
  #5  
Old July 27th, 2021, 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,591
Default Re: Using external data file to pull in image

Quote:
Originally Posted by dml1280 View Post
Thank you. It works perfectly.
Great!
Quote:
Originally Posted by dml1280 View Post
I am using the URL for our store image library in MarcomCentral as the search path. Is there any issue that you can for-see with that?
Well, if you're composing the job online in the MarcomCentral DM app, then you shouldn't need to do anything special; the graphics will be automatically found in the image libraries.

If you want to see the graphics in an offline composition (like in Acrobat), then you'll have to append the URL base, like so:
Code:
var BaseURL = "https://server/foldername/"; // <- your URL here
return CreateResource(BaseURL + externalDF.GetFieldValue(r, "Logo"));
Quote:
Originally Posted by dml1280 View Post
It doesn't work if my facility name has an apostrophe or an ampersand in it. Is there a way to be able to include the apostrophe or an ampersand in the facility name?
Yes, though it depends on how the input data file is encoded. If you're a MarcomCentral DM user, it's probably a tagged markup file, in which case you'll need to change the FindRecord call slightly, like so:
Code:
var r = externalDF.FindRecord("Facility", UntaggedDataField("Facility"));
__________________
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
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 01:51 AM.


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