Search code examples
lotusscript

Lotuscript IF statements


I am trying to cycle through multiple fields at once to check if they match a certain value. For example, a document contains field_1, field_2, field_3 ect. They either have a value of "Yes" or "No".

The statement would be read like this:
IF field_1 OR field_2 OR field_3 = "Yes"
I am not trying to test if ALL fields are = to YES. They should be checked independently.

If it's not too difficult, I would also like to create an IF statement to match 2 group of fields.

Example:
IF field_1 OR field_2 OR field_3 = "YES" AND other_1 OR other_2 OR other_3 = "NO"


Solution

  • Assuming your fields contain single-value string values, then this will work (using the dot notation syntax):

    If (doc.field_1(0) = "Yes" Or doc.field_2(0) = "Yes" Or doc.field_3(0) = "Yes") And (doc.other_1(0) = "NO" Or doc.other_1(0) = "NO" Or doc.other_1(0) = "NO") Then
        ' Do stuff
    End If
    

    This assumes that the doc variable contains a reference to the document in question.

    Instead of the dot syntax you can also access the field values using doc.getItemvalueString("field name").