Skip to main content
yanksgirl
Inspiring
October 2, 2019
Answered

Set value of textbox based off of value in other fields

  • October 2, 2019
  • 1 reply
  • 1186 views

I have a form that has a Yes or No question, however, the Yes or No question is based off of the answer to FOUR different mapped fields.  If ANY of those mapped fields populate a Y value then I want my textbox to have a Y entered, else "".  I'm using the following script but I cannot get it to work.

 

var a = this.getField("APPLICANT_1_BANKRUPTCY").valueAsString;
var b = this.getField("APPLICANT_1_OUTSTANDING_JUDGMENTS").valueAsString;
var c = this.getField("APPLICANT_1_FORECLOSED_REPOSSESSED").valueAsString;
var d = this.getField("APPLICANT_1_PARTY_TO_LAWSUIT").valueAsString;
if (a=="N" && b=="N" && c=="N" && d=="N") event.value = "";
else event.value = "Y";

 

 

  Also, the four mapped fields that the box is drawn off of map at different times, so if the first box comes in at N and the second at Y, then I need the box to populate Y, and I don't want it to change if the other 2 mapped fields come in at N.  I also tried dabbling with an array script, but I'm self taught and am making a mess I think lol.

 

Any help would be appreciated!

    This topic has been closed for replies.
    Correct answer George_Johnson

    Based on what you stated and assuming you placed the script as the custom calculation script for the text field, that if statement should be:

     

    if (a == "Y" || b == "Y" || c == "Y" || d == "Y") event.value = "Y";

    else event.value = "";

    1 reply

    George_JohnsonCorrect answer
    Inspiring
    October 2, 2019

    Based on what you stated and assuming you placed the script as the custom calculation script for the text field, that if statement should be:

     

    if (a == "Y" || b == "Y" || c == "Y" || d == "Y") event.value = "Y";

    else event.value = "";

    yanksgirl
    yanksgirlAuthor
    Inspiring
    October 3, 2019

    Thank you George, this worked perfect. I mixed up my logic I guess!

     

    Can I ask another question?  Can I have two if statements in the same script?  Using the script you gave me, the default of the field is N, which means it's going to print as N if the document is not being populated with information from our system (say to be mailed out) and then the person is going to have to cross out the N and put a Y if any of the 4 mapped field values are true.  Can I have it make the box Y if any of the 4 are Y, N if ALL of the 4 are N, else "" as the default?

     

    Does that makes sense?

    yanksgirl
    yanksgirlAuthor
    Inspiring
    October 3, 2019

    Nevermind, I figured it out. I did an else if on the next line and made it the &&...see below. Thank you anyways!

     

    var a = this.getField("APPLICANT_1_OUTSTANDING_JUDGMENTS").valueAsString; var b = this.getField("APPLICANT_1_BANKRUPTCY").valueAsString; var c = this.getField("APPLICANT_1_FORECLOSED_REPOSSESSED").valueAsString; var d = this.getField("APPLICANT_1_PARTY_TO_LAWSUIT").valueAsString; if (a == "Y" || b == "Y" || c == "Y" || d == "Y") event.value = "Y";

    else if (a == "N" && b == "N" && c == "N" && d == "N") event.value = "N";

     

    else event.value = "";