Is a drop-down window considered a string?

Feb 07, 2018

Copy link to clipboard

Copied

I ask this because I have and if/then statement set up where if a field has a keyword inputted, then when a submit button is pushed it will send an email to one of two groups.  I'm changing it because users are not "reading" the instructions and half the time, are not putting in the keyword when they should be so it's being emailed to the wrong group.

So I want to change the "if/then" to a different field but that field is a drop-down menu and it doesn't work with the ".valueAsString.indexOf("Keyword") == 0.

Here's part of what I'm working with:

var keyWord = (this.getField("Org").valueAsString.indexOf("Company Name") == 0);

if (this.getField("Signature").value != "" && keyWord == true) {

    this.mailDoc({bUI:true, cTo:sendTo, cCc:copyTo...

I have to run this script in the Button Field.

The "Keyword" should've been "Company Name"...sorry.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

87

Likes

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

Is a drop-down window considered a string?

Feb 07, 2018

Copy link to clipboard

Copied

I ask this because I have and if/then statement set up where if a field has a keyword inputted, then when a submit button is pushed it will send an email to one of two groups.  I'm changing it because users are not "reading" the instructions and half the time, are not putting in the keyword when they should be so it's being emailed to the wrong group.

So I want to change the "if/then" to a different field but that field is a drop-down menu and it doesn't work with the ".valueAsString.indexOf("Keyword") == 0.

Here's part of what I'm working with:

var keyWord = (this.getField("Org").valueAsString.indexOf("Company Name") == 0);

if (this.getField("Signature").value != "" && keyWord == true) {

    this.mailDoc({bUI:true, cTo:sendTo, cCc:copyTo...

I have to run this script in the Button Field.

The "Keyword" should've been "Company Name"...sorry.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

88

Likes

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
Feb 07, 2018 0
Feb 07, 2018

Copy link to clipboard

Copied

The "Keyword" should've been "Company Name"...sorry.

Likes

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
Reply
Loading...
Feb 07, 2018 0
Feb 07, 2018

Copy link to clipboard

Copied

the value of a dropdown is a string in the same sense that all field values are strings. If you use the "field.valueAsString" property it's guaranteed.

If the code is not working, it has nothing to do with whether or not the dropdown value is a string. The most likely issue are the values returned by the drop down.  I'm assuming that the dropdown is named "Org"?

To find out the value returned from the dropdown, run this code from the console window:

this.getField("Org").value

You'll find a tutorial on the Console Window here:Free Video Content & Full Listing of Available Videos

I'd also suggest rewriting the if statement to make the conditions more explicit

Like this:

if ((this.getField("Signature").value != "") && keyWord) {

is it not necessary to test a boolean for "true", since its already true or false.

Likes

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
Reply
Loading...
Feb 07, 2018 0
Feb 07, 2018

Copy link to clipboard

Copied

That worked Thom!  Thank you sir!

Likes

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
Reply
Loading...
Feb 07, 2018 0