Unable to find the proper condition to put within if activity

Hello Community

I have 3 Variables
CCType
CCQty
CCDate

Case 1
If all 3 variables are empty, do nothing.

Case 2
If CCType is present, and CCQty and/or CCDate is present do nothing

Case 3
If CCType is not present, but if CCQty and CCDate is present or if any one if this (CCQty or CCDate)is present.
Then Log message to console “CC type is present. But CCQty and/or CCDate values are present.”

Thank you.

Hi @hansen_Lobo

If String.IsNullOrEmpty(CCType) AndAlso String.IsNullOrEmpty(CCQty) AndAlso String.IsNullOrEmpty(CCDate)
// Case 1: If all three variables are empty, do nothing
// No action needed

ElseIf Not String.IsNullOrEmpty(CCType) AndAlso (Not String.IsNullOrEmpty(CCQty) Or Not String.IsNullOrEmpty(CCDate))
// Case 2: If CCType is present and CCQty and/or CCDate is present, do nothing
// No action needed

ElseIf String.IsNullOrEmpty(CCType) AndAlso (Not String.IsNullOrEmpty(CCQty) Or Not String.IsNullOrEmpty(CCDate))
// Case 3: If CCType is not present, but CCQty and/or CCDate is present
// Log the message to console
Log Message: “CC type is not present. But CCQty and/or CCDate values are present.”

Else
// Any other scenario not covered above
// No action needed
// Optionally, you can add logging or additional actions here

Hope this will help you to understand better.

Cheers!

Can you share the variable types? “Empty” would mean different things, depending on if your variables are strings, ints, datatables, datetime objects, etc.

string variable type

Then @Nawazish_Ahmad’s solution should work. You would need to use the Else If activity.

1 Like

HI @hansen_Lobo

Try this:

If
`String.IsNullOrEmpty(CCType) And String.IsNullOrEmpty(CCQty) And String.IsNullOrEmpty(CCDate)`
   Then:
      - Do nothing (Case 1)
ElseIf
   Condition: `Not String.IsNullOrEmpty(CCType) And (Not String.IsNullOrEmpty(CCQty) Or Not String.IsNullOrEmpty(CCDate))`
   Then:
      - Do nothing (Case 2)
ElseIf
   Condition: `String.IsNullOrEmpty(CCType) And (Not String.IsNullOrEmpty(CCQty) Or Not String.IsNullOrEmpty(CCDate))`
   Then:
      - Log Message-> "CC type is not present. But CCQty and/or CCDate values are present." (Case 3)
Else
  - Do nothing or add Log message

Hope it helps!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.