IF ELSE Statement error

Hi everyone, can I please get assistance

I have this condition here, it extracts that ‘CPP’ value from an excel file and if it finds that it needs to replace it with a value on the assign activity. What it does it is, it identifies that CPP value but it still goes to the ‘else’ side and sends an email that is on the else.

In the condition I tried putting =True

Hi @Anelisa_Bolosha1

Use If ProductName.ToString.Trim.Equals(“CPP”) to ensure exact match.
Check for case sensitivity and extra spaces in the Excel value.

Happy Automation

Hi @prashant1603765 , yes I did check thank you let me try this

Hi Unfortunately it didn’t work either and what it does now, is it sends the email with email addresses I dint include

@Anelisa_Bolosha1

That’s odd. Try printing the product name once. Also debug it thoroughly.

If you are extracting product name from some website or email, there is high chances of special invisible characters attached to the string. Try logging the length of the product name variable to check any invisible characters present.

If possible try sharing a sample workflow to reproduce the issue.

Hi @Anelisa_Bolosha1

few things here..

  1. is the name “CPP” or in another case (lower or sentence case)? accordingly modify your condition.

  2. Put a breakpoint on If statement then debug the code, watch from locals panel, what is the value coming in productName variable? Does it contain any spaces? or is it in any other case? Does it contain any extra characters?

This will help you pinpoint the problem.

if productname only contains CPP then better to use Equals function rather than Contains. When you hit breakpoint on if, go to immediate panel and test the result of below expressions..

ProductName.ToString.Trim.Equals(“CPP”)

ProductName.ToString.Contains(“CPP”)

ProductName.ToString.Length

ProductName.ToString.ToLower.Contains(“cpp”)

ProductName.ToString.ToUpper.Contains(“CPP”)

try different combinations, will help you identify the problem.

Thanks I had to debug thoroughly and I saw the issue

1 Like

this worked now after

1 Like

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