Jump to content

Empty fields to zero?


MLobo

Recommended Posts

If you have a rule that's returning a field's value, you can do something like this:

var number = Field("Your Field") || 0;
return number;

The first line says: "Set the value of 'number' equal to the value of the field 'Your Field' or if a value does not exist for 'Your Field,' set 'number' equal to zero."

 

If you aren't using rules to return your fields and you're simply inserting a field into the text editor you can make an OnRecordStart callback rule that replaces the value of any empty field with 0:

for (var i in FusionPro.Fields)
   if (!Field(i)) FusionPro.Composition.AddVariable(i, 0);

The above code walks through every field in your data file at the beginning of each record and checks to see if it is empty. If the field is empty, it's value is set to zero.

Link to comment
Share on other sites

Thank you for the fast reply!!

 

That is very interesting info. I'm trying to learn by consulting the manuals that came with FP, though, and didn't see ANY of what you just told me. Like everyone else, I try for hours to solve a problem myself, and then it turns out I was completely off base the whole time.

 

Can you tell me what I should be using to learn these things? I'd be happy to buy a book if that's what I need to do, or if it's in one of the manuals can you tell me where to find it?

 

I want to learn this system, it's so cool. I haven't tried what you told me yet, but I'm sure it's right, and I appreciate you explaining what the code means as well.

 

Thank you!

Link to comment
Share on other sites

I don't think there's much about JavaScript in the manuals because that's already pretty well-documented across the internet. If you're new to JavaScript, checkout JavaScript.com or CodeAcademy. Those are two free resources that will (at the very least) get you familiar with the syntax. Aside from that, my other suggestion would be to just participate on this forum. If there's something specific to a template you're working on that you can't figure out, search the forum – it is extremely possible that it's been asked before and if not, feel free to post it because I'm sure someone else will also want to know.
Link to comment
Share on other sites

Do the "extra" files generated (DL.DEFFile, DIF File) need to be kept?

No, they don't need to be kept if you're composing jobs locally. If you're composing a job on the server, you'd have to specify a '.dif' file and a '.cfg' file to use on the command line. Otherwise, I believe FusionPro just regenerates those files every time you compose the job based on the most recent composition settings.

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