Document level script to display zeros in calcuated field

I have created a form, with the calculated fields set to read only, and with a validation script of
if (event.value == 0) event.value = '';
(so that the calculated fields do not display as $0.00)
All but four of the calculated fields are named Item.0, Item.1 etc., plus there are SubTotal, ShippingCharge, CCFee and Total fields that need to stay blank until data is entered into the form.
Initially, I tried to add the script as a document level script, but it didn't work and I'm thinking it needs more to the script to use at the document level, but I have no idea what more it needs.
Where did I go wrong?  It certainly would be quicker to add calculated fields if I didn't have to add that validation script to each.

Even with a document level script you would need to call it in every calculated field.
I you were to write "app.alert("Hello World");" as a document level function, it would only execute when the PDF was initialized or opened and not again as long as the PDF remained open.
If you rote a document level function using JavaScript like:
function Hello() {
appp.alert"Hello World, I am a function");
return true;
It would never run until called  with  a JavaScript statement like "Hello();"
So even with a document level script and preferably a function, you still would need to edit every calculation to call the function or the script would never run.
You could also create a document level function to suppress the zero display and then write more code to add the call to this function to the calculated fields.
You need to learn more about the scope of items, how events are processed within a PDF, what functions are and how to use them effectively. You might want to start with getting or linking to a copy the Acrobat JS API Reference.

Similar Messages

  • Delete Document Level Script Using JavaScript?

    Hello all.
    Is there a way for a document level script to delete itself? I am running Adobe Acrobat Professional 11.
    My situation is that I am currently analysing data using a Java application. The Java application taylors a script to suit each specific PDF, and then inserts it into the PDF automatically. When the PDF is opened, the script runs once and then is no longer needed.
    As the script is no longer needed it would be preferred if the script could automatically be deleted. Is it possible the script has access to the field in which it is stored (e.g. doc.javascriptField = "";)? Or by some miracle, a delete function already exists?
    I think that due to the lack of need for such a function by general and advanced users I won't get the answer I am hoping for. But it is worth a shot. In the mean time, I am inserting a flag into the KeyWord field so that the script does not run twice. It works, but it is not exactly clean.
    Any help would be greatly appreciated.
    Thanks
    Jonny O

    My original idea of...
    stamper.addJavaScript("this.addScript("oneTimeScript", "app.alert('Annoying Popup')")");
    Did not work.
    However, while debugging I did come across the name given to a script added via iText (Java library). The default is "000000000000000". With any added scripts being incremented by 1. So the this.removeScript("ScriptName") function works perfectly.
    Thanks
    Jonny O

  • Document level scripting from process workflow

    Hi all,
    is there some way to add a "document level" script from process workflow in Livecycle Workbench?
    That is, I have a script i want to add to a pdf in my process workflow. How can I do that? Is there some service/function/script I can use to do that?
    I'd really appreciate any help.
    Thanks
    Alessio

    Not that I am aware of, could be wrong though

  • Document level scripting

    I have read about document level scripting -
    This is a nice feature - since it allows a certain level of generalization rather that writing a scriptlet for each objects events.
    I am using Live cycle designer 8.2
    How can I create a document level javascript function ?  i can't see how to do it .
    I am familiar with java scripting and have been scripting for a number of events but i would really like to be able to have a callable function that I pass certain parmeters to for processing.
    please indicate how I can do this .
    Thanks

    You should post this in the LiveCycle Designer forum here, if you haven't already.

  • Folder level script? How can I use field value as a pdf filename in save as dialog box

    I read somewhere that if you use a folder level script, you can do things like save a pdf with a specific filename - possibly based on a field name.
    How would one set up a folder level script?
    How do you execute a script from the PDF?
    What code would you use to change the PDF name to the contents of the fFieldName text field?
    Or, is this really just impossible to do?

    The article is interesting.  It suggests you place code like this:
    // Page Replacement Function
    var ReplaceLastPage = app.trustedFunction( function(cPath) {
    app.beginPriv();
    this.replacePages(this.numPages-1, cPath); app.endPriv();
    In the trusted folder.  What is the path of the trusted function(s) that get automatically loaded into Acrobat?
    I assume in the example above, function(cPath) is a function inside of the PDF...

  • Smartform-Suppress Zero and Display Zero for same field in Diff Conditions?

    Hi,
    I have a scenario in smartform, where for a quantity field of length p15 and Dec3, needs to display ZERO for one scenario and display SPACE for another condition. To display ZERO i have made it as &quantity(c)&, so that i can display zero. It displays ZERO, but for another condition, when i want to display space, there also it displays 0.000 ! how to display SPACE there ?
    thanks,
    Padma

    Hi,
    I think then in that case we need to use (NZ) I am not sure. But however why don't you use the Condition Tab in the Text by Including the Condition Quantity > 0.000.
    Please let me know if anyone of this works for you.
    Regards,
    SRinivas

  • Document Level Scripts .. Need a simple example!

    I've been trying to add a function to a form just to avoid writing the same script over & over again & am not succeeding :|
    I'm trying to add even only an app.alert function..
    I add a script object under a subform 'P1' called 'hello'..
    in hello, i write
    function hello1
    app.alert("hello")
    you can see the hierarchy here:
    http://i29.photobucket.com/albums/c271/mashdown45/screen.jpg
    in order to call the hello1 function from a button, on the click event, i add the following:
    form1.P1.variables.hello.hello1();
    but am getting an error
    TypeError: form1.P1.variables.hello123 has no properties
    1:XFA:form1[0].P1[0].Button1[0]:click
    (you all must be thinking: 'obviously'.. but i cannot figure it out!)
    Thank you in advance..

    Hi Chris. I created a variable named hello in the hierarchy and typed in:
    function hello1()
    app.alert("hello")
    Then in the click event of the button I put:
    form1.P1.variables.hello.hello1();
    I think all you needed were the "()" after the function name.

  • Import script to remove zeros in Account field

    Dear FDM Experts,
    The problem is our source system always extracts 10 characters but we use 7 characters in HFM.
    Example, Account 0001201010 (10 characters) must be 1201010 (7 characters).
    I want to write an Import Script to remove, if any, all zeros from the left side of the account value at the import stage. We have no Accounts beginning with 0.
    Thanks in advance for your help,
    Carsten

    Thanks! But I got an error message:
    ** Begin FDM Runtime Error Log Entry [2012-04-17-13:24:10] **
    ERROR:
    Code............................................. 13
    Description...................................... Type mismatch: 'FormatNumber'
    At line: 14
    Procedure........................................ clsImpProcessMgr.fLoadAndProcessFile
    Component........................................ upsWObjectsDM
    Version.......................................... 1111
    Thread........................................... 2164
    Could you provide me with the full script?

  • Document Level Header Scripts

    Hello -
    I am looking for any assistance you may have.  I am working on a project in Acrobat Professional 7.0 that requires me to add the computer username to the header of a pdf file.  I have determined, and implemented this in Excel files using an onopen event.  I need to do the same thing but in a pdf file.  I have absolutely no javascripting experience so the more basic your explanation the better.
    After reading up on the internet, I believe that I need a document level script?  I found an example that is:
    this.addwatermarkfromtext({
    ctext: "Confidential Document",
    ntextalign: 2,
    nhorizalign: 2,
    nvertalign: 0,
    nhorizvalue: -72,
    nvertvalue: -72,
    I entered that under Advanced, Javascript, Document Javascript but I receive an error that says typeerror: this.addwatermarkfromtext is not a function.  Again, I would need to change it to pull the username (I am assuming I can do this with a variable?).  I appreciate any and all help.
    Thanks in advance for your time.

    Thanks for the quick response.  Here is my situation.  The pdf file contains highly confidential information.  I want to email it out and have the username automatically appear in the header or footer so everyone is aware of who printed the copy.
    If, according to your last post, cannot assign that to the document level then must that be applied on everyone's computer?  Please note that I am the only one with Professional.  All users will be using the Reader only.
    Thanks again for all of your assistance.  It is greatly appreciated.

  • Document-level Javascript as Object

    I created a document level script called Utility.
    I want to create methods within this script rather than coding each one separately.
    function Utility()
    this.getFormattedDateOnly=function(pDate) {
      if (typeof pDate == "undefined") {
        pDate = new Date();
      var retval = util.printd("m/dd/yyyy",pDate);
      return retval;
    this.getFldsOnPagenum = function(pPageNum, pDoc) {
      /* returns an array of the form fields who are on or start on a page */
      /* zero based return ; however pPageNum is 1 thru numPages, not 0 -> numPages-1 */
      var currPage;
      var currFld;
      var cnt = -1;
      var ARflds = [];
    CPR("# flds=" + pDoc.numFields+" Type of pDoc:"+ (typeof pDoc));
      for (var i = 0; i < pDoc.numFields; i++) {
        currFld = pDoc.getNthFieldName(i);
        if (typeof currFld.page == "number") {
    CPR("page="+(1*currFld.page+1));
          if ((1*currFld.page+1) == pPageNum) {
            cnt++;
            ARflds.length = cnt + 1;
            ARflds[cnt] = currFld;
    CPR("\n cnt="+cnt);
        } else if ((1*currFld.page[0]+1) == pPageNum) {
          cnt++;
          ARflds.length = cnt + 1;
          ARflds[cnt] = currFld;
      return ARflds;
    var MyUtil = new Utility();
    This is all working fine with the following exceptions:
    1) the methods are not being registered in the Javascript hierarchy listing.
    That's annoying.
    2) "This" is not recognized at the document level....I must pass it as a parameter (pDoc).
    I thought that was strange...I could see it if were at the folder level.
    It appears the document object is out-of-scope !!
    3) currFld = pDoc.getNthFieldName(i);
    The above is failing....sending back a "currFld is undefined" error.
    I don't see the problem....very strange IMHO.
    When I call the getNthFieldName function from the console....no problem.
    What am I doing wrong in the definition here ?
    It appears that what I did has Acrobat functions and document properties out-of-scope.

    I think this would work if you could make the document object a member of the Object being created.
    To do that, a constructor needs to be invoked so that it can instantiate a public property of the Object.
    var MyUtil = new Utility(this);
    inside of Utility I would have:
    this.oPDFdoc =  this;
    thereby transferring a reference to the entire PDF document to my Object.
    Getting this to work would eliminate the need for all of the document-level javascript references.

  • How do I validate a certificate (not visible) at the document level?

    I am using Acrobat XI Pro running in Windows 8.
    I created a PDF document with form fields (type: button) and JavaScript codes (field-level and document-level). Before I certify (not visible) and save the document, I want to add a document-level script that checks if the certificate is valid. If the certificate is valid, I would like to  schedule an interval object to update some of the icons in the fields. Is this possible? If so, how do I get the “certificate (not visible) field” and check that it is valid
    Thanks. - john

    I am using Acrobat XI Pro running in Windows 8.
    I created a PDF document with form fields (type: button) and JavaScript codes (field-level and document-level). Before I certify (not visible) and save the document, I want to add a document-level script that checks if the certificate is valid. If the certificate is valid, I would like to  schedule an interval object to update some of the icons in the fields. Is this possible? If so, how do I get the “certificate (not visible) field” and check that it is valid
    Thanks. - john

  • ALV not displaying zeros

    Hi,
    I am calling 'REUSE_ALV_GRID_DISPLAY' and it is not displaying zeros in two fields. I mean for all the values which are 0.00  it is just showing blanks in  ALV.
    Internal table is populated properly.
    Pls help

    try giving the datatye in fieldcatalog
    wa_fieldcat-datatype = 'CURR'

  • How to prevent a text in script from displaying if its value is zero

    Dear all,
    How to prevent a text in script from displaying if its value is zero
    for eg   Price  = 0.00
    if price is 0 it should'nt appear in output.
    I tried with    if price ne 0.
                       price = &price&
                        endif.
    but it's not working.
    Regards
    Raj
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Jan 20, 2009 8:59 AM

    Hello Nagaraju,
                           What you were doing is partially right.
    The correct format to write in the script is as follows :
    /:  if &PRICE& ne 0.
      &PRICE&
    /:  endif.
    This should work. Let me know how it goes.
    Nayan

  • When we drilldown at document level it displays one record for each cube

    Dear Experts .
    The users want to see the report by status for the order detail report at document level it displays one record for each cube .
    They want to see the single line for the order quantity , Amount, Billing quantity delivery and amount along with the Sales order number , billing document number billing date , delvert date ..et in signgle line. ( Sale order DeliveryBilling)
    When we are doing on Multiprovider recording displaying from each cube.
    We have tried with Constant selections and it is not giving the required results m since these want to see by status. Due to huge data performance reasons we re unable to use it .
    Please provide your valuable inputs.
    Thanks,
    Mahesh.

    Mahesh,
    If you want to get detail data with respect to Sales order - delivery - Billing, on top of Multiprovider you can come up with Constant selection.
    But I am not clear that why constant selection is not working properly, can I have some light on that.
    Probably, you are struggling with multiple records .
    I suggest you to go with end routine and map all fields to one IC and do reporting on that single IC, then your requirement will fulfill.
    But here we need to take care of performance issues and process chain scheduling wile loading deltas.
    If Multiprovider is not working properly , then try with Infoset(If you have more than 2 ICs it not possible).
    Regards,
    rvc

  • MANSP Dunning block at document level display

    Dear Xperts,
    I dont see the field MANSP "Dunning block" at document level (for an invoice), transaction FB03. I have chequed the field status defined for the posting key, but I cant find this field. What can be the reason the I dont see this field at document level?
    Best regards.
    Cristóbal.

    Hi,
    Actually when the dunning run is executed, the documents gets the dunning block MANSP field and gets stored in table MHNK/ MHND. This block MANSP gets deleted from these tables when the dunning run is completed.
    Sometimes the entry remained there, even after the dunning run completion and thus not considering customer for any next dunning run.
    You can run the report RFMAHN21 in transaction SE38/ SA38 to check these blocked items.
    Also check the below OSS notes if not applied in your system:-
    https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=1005739
    https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=1092805
    Regards,
    Gaurav

Maybe you are looking for