Hi, how to write nested if in serverside script and check whther value is greater than specific valu

Question 1: How to write nested if (If filed1 equal to "Ready for WOC" and field3 equal to Provider SSCR", then Field2 should be mandatory)

def field1 = getFieldByName("Current Status")
def field2 = getFieldByName("SSCR #")
def field3 = getFieldByName("Type")

if(field1.getValue().equals("Ready for WOC") ) // tried "AND", "&&", "&" but didn't work

  if(field3.getValue().equals("Provider SSCR"))
   

{ field2.setRequired(true) }
else { field2.setRequired(false) }

 

Question 2: How to check if the value is greater than a specific value (If filed1 equal to "Ready for WOC" and field3 greater than 44.52, then Field2 should be mandatory)

def field1 = getFieldByName("Current Status")
def field2 = getFieldByName("Justification for High Blended Rate")
def field3 = getFieldByName("Actual Blended Rate")

if(field1.getValue().equals("Ready for WOC") ) 
   
if(field3.getValue().equals("44.52")) // not able to understand how to say greater than
  
  

{ field2.setRequired(true) }
else { field2.setRequired(false) }

 

Question 3:

How to say "not equal to". I tried "!=" didn't work.

I am trying to say field1 not equal to empty. and field1 is string.

 

Thanks in advance for your help!

 

 

1 answer

Hi Anna,

For Q1: Try this

def field1 = getFieldByName("Current Status")
def field2 = getFieldByName("SSCR #")
def field3 = getFieldByName("Type")
if((field1.getValue().equals("Ready for WOC"))&&(field3.getValue().equals("Provider SSCR"))){}

Hi Anna

For Q3: Try this

if (field1 != null){}

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Service Desk

Wy are we still using email for Service Desk workflows?

...attest to the experience of an urgent approval that gets lost in the boss’s inbox and requires that special “Please Approve” email or text message. In an age where we have distributed teams...

90 views 0 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you