Need Assistance With Custom Calculation Script

I need help with a custom calculation script in Acrobat Pro.  I am trying to add the sum of fields A, B, C, D, E, F, and G together with the lesser value of fields H and I.  What would be the script to enter for this result?  Thank you.

event.value = Number(this.getField("A").value) + Number(this.getField("B").value) + Number(this.getField("C").value) + Number(this.getField("D").value) + Number(this.getField("E").value) + Number(this.getField("F").value) + Number(this.getField("G").value) + Math.min(Number(this.getField("H").value), Number(this.getField("I").value));

Similar Messages

  • Need Help With Custom Calculation Script

    Hey everyone.  I'm using Acrobat Pro X and stumbling a bit on the syntax for the following equation.  I need to add the value of "Cell1" & "Cell2" then add the value of "Cell3".  However,the value of "Cell3" is entered by the user and specifies a percentage of the sum of "Cell1 & "Cell2".  For example: If the user enters "3" into "Cell3" I need the returned value to be 3% of the sum of "Cell1" + "Cell2".  If the user enters "9" into "Cell3" I need the returned value for "Cell3" to be 9% of the sum of "Cell1 & Cell2" and the end result needs to be the sum of "Cell1+Cell2+Cell3".  In greater detail:
    If "Cell1" = $500, "Cell2" = $500 and "Cell3" = "3" then I need the returned value to be $1030.00.
    I hope this makes sense. Here's what I have so far but alas, it's not working.  Any help would be GREATLY appreciated.
    // Get first field value, as a number
    var v1 = +getField("Cell1").value;
    // Get second field value, as a number
    var v2 = +getField("Cell2").value;
    // Get processing field value, as a number
    //var v3 = +getField("Cell3"/100).value;
    // Calculate and set this field's value to the result
    event.value = v3+(v1+v2);
    Thanks,
    Solan

    I posted an answer but realized it wasn't what you wanted. There is some confusion about what you want for Cell3. On the one hand, you say you want the user to enter a vaule in the field, but them you say you want its value to be calculated based on what the user enters and two other field values. It seems to me Cell3 should be the field that the user enters the percentage and the calculated field's (Cell4) script could then be:
    // Get first field value, as a number
    var v1 = +getField("Cell1").value;
    // Get second field value, as a number
    var v2 = +getField("Cell2").value;// Get processing field value, as a number
    // Get the percentage
    var v3 = +getField("Cell3").value;
    // Calculate and set this field's value to the result
    event.value = (1 + v3 / 100) * (v1 + v2);

  • Help with Custom calculation script in Acrobat 8

    Hi all, I am using acrobat 8 on OS 10.5
    I am trying to add certain fields (numbers) and then subtract another field value to give an end result.
    I don't know anything about Javascript, would anyone be able to help with any info on how I achieve this result? I can only see Add, x and average etc... nothing there for subtraction
    Thanks for any help in advance
    Swen

    This should get you started:
    >if (event) {
    // get values from two text fields
    var a = Number(this.getField('Text1').value);
    var b = Number(this.getField('Text2').value);
    // subtract the values and show it
    this.event.target.value = a - b;
    Place this in a 3d text field, as a Custom Calculation Script.

  • Error message with custom calculation script

    I am currently trying to add two fields and multiply them by another. I got the script working, however, when I clear the form, i get this message:
    "The value entered does not match the format of the field [total.sectionA]"
    Here is what I have entered into the custom calculation window:
    event.value = (this.getField("sponsor.level").value +
        this.getField("sponsor.addedtabs").value ) *
    this.getField("total.months").value;
    I'm not very knowledgeable in the area of Java, and would rather use a simple field notation. But I can't get that to work at all. Here is what I have tried:
    (sponsor.level + sponsor.addedtabs) * total.months
    Thanks in advance for any help or advice that comes my way!
    i

    'Simplified field notation' will not work because you are not using simplified field names. You can not use spaces, dots, or other special characters in the 'simplified field notation'. You can also not use any method, function, or any type of control statement.
    What are all the possible values of the 'sponsor.level'?
    Are there any other calculations in the form?
    Are you perforning a division anywhere else on the form?

  • Custom calculation script for checkboxs

    Hello,
    Can anyone help me out with custom calculation script for this?  I have two mutually exclusive checkboxes that, when checked, I want to populate data into other text fields.
    If Checkbox1 is checked:
    Company1=Warehouse Alpha
    Address1=1234 Any Street
    City/State/Zip1= Los Angeles, CA 90020
    Contact Name1= Mr. Nice Guy
    Phone Number1= 213-854-8565
    Email1=[email protected]
    If Checkbox2 is checked:
    Company2=Warehouse Beta
    Address2= 5678 Awesome Blvd.
    City/State/Zip2= San Bernardino, CA 96545
    Contact Name2= Mr. Handsome
    Phone Number2= 909-824-8265
    Email2=[email protected]
    Thanks,
    Bryan

    So one has two check boxes and one wants them to be mutually exclusive. Name them the same and change the export value of the field. Try it and observe what happens as you check the different check boxes.
    You have described what happens if either box is checked but what happens when a checked box Is unckecked?
    One can place scripts in many locations. I would use a mouse up action for both the check boxes, use the same script for both check boxes.
    I would assume you are using the following names for the fields to populate:
    Company
    Address
    CityStateZip
    ContactName
    PhoneNumber
    Email
    // Mouse up action for both check boxes;
    // initial value for the fields:
    this.getField("Company"),value = "";
    this.getField("CityStateZip"),value = "";
    this.getField("ContactName"),value = "";
    this.getField("PhoneNumber"),value = "";
    this.getField("Email"),value = "";
    // test for check box value for selected box;
    if(event.value == 1) {
    this.getField("Company"),value = "Warehouse Alpha";
    this.getField("CityStateZip"),value = "1234 Any Street";
    this.getField("ContactName"),value = "Los Angeles, CA 90020";
    this.getField("PhoneNumber"),value = "213-854-8565";
    this.getField("Email"),value = "[email protected]";
    if(event.value == 2) {
    this.getField("Company"),value = "Warehouse Beta";
    this.getField("CityStateZip"),value = "5678 Awesome Blvd.";
    this.getField("ContactName"),value = "San Bernardino, CA 96545";
    this.getField("PhoneNumber"),value = "Mr. Handsome";
    this.getField("Email"),value = "[email protected]";
    // end Mouse up action for both check boxes;

  • Custom Calculation Script Help Needed

    I need to make a script that Sums a column of fields based on whether or not information found in another column of fields is the same or specific text. Please see below screenshot of what I would like it to do.
    I would like a Sum of all Amounts that have the Code A...

    You can use this script as the custom calculation script of "SumOfA":
    var total = 0;
    for (var i=0; i<=2; i++) {
        if (this.getField("p1TC."+i).value=="Code A")
            total+=Number(this.getField("p1RecIn."+i).value);
    event.value = total;
    You can easily adjust it for the other field as well.

  • How to convert an Excel Formula to a Custom Calculation Script in a Adobe Acrobat 9 Form?

    Hello,
    I am not familiar whatsoever with Javascript and need some help in converting the following Excel Formula so that I can enter it into a Custom Calculation Script in a Adobe PDF Form. Here is the formula:
    =IF(E15<25.01,9.95,IF(E15<50.01,11.95,IF(E15<75.01,13.95,IF(E15<100.01,16.95,IF(E15<150.01 ,19.95,IF(E15<200.01,24.95,IF(E15>200.00,E15*0.125)))))))
    Where "E15" will be the text field named "Subtotal" on my Adobe PDF Form.
    Thank you for any help you can provide!

    Fortunately JavaScript has the 'switch' statement so nested if statements can be avoided.
    var E15 = this.getField("Subtotal").value;
    switch(true) {
    case (E15 < 25.01) :
    event.value = 9.95;
    break;
    case (E15 < 50.01) :
    event.value = 11.95;
    break;
    case (E15 < 75.01) :
    event.value = 13.95;13
    break;
    case (E15 < 100.01) :
    event.value = 16.95;
    break;
    case (E15 < 150.01) :
    event.value = 19.95;
    break;
    case (E15 < 200.01) :
    event.value = 24.95;
    break;
    case (E15 > 200) :
    event.value = E15 * 0.125;
    break;
    default:
    event.value = "";
    break;
    } // end switch;

  • Is it possible to use extensive formulas (e.g. "if" or vlookup functions) in the "Custom Calculation Script"?

    I am working on a form fill PDF converted from MS excel. This is for others to use who don't have MS excel that need to use my spreadsheet.
    1. I would like to know how complex can the formulas be in the custom calculation script in the calculate tab under properties in a cell menu?
    2. Where can I find what formulas will work in the custom calculation script along with the format for those formulas to work correctly (tutorials would help)?
    I have tried writing an "if" function but received and error so I am assuming either functions don't work in the script or there is a different format than standard spreadsheet formats.
    Bruce

    In that case the for loop would be:
        for (var i = 0; i < 8; i += 1) {
            sum += +getField("Total." + i).value;
    So initially, the counter i is equal to zero, so the field name used with the getField method is:
    "Total." + 0, which results in the string "Total.0". With each iteration, the variable i is incremented by 1, so the subsequent field names are the following:
    "Total.1"
    "Total.2"
    "Total.3"
    "Total.4"
    "Total.5"
    "Total.6"
    "Total.7"
    The script gets the value of each field, converts it to a number, and adds the number it to the running sum.

  • Custom Calculation Script - Multiplication IF

    Hey Adobe peeps, need help here. I'm not a programmer by any stretch of the imagination, but I am resourceful, BUT I have yet to find a concrete answer for this, nor can I get any of my test formula's to work.
    I have a fillable PDF that is used in a field service environment where employees track their time. I want them to be able to input the data in i.e. hours*rate and it automatically populate the price/cost. Now this is very easy to do with the built in product function, but the problem here is that they have multiple fields to fill out. See below.....
    So basically the "Extended Price" field depends on what they enter into either the "Days", "ST Hours", "Rate, "OT Hours" or "Rate" fields.
    The calculation should be based on 2 of the 5 fields being filled out. For example, here are the 3 possible scenarios:
    Scenario 1: SP Extended Price1=SP Days1*SP ST Rate1
    Scenario 2: SP Extended Price1=SP ST Hours1*SP ST Rate1
    Scenario 3: SP Extended Price1=SP OT Hours1*SP OT Rate1
    They won't ever fill out any more than 2 of the fields so it needs to be an 'if' type of function. I've spent hours on this already, like I said, I'm not a programmer.
    Please help.

    If they really won't be filling in more than one of those sets of fields, the custom calculation script could be:
    (function () {
        // Get the field values, as strings
        var s1 = getField("SP Days1").valueAsString;
        var s2 = getField("SP ST Rate1").valueAsString;
        if (s1 && s2) {
            event.value = +s1 * +s2;
            return;
        var s3 = getField("SP ST Hours1").valueAsString;
        if (s2 && s3) {
            event.value = +s3 * +s2;
            return;
        var s4 = getField("SP OT Hours1").valueAsString;
        var s5 = getField("SP OT Rate1").valueAsString;
        if (s4 && s5) {
            event.value = +s4 * +s5;
            return;
        // If none of these apply, set the field to blank
        event.value = "";

  • Character Limit to Custom Calculation Script?

    Hi. I have a document that has a text form field. I want to run a custom calculation script that basically says if field "Group Number" = xxxxxxx, then field "Group Name" should = ABC Company.
    I have a list of almost 575 group numbers and names that I need to put in the script. And I've got the script working just fine but I am guessing there is a character limit to the script field???? It won't let me put my full list in there.
    Any suggestions on how to get around this??
    Thanks,
    Brandy

    I think I might have one error but I thought I had corrected it. Let me run this by you. My "if" lines are like this:
    if(a == '88096') event.value = 'Stacy's Carpet Steam Cleaning Company';
    But the code doesn't seem to like the ' in the Group's name. Is there a way to correct that without getting rid of the ' .... ?????

  • How do I create an "if" function in a custom calculation script?

    I need to take a simple "value is the sum of" and make it so if one field is less than 1 then the result of the formula will equal "0".
    For example here is a simple "sum of" script:
    Incent Bns.26, Time Bns.26, Spec Bns.26.
    Now converted to a custom calculation script:
    event.value = ((this.getField("Time Bns.26").value) + (this.getField("Incent Bns.26").value)) + (this.getField("Spec Bns.26").value);
    Where Time Bns is calculated by looking at another field Hours26 using a special formula to calculate the bonus.
    I would like to add something like an "if" function to the script so that if the Hours26 field is less than 1 then the output of the script will equal "0".
    I tried this already:
    var rank = this.getField("Hours26").value
    var value = 0
    if (rank < 1) {
      value = 0
    else  (rank > 0) {
       value = ((this.getField("Time Bns.26").value) + (this.getField("Incent Bns.26").value)) + (this.getField("Spec Bns.26").value);
    event.value = value
    But get the error: SyntaxError : missing ; before statement 7 at line 8:
    Thanks ahead of time for any help.
    Bruce

    Try this:
    var rank = this.getField("Hours26").value;
    var value = 0;
    if (rank < 1) {
      value = 0;
    } else {
       value = ((this.getField("Time Bns.26").value) + (this.getField("Incent Bns.26").value)) + (this.getField("Spec Bns.26").value);
    event.value = value;

  • Custom Calculation Script to copy value of a field

    Hi,
          I'm trying to copy the value of a field into another field and display it in the pdf. This is for the 1099's. We are trying to print 2 copies(Copy B and Copy 2) in one page. The first field will come from the XML file. I need to copy the value of this field into the second field. Can anyone please help me with the calculation script for this. I tried the getField.value and it didn't work in the pdf. Thanks.
    With Regards,
    Satishpdf.

    Hi,
    There are a couple of approaches.
    One would be to put the script in the radio buttons that when clicked would do the calculate and set the value of the numeric field.
    Another would be to have the script in the calculate event of the numeric field looking back at the value of the radio button. Taking this approach the script in the numeric field calculate event would look like this:
    if (radioButton.rawValue == 1) // radio button bound to 1 is on/yes
         this.rawValue = ; // your calculation goes here
    else
         this.rawValue = null;
    This is testing the value of the radio button and then taking appropriate calculations.
    Hope that helps,
    Niall

  • Custom Calculation Script Question

    I'm flying blind here, I know nothing about this stuff. I just need something i can copy and paste into the "custom calculation script" box.
    I'm working on making a character sheet for star wars saga edition auto calculate. The only thing I have left before it is completely done is one last calculating field. However, I have no clue how to do it.
    What it needs to do is take the value from one field (user entered info) and then divide it by 2, always rounding down.
    The field the user enters a number in is named "Level" and the field that needs to display that number is named "1/2lvl".

    If no one answers here you can try the Acrobat Scripting forum.

  • Custom calculation script not working

    Hi...
    I've been looking at the samples and searching but have yet to make my custom calculation script work.  The bottom line is that I want one field to be blanked out if another is populated.
    My script currently looks like this:
    event.value = (getField("List_B1") + '').length > 0 ? '' : getField("List_A1");
    I've also tried
    event.value = (getField("List_B1").value + '').length > 0 ? '' : getField("List_A1").value;
    Neither result in List_A1 being empty when List_B1 has something in it.
    Anyone see something I'm missing?
    Thanks
    Mark

    The fields are being processed in programmatically.  The request came in that when we save the form values as a pdf that they don't want any List A value to show if List B has a value set.  So to give an example the inputs would be
    List A : foo
    List B : bar
    List C : baz
    What I'm trying to do with the custom calculation is to have the output pdf be
    List A:
    List B: bar
    List C: baz
    at least that's what my script was aiming for, but what's coming out is
    List A : foo
    List B : bar
    List C : baz
    Come to think about it, it probably has to do with the order with which the fields are being set and the expression fires.  In other words, it could be that when List A is set, List B hasn't been set yet, so the expression's a no-op...
    Thanks
    Mark

  • Custom Calculation Script for building in a percentage increase

    Hello all,
       Looking for a custom calculation script that will apply a percentage increase to a default value when the value of another cell goes above certain numbers. Crude example below.
    Y is the cell that the script will be applied to.
    if value of cell X > 10 then value of cell Y = default value * .10 ..... for 10%
    if value of cell X > 20 then value of cell Y = default value * .20...... for 20%
    if value of cell X > 30 then value of cell Y = default value * .30....... for 30%
    Pleaes forgive me. I know my example above is not in true Java form because I really do not know Java that well. Thanks for any help that you all may provide!

    I've inserted the picture above to help. This is a sizing form for pants for a fire department that will be filled out at the department by the firefighter. The manufacturer that makes the pants passes along a 10% upcharge for anyone with a waist 44-50, a 20% upcharge for anyone with a waist 52-54, and a 30% upcharge for anyone with a waist 56-58. The $42.95 in the "Price" cell is the default price for anyone with a waist that does not meet up-charging penalties (Less than a 44 waist). What I am trying to do is if the firefighter plugs in let's say a waist of 50" the "price' cell will update to show an increase of 10%. ($47.24). If he plugs in a waist of 52" the "price" cell will update to show an increase of 20% ($51.54). If he plugs in a waist of 56" the "price" cell will update to show an increase of 30% ($55.83). I hope that makes sense. I know it can be frustrating helping someone that may not know all the ins and outs like a lot of you do so I greatly appreciate your patience and your help!

Maybe you are looking for

  • Basic questions about Bigdata, NOSQL and Hadoop

    Hi, I've basic questions related to Bigdata. (I've googled it but still wants to confirm with experts) Please correct me if I am wrong on below. 1) As far as I know big data is collection of unstructured data. Even we can store relational data as wel

  • What would cause my autofill to stop working?

    I have an iPad 2 with wi-fi and 3G.  I also have an iPad 1 with just wi-fi.  Both iPads are 64 GB. I am the sole user and both iPads were brand new when I received them. Can someone please help me? I have broken both my hands in the past and I am sur

  • How to use Java Action in fault policy

    Hi , I want to execute custom java Action as fault handler in fault-policy implemntation. I have done but it is not working. I am putting code for fault-policies.xml and also java Action class. <?xml version="1.0" encoding="UTF-8"?> <faultPolicies xm

  • Problem with minus

    Hi , I am facing a strange issue with the MINUS operator in Oracle. Select count(1) from (query 1); COUNT(1) 5298 Select count(1) from (query2); COUNT(1) 5285 I am doing a minus to try to get the extra rows fetched by query 1 (both are selecting the

  • Grayout fields in VA02

    HI, I need to gray out the fields ( like rebate description,external description,validfrom and validto) in VA02 transaction. Please tell me the method of how to do this..? Do i need to write code in user-exit?. thanks Ashok