Skip to main content
ytk1978
Known Participant
July 30, 2018
解決済み

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

  • July 30, 2018
  • 返信数 1.
  • 647 ビュー

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!

このトピックへの返信は締め切られました。
解決に役立った回答 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

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
ytk1978作成者
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 Expert解決!
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"...