• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
24

Implementing a Button to Check for Latest Form Version

Explorer ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

Hi everyone,
I'm trying to generate a button in my form to allow users to check if they downloaded the latest version online by implementing the code below. For some reason, it doesn't work. I defined the URL of the server where the latest form version is hosted and the latest file name allocated, but it still doesn't run. Any idea why?
----------------------------
var versionCheckUrl = "https://example.com/checkformversion";var xhr = new XMLHttpRequest();
xhr.open("GET", versionCheckUrl, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var latestVersion = xhr.responseText;

var currentVersion = this.getField("versionField").value;

if (latestVersion === currentVersion) {
app.alert("You have the latest version of the form.");
} else {
app.alert("A newer version of the form is available. Please download it from our website.");
}
}
};
xhr.send();

TOPICS
Create PDFs , General troubleshooting , How to , JavaScript , PDF , PDF forms

Views

218

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

Check the JavaScript console (ctrl-j) for errors.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

Thanks @Bernd Alheit I couldn't figure out the issue. Is there easier way to apply so far. As I may over complicating the solution.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

To start, besides the bad formatting, this is not Acrobat JavaScript. If you had looked in the console window you would have seen an error reported on the first line. Something like this;

ReferenceError: XMLHttpRequest is not defined

 

Where did you get this code? 

See the Acrobat JavaScript reference for a list of actual objects and functions in the Acrobat JavaScript model.

 https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/index.html

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

Thanks @Thom Parker, to this stage my knowedge is limited 😞

I didn't know it was that complicated. I had a problem where users download old versions and they don't check back for updates. I'm struggling with this, so I thought if something could check the name of the file with the version and alert users, that would be great. The code from a friend.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

There is a way to do this. And it's not that complicated. 

Use the doc.submitForm() function. You're server side script will need to be modified to return a data format that is acceptable to Acrobat, such as XML, XFDF, or FDF.

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 20, 2024 Apr 20, 2024

Copy link to clipboard

Copied

LATEST

Thanks, @Thom Parker  and @Bernd Alheit , for taking the time to respond to my question. I'll leave it here because I don't have enough knowledge to implement that.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines