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

if file name contains 4th wk drop box name "4th wk" gets automatically yes

Community Beginner ,
Jul 30, 2018 Jul 30, 2018

following up with another question related to filling data in adobe form from the file name...

how do I code to search the file name and if the part of the file name contains a certain name put (or pick) yes in the drop box in the Adobe form?

to clarify....

file name Doe, John (1234) SOAP 01.01.2018PK-4th wk.pdf

as this file name contains 4th wk, put "yes" in the drop box in the Adobe form.

drop box name is "4th wk".

THANK YOU for your help.

I should try to learn javascript and stop bothering people.  once again thank you!

TOPICS
Acrobat SDK and JavaScript , Windows
605
Translate
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

correct answers 1 Correct answer

Community Expert , Jul 31, 2018 Jul 31, 2018

It should work with a drop-down field just as well as with a text field, but keep in mind that JS is case-sensitive, so if they values are "Yes" and "No" then you have to enter them like that into the script, not as "yes" and "no"...

Translate
Community Expert ,
Jul 30, 2018 Jul 30, 2018

Insert this code as a doc-level script in your file (I assume you want "no" to be selected if the file-name does not contain this string):

this.getField("4th wk").value = (/4th wk/.test(this.documentFileName)) ? "yes" : "no";

Translate
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 Beginner ,
Jul 31, 2018 Jul 31, 2018

once again, THANK YOU so much!!

if you can can you make one correction?  code you have provided works for text box.  is there any way to apply the code to drop box in the form?

my drop box has only "Yes" and "No" option.  if it doesnt work I have modified the dorpbox to text and it is working.  just wanted to check if these can be done to drop box.

Please let me know.  thank you much!

Translate
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 ,
Jul 31, 2018 Jul 31, 2018
LATEST

It should work with a drop-down field just as well as with a text field, but keep in mind that JS is case-sensitive, so if they values are "Yes" and "No" then you have to enter them like that into the script, not as "yes" and "no"...

Translate
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