Jump to content

If field empty return image


Natea11

Recommended Posts

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?

FAI_FH12GiftList.zip

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 3 months later...
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.

Link to comment
Share on other sites

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.

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