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

Need a check on a script I've used for show/hide

Contributor ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

The below is in the custom validation script box of a field (model4) on page 3 of my document and if absolutely any content is added to that field, a message appears on page 1. 

- on the document as a standalone, the first part works well, but if the content is removed from the model4 field, the message on page 1 doesn't revert to hidden

- if the document is used through an automated system, it merges with content in the field model4, but the message on page 1 doesn't appear.

Have I missed something or made a mistake?

if (event.value.length == 0) {

this.getField("Cont onto Sch22").display = display.hidden;

} else {

this.getField("Cont onto Sch22").display = display.visible;

}

 

 

TOPICS
Acrobat SDK and JavaScript

Views

355

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 ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

Where did you place the code?

Merging or importing data into a file doesn't trigger any of the scripts in it. If you're using a script to import the data then you can add a command to force calculations to happen, but if you're using the built-in Import Form Data command that's not possible. You can do it when the file is opened, or saved, though.

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
Contributor ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

The code is in the custom validation script box of 'model4'

The merged data is coming from an opportunity in Salesforce

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 ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

Hi,

 

Curious as to what you mean by "Automated System"?

 

Regards

 

Malcolm

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
Contributor ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

The data is coming from an opportunity in Salesforce, so the user merges it all using Conga

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 ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

A validation script is only triggered when a user enters information into the field. If you fill in data via a process that does not involve the user interface, the validation script is never triggered. One thing you can do is to create a document level script that is outside of a function scope. Such a script will be executed every time the document gets opened. That script would then loop over all fields that can potentially contain data and check if there is data entered. The first time you encounter a field that has data, you show the field on page 1, if you make it all the way through the list without finding data, you hide the field. 

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
Contributor ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

That explains why it doesn't work then - the user isn't entering data, it's automatically merging.

I acutally have very little knowlege of writing scripts (the above was a lucky guess) so the document level script you refer to, would that be able to make the hidden field visible if content was automatically added in the specific field?

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 ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

Only the next time you open or save the file, and you'll need to adjust the code for it to work.

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
Contributor ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

LATEST

I think I've found an easier way round this - there's a tick box associated with 'model4' and this has to be ticked manually, so I'll add a script to that to make the message visible/hidden.

 

@try67 and @Karl_Heinz_Kremer - I now know scripts do not trigger if data is merged. This will be very helpful going forward, so thank you.

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