Skip to main content
ytk1978
Known Participant
July 30, 2018
Answered

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

  • July 30, 2018
  • 1 reply
  • 641 views

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!

This topic has been closed for replies.
Correct answer try67

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"...

1 reply

try67
Community Expert
Community Expert
July 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";

ytk1978
ytk1978Author
Known Participant
July 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!

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 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"...