PDA

View Full Version : If field empty return image


Natea11
May 20th, 2013, 06:42 PM
I've got a client that is putting together an order form and was wondering if there is a way to right a rule to the effect of something like this.

If fields "Name", "Address", "Phone# and "Recipient#" are empty return graphic "Contact". Basically, if all those fields are empty they want to place a graphic in the same space that has lines so that someone can hand write in.

Thoughts?

step
May 21st, 2013, 06:30 AM
You could achieve this using an inline graphic:


var contact = [Field("Name"),Field("Address"),Field("Phone#"),Field("Recipient#")];
return (contact.filter(String) != "") ? contact.filter(String).join("<br>") : '<graphic file="Contact.pdf">';

Natea11
May 21st, 2013, 06:12 PM
Thnks. I'll give it a try.

digital@sig-1.com
September 4th, 2013, 10:34 AM
I'm doing something similar; how does this script tell FusionPro the location of the graphic image?

esmith
September 4th, 2013, 11:02 AM
I'm doing something similar; how does this script tell FusionPro the location of the graphic image?
step's code assumes the image is in the same folder as the template. If your graphic is elsewhere, you would need to include the path in the quoted portion of the graphic tag which should either be a full path or relative to the template.

Dan Korn
September 4th, 2013, 12:16 PM
step's code assumes the image is in the same folder as the template. If your graphic is elsewhere, you would need to include the path in the quoted portion of the graphic tag which should either be a full path or relative to the template.
Hard-coding the path into the JavaScript rule makes the job less portable.

It's better to the put path in the Search Path box on the Advanced tab of the Composition Settings dialog; that can be overridden in the CFG file as needed for Producer API compositions (such as in MarcomCentral).

Or, you can use a named resource, added via the Resources dialog, and then call it out in the rule, like so:
var contact = [Field("Name"),Field("Address"),Field("Phone#"),Field("Recipient#")].filter(String);
return contact.length ? contact.join("<br>") : Resource("Contact").content;Then the path to the resource is specified in the Resources dialog, and can be re-linked there if necessary.