How to Add a Confirmation Prompt Before Updating a PDF Summary Field
Question details
The user needs a method to ask for confirmation using Acrobat JavaScript before a macro automatically updates a list or summary field in a PDF form.

- Product
- PDF Editors
- Device & OS
- not provided
- Scenario
- Automating PDF form data summarization where a script gathers values from multiple priority fields into a single summary box.
- Observed behavior
- Currently, the script overwrites the summary immediately. The goal is to display a Yes/No prompt; if 'No' is selected, the existing summary must remain completely unchanged.
Ensure that your PDF software supports JavaScript for interactive forms (such as Acrobat Pro or advanced PDF editors) and always back up your original PDF file before adding custom scripts.
Implement an app.alert Yes/No Prompt in PDF JavaScript
Use the built-in app.alert function to create a confirmation dialog that controls whether the data extraction loop executes, preserving existing data if canceled.
The app.alert method in PDF JavaScript allows you to display a dialog box with specific buttons. By setting the button type to Yes/No, you can capture the user's choice. If the user clicks 'Yes', the function returns a value of 4, which you can use as a condition to run your form field loop. If 'No' is clicked, the loop is skipped entirely.
Right-click the button or field that triggers the summary update, select 'Properties', and navigate to the 'Actions' tab.
Select 'Run a JavaScript' from the Select Action dropdown menu, then click 'Add' to open the JavaScript Editor.
Wrap your existing field loop inside an if statement using app.alert. Type: if (app.alert("Retrieve opportunities and skills priorities?", 1, 2) == 4) {
Inside the if block, initialize your variable and loop through your fields. For example: var total = ""; for (var i = 1; i <= 92; i++) { if (this.getField("priority" + i).valueAsString != "Off") total += "• " + this.getField("Text" + i).valueAsString + "\n"; } this.getField("summary").value = total; }

Create, Edit, and Manage PDF Forms with WPS Office
WPS Office provides a comprehensive suite of PDF tools, allowing you to easily view, edit, and manage interactive PDF forms. Experience seamless PDF form handling alongside fully compatible Word, Excel, and PowerPoint alternatives in one lightweight application.
- 1. Download and Install: Download WPS Office from the official website and launch the application on your device.
- 2. Open your PDF: Click 'Open' and select your interactive PDF form from your local files.
- 3. Fill and Edit Forms: Navigate to the 'Form' or 'Edit' tab to interact with, highlight, or fill out various form fields securely.
- 4. Save and Export: Save your completed PDF or export it directly without losing any form functionality or data.

Frequently Asked Questions
What do the numbers '1, 2' mean in the app.alert function?
In Acrobat JavaScript, the '1' represents the icon type (displaying a Warning or Question icon), and the '2' represents the button group (displaying Yes/No buttons instead of just an OK button).
Why does the if statement check if the alert equals 4?
When an app.alert dialog displays Yes/No buttons, clicking 'Yes' returns an integer value of 4. Clicking 'No' returns 3. Checking for 4 ensures the code only runs when the user explicitly agrees.
Will this JavaScript work on mobile PDF readers?
Most mobile PDF readers have limited or no support for Acrobat JavaScript. This confirmation prompt is best suited for desktop PDF applications like Adobe Acrobat or advanced desktop PDF editors.




