Skip to main content
Participating Frequently
February 25, 2026
Question

valueAsString for Pool GPM Calculation

  • February 25, 2026
  • 2 replies
  • 22 views

Hello, I'm creating a GPM sheet for pool applications and need assistance with my final task. I've created a dropdown list that toggles the visibility of 3 types of sheers. My goal is whenever the user inputs the LF (Sheer1LF), the GPM (Sheer1GPM) updates with the number associated with it in the "SheerGPMScript". I believe I have to use valueAsString, but I'm not too great at applying it.

 

Here is the sheet for anyone who wants to take a crack at it.

    2 replies

    Nesa Nurani
    Community Expert
    Community Expert
    February 26, 2026

    Use this in one of the text fields as custom calculation script:

    var LF1 = this.getField("Sheer1LF").value;
    var LF2 = this.getField("Sheer2LF").value;
    var LF3 = this.getField("Sheer3LF").value;

    var Gsc = this.getField("SheerGPMScript").value;
    var Tsc = this.getField("SheerTypeScript").value;
    var Vsc = this.getField("SheerVisibilityScript").value;

    var sheer1 = this.getField("Sheer1GPM");
    var sheer2 = this.getField("Sheer2GPM");
    var sheer3 = this.getField("Sheer3GPM");

    function setIfValid(lf, targetField, scriptValue) {
    var num = Number(lf);
    targetField.value = (lf !== "" && !isNaN(num) && num !== 0) ? scriptValue : "";}

    setIfValid(LF1, sheer1, Gsc);
    setIfValid(LF2, sheer2, Tsc);
    setIfValid(LF3, sheer3, Vsc);

     

    AnandSri
    Community Manager
    Community Manager
    February 25, 2026

    Hello ​@Deron274936856sel 

     

    I hope you are doing well, and thank you for reaching out.

     

    In Acrobat (AcroForms), the supported/standard way to auto-update one field from another is to make the target field calculated and set its value via a Custom calculation script (or, for performance, use a Validation script on the driving field). Here Adobe’s help article on where to configure calculations and how to set calculation order so dependent fields compute correctly: https://helpx.adobe.com/acrobat/desktop/work-with-pdf-forms/customize-form-fields/set-calculation-fields.html

     

    Suggestions: 

    Please note that these are sample scripts and may require modifications based on your needs and the system or user environment.

     

    Compute GPM from LF × rate: 

    Use this when SheerGPMScript stores a GPM-per-linear-foot rate (or any numeric factor), and the user enters LF in Sheer1LF.

     

    • Put a Custom Calculation Script on Sheer1GPM
      • In Acrobat: Go to All Tools > Prepare Form > Right‑click Sheer1GPM > Properties > Calculate > Custom calculation script > Edit.
      • Paste:

      • !--scriptorstartfragment-->

        // Sheer1GPM = Sheer1LF * SheerGPMScript

         

        var lfStr   = this.getField("Sheer1LF").valueAsString;

        var rateStr = this.getField("SheerGPMScript").valueAsString;

         

        // If either input is blank, keep result blank

        if (lfStr === "" || rateStr === "") {

          event.value = "";

        } else {

          var lf   = Number(lfStr);

          var rate = Number(rateStr);

         

          // If parsing fails, keep result blank

          if (isNaN(lf) || isNaN(rate)) {

            event.value = "";

          } else {

            event.value = lf * rate;

          }

        }!--scriptorendfragment-->

     

    2) Ensure calculation order is correct: 

    If SheerGPMScript is itself being set/updated by your dropdown logic, make sure Acrobat calculates SheerGPMScript before Sheer1GPM using Set field calculation order (Fields pane options).

     

    I hope this helps.

    Regards,

    Anand Sri.

    Participating Frequently
    February 25, 2026

    @AnandSri, Thank you for your reply.

     

    The Sheer1GPM updates perfectly the first time a selection is made. However, when changing to a different Sheer Type, the SheerGPMScript does not update the event value to reflect the correct rate.

    try67
    Community Expert
    Community Expert
    February 26, 2026

    Check the Field Calcluation Order in the file.