Go Back   PTI Marketing Technologies User Community > Software-Related Talk > The JavaScript Library > Graphic Rules

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old July 18th, 2013, 06:56 PM
KatJones KatJones is offline
Junior Community Member
 
Join Date: Sep 2011
Location: Atlanta, GA
Posts: 22
Default Re: Graphic rule executed ONLY if multiple fields are empty

I took your example, which works beautiful and wonderfully and does EXACTLY what I need it to do for mine, but when I copied and pasted to my layout and just switched out the field names and resource names it works... but...

The variable fields show duplicated on the preview. It will show the field(s) a large space/gap and then repeat those fields but they are tabbed over, then it will show the resource.

I noticed in your text frame you had custom tabs set up, but I didn't think that would have anything to do with the variable fields showing up twice even tho I don't have in the my text frame twice
__________________
FP 9.1.0 Producer, Windows Server 2008 R2, Acrobat 10.1.9
Reply With Quote
  #12  
Old July 19th, 2013, 07:17 AM
KatJones KatJones is offline
Junior Community Member
 
Join Date: Sep 2011
Location: Atlanta, GA
Posts: 22
Talking Re: Graphic rule executed ONLY if multiple fields are empty

I think we are almost there! Your code seems to work with setup ... however there seems to be a huge space in between the variable fields and the image when it shifts. When it gets to all 10 fields being populated the image runs off the page because of the huge gap.

The image itself doesn't have as much white space that the preview is showing.
__________________
FP 9.1.0 Producer, Windows Server 2008 R2, Acrobat 10.1.9
Reply With Quote
  #13  
Old September 4th, 2013, 11:38 AM
digital@sig-1.com digital@sig-1.com is offline
Regular Contributor
 
Join Date: Jan 2009
Location: Sacramento, CA
Posts: 66
Default Re: Graphic rule executed ONLY if multiple fields are empty

I have a variable text field that has either 2 or 3 horizontal lines of text. They are divided vertically by a green graphic image. When there are only 2 lines of text, I need a portion of the green line covered up. I created a white box graphic and added it to the resources. Then I wrote this script:

Quote:
if (Field("Direct") == "", Field("Cell") == "") return Resource("Resource1");
else return NullResource();
If both "Direct" and "Cell" are empty fields, the white box appears, which is what I want. If "Cell" exists, then the white box goes away, also what I want. But if "Direct" exists, the white box appears, which I do not want.

I thought it might be something simple, like add a line like this:
Quote:
if (Field("Direct") !="") return NullResource();
but it doesn't work. I do not know JavaScript so I am confused.
__________________
Christian • PrePress
Intel 2 x 2.6 Macintosh 10.6.8 • 12GB RAM • FusionPro 9.2.31 • PitStop 12u2
Reply With Quote
  #14  
Old September 4th, 2013, 12:11 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,147
Default Re: Graphic rule executed ONLY if multiple fields are empty

Quote:
Originally Posted by digital@sig-1.com View Post
I have a variable text field that has either 2 or 3 horizontal lines of text. They are divided vertically by a green graphic image. When there are only 2 lines of text, I need a portion of the green line covered up. I created a white box graphic and added it to the resources. Then I wrote this script:



If both "Direct" and "Cell" are empty fields, the white box appears, which is what I want. If "Cell" exists, then the white box goes away, also what I want. But if "Direct" exists, the white box appears, which I do not want.

I thought it might be something simple, like add a line like this:


but it doesn't work. I do not know JavaScript so I am confused.
What do you think the comma (in red) is doing here?
Code:
if (Field("Direct") == "", Field("Cell") == "") return Resource("Resource1");
else return NullResource();
If you want to say "OR", then use the Logical OR Operator (||), like so:
Code:
if (Field("Direct") == "" || Field("Cell") == "") return Resource("Resource1");
else return NullResource();
Or you could flip the logic, like so:
Code:
if (Field("Direct") != "" && Field("Cell") != "")
    return NullResource();
//else
return Resource("Resource1");
Which can be reduced to:
Code:
if (Field("Direct")" && Field("Cell"))
    return NullResource();
//else
return Resource("Resource1");
Or even:
Code:
return  (Field("Direct") && Field("Cell")) ? NullResource() : Resource("Resource1");
__________________
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@pti.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@PTI.com. Paid consulting work may be required to fulfill your template-building needs. Please do not post proprietary font files to this forum.

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
  #15  
Old September 4th, 2013, 01:09 PM
digital@sig-1.com digital@sig-1.com is offline
Regular Contributor
 
Join Date: Jan 2009
Location: Sacramento, CA
Posts: 66
Default Re: Graphic rule executed ONLY if multiple fields are empty

hmm... still not working.

same problem with this:
Quote:
if (Field("Direct") == "") return Resource("Resource1");
else if
(Field("Cell") == "") return Resource("Resource1");
else return NullResource();
If you look at the screenshots, it will show you a little more about what I am doing. I need the white box when only 2 numbers appear, but no white box when 3 numbers appear.
Attached Images
File Type: png 2-number-whitebox-yes.png (28.0 KB, 2 views)
File Type: png 3-number-whitebox-no.png (31.0 KB, 1 views)
__________________
Christian • PrePress
Intel 2 x 2.6 Macintosh 10.6.8 • 12GB RAM • FusionPro 9.2.31 • PitStop 12u2
Reply With Quote
  #16  
Old September 4th, 2013, 01:18 PM
digital@sig-1.com digital@sig-1.com is offline
Regular Contributor
 
Join Date: Jan 2009
Location: Sacramento, CA
Posts: 66
Default Re: Graphic rule executed ONLY if multiple fields are empty

My bad... this converse statement works.

Quote:
if (Field("Direct") != "" || Field("Cell") != "") return NullResource();
else return Resource("Resource1");
__________________
Christian • PrePress
Intel 2 x 2.6 Macintosh 10.6.8 • 12GB RAM • FusionPro 9.2.31 • PitStop 12u2
Reply With Quote
Reply

Tags
graphic, javascript, rules

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 05:26 PM.


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