Skip to main content
Inspiring
December 15, 2017
Answered

Certain text in a field

  • December 15, 2017
  • 1 reply
  • 456 views

I have tried so many different ways, that I finally decided to break down and ask the "experts"!  I have a text field where users will input what organization they are with.  I have a popup window "On Focus" that tells the user if they are working for our organization, to input our company name "XYZ"; Otherwise, input whatever.  Later on in the form, there's a submit button to email the PDF form.  If that text field has XYZ G6, it'll send an email to a certain group of people; Otherwise, if that text field doesn't have that key word (XYZ), it sends the email to a different group of people.  Here's what I've been working with:

var sendTo = "john.doe@mail.com";

var sendOther = "bill.jones@mail.com";

var keyWord = this.getField("20 Supervisors Organization").startsWith("XYZ);

if (this.getField("31 Sec Mgr Sig").value != "" && keyWord == true) {

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

} else if (this.getField("31 Sec Mgr Sig").value != "" && keyWord == false) {

   this.mailDoc({bUI:true, cTo: SendOther...

I've tried includes(), valueOf(), and other String Methods, but none of them are working.  Am I even going the right route?

This topic has been closed for replies.
Correct answer try67

Replace line #3 with:

var keyWord = this.getField("20 Supervisors Organization").valueAsString.indexOf("XYZ")==0;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 15, 2017

Replace line #3 with:

var keyWord = this.getField("20 Supervisors Organization").valueAsString.indexOf("XYZ")==0;

SIPRNet11Author
Inspiring
December 15, 2017

Gilad,

I can't wait to have just 1/8th the knowledge you have with javascript!  Thanks!!  Have a great weekend and Merry Christmas!