MLobo Posted January 25, 2016 Share Posted January 25, 2016 This seems pretty basic, but I can't get it to work. Please help? In a data list of numbers, if a field is empty I want to return "0" as a value. Thanks! Quote Link to comment Share on other sites More sharing options...
step Posted January 26, 2016 Share Posted January 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
MLobo Posted January 26, 2016 Author Share Posted January 26, 2016 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! Quote Link to comment Share on other sites More sharing options...
step Posted January 26, 2016 Share Posted January 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
MLobo Posted January 26, 2016 Author Share Posted January 26, 2016 Thank you again!! That helps enormously. Another quick question if you don't mind: Do the "extra" files generated (DL.DEFFile, DIF File) need to be kept? Quote Link to comment Share on other sites More sharing options...
step Posted January 26, 2016 Share Posted January 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
MLobo Posted January 26, 2016 Author Share Posted January 26, 2016 Great. Again, thanks for the enlightenment! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.