6 Replies Latest reply on Sep 24, 2012 7:55 PM by LaRetta

Hi- I am new to this forum, so go easy on me. need help with a script

is there and easy way to create a script with a two part if statement? i.e.: if the fruit is "round" (result from shape field) and the color is " orange" (result from color field) then the result to be entered in a result column is "an orange"?

• 1. Re: Hi- I am new to this forum, so go easy on me. need help with a script

Nested If ( ) steps will do it. This part of your script will look something like this:

If ( shape field = "round" )

If (colour field = "orange" )

do this

Else

do the other

End If

End If

Cheers!

• 2. Re: Hi- I am new to this forum, so go easy on me. need help with a script

THANK YOU !!!

• 3. Re: Hi- I am new to this forum, so go easy on me. need help with a script

I trust you grasp the underlying logic. The second If( ) is just the "true" response to the first If( ). Thus you can nest as many as you like, and also use Else If ( ), to extend the logic for further possibilities. I thought afterwards I could have been more specific to help, so:

If ( shape field = "round" )

If ( colour field = "orange" )

do this if round and orange

Else If ( colour field = "green" )

do this if round and green

Else

do this if round and neither orange nor green

End If

do this if not round

End If

Cheers!

• 4. Re: Hi- I am new to this forum, so go easy on me. need help with a script

Hi Robert,

If the result needs to be entered into a third column, and if the results are based upon the criteria specified then why not use a calculation for the third column (field) so you do not have to run script?

Case (

Shape = "Round" and Color = "Orange" ; "Orange" ;

Shape = "Round" and Color = "Red" ; "Cherry" ;

... enter more values then a final result

"No fruit"

)

If you have very many combinations and/or if you might be changing their name pairs then it would be best to use a table which would probably save you a lot of maintence later.  :-)

• 5. Re: Hi- I am new to this forum, so go easy on me. need help with a script

I feel I should also mention option of using merge variable set in conditional format in place of creating a calculation.  I prefer it unless it's a field used in various places or for exporting, searching, calculating, summarizing and such.

• 6. Re: Hi- I am new to this forum, so go easy on me. need help with a script

And yes you can have Case() or If() within but my point was to use a calc so it is maintenance-free.  The only time it would need to be a standard field is if you might need to change the results or set a related table (which is rare). Sorry I'm explaining in segments.  I' d like to blame the iPad but can't on this one, LOL