Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Behaviors Help

Marc Jason Mutuc
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2019

These are the requirements for a behavior I am trying to do using two fields

Release Notes is a Multi-line Text field

Use Release Notes is a Checkbox field with Yes as an option

By default, Release Notes is hidden

Requirements

1. When "Use Release Notes" is Yes and Release Notes is NULL, populate Release Notes with ABCDE and unhide it.

2. When "Use Release Notes" is Yes and Release Notes is NOT NULL, do not overwrite Release Notes and unhide it.

3. When "Use Release Notes" is NULL, clear Release Notes and hide it. If "Use Release Notes" is ticked once again, populate Release Notes with ABCDE and unhide it.

 

Initialiser below:

def childField2 = getFieldByName("Release Notes")

childField2.setHidden(true)

 

Here is my script on the field "Use Release Notes"

def childField1 = getFieldByName("Use Release Notes")
def childField2 = getFieldByName("Release Notes")
def childField1o = childField1.getValue() as String
def childField2v = childField2.getValue() as String
//def parentField = getFieldById(getFieldChanged())
//def selectedOption = parentField.getValue() as String
def defaultValue = "ABCDE"

if (childField1o == "Yes" && childField2 == null)
//if (childField1o == "Yes")
{

childField2.setHidden(false)
childField2.setFormValue(defaultValue)

}
else if (childField1o == "Yes" && childField2 != null)
//else if (childField1o == "Yes")
{

childField2.setHidden(false)

}
else
{

childField2.setHidden(true)
childField2.setFormValue(null)

}

Problem is, the ABCDE is not applied. Can someone please comment on the code? Appreciate it very much.

1 answer

1 accepted

1 vote
Answer accepted
Antoine Berry
Community Champion
June 4, 2019

Hi @Marc Jason Mutuc ,

I would use childField2v instead of childField2 and test it against an empty string :

if (childField1o == "Yes" && childField2v == ""){ ....

else if (childField1o == "Yes" && childField2v != ""){ ...

Antoine

Marc Jason Mutuc
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 4, 2019

Works! I have a similar ticket for support and they are still asking for logs. Decided to go here as usual which gives better responses. 

Like # people like this

Suggest an answer

Log in or Sign up to answer