Comparing strings

I want to compare two variables using AND in if condition but my condition does not work Could anyone please help me with this issue?
Below is the if condition
SupplierPANNumber<>pancardoutput1 AND SupplierBankAccountNumber<>accountnumber1 AND SupplierBankIFSCCode<>ifsccode1 AND SupplierGSTINNumber.Equals(gstin1) AND SupplierGSTLegalName.Equals(legalname1)

give a try on

{SupplierPANNumber <> pancardoutput1, SupplierBankAccountNumber <> accountnumber1, SupplierBankIFSCCode <> ifsccode1, SupplierGSTINNumber.Equals(gstin1), SupplierGSTLegalName.Equals(legalname1)}.All(Function (x) x)

in case of it is not working as expected do debugging and explore the part results within the immediate panel

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

@ppr I tried using your if condition but it does not work

always provide feedback, what is not working.

just use the immediate panel and check each part check individually (set breakpoint, debug and get paused)

for strings also checkalternates like: Not StringA.Equals(String) instead of StringA <> StringB

1 Like

hi @Seema_Jethe, it’s all Int variables? Or it’s all string? If have some string try to put “variable.tostring <> variable2”

@Vitor_Soares All are strings

TRy to use ToString.Trim.Tolower or Upper if upper lower case does not matter
And as instructed try checking individual value i mean SupplierPANNumber<>pancardoutput1…

@ppr Below is the if condition which is not working as expected

Not SupplierPANNumber.Equals(pancardoutput1) AND Not SupplierBankAccountNumber>Equals(accountnumber1) AND Not SupplierBankIFSCCode.Equals(ifsccode1) AND SupplierGSTINNumber.Equals(gstin1) AND SupplierGSTLegalName.Equals(legalname1) Can u please help me with this?

please try this, similar to

if you have lower or upper cases add like @ppr said, if you have all the same, try this: SupplierPANNumber<>pancardoutput1 AND SupplierBankAccountNumber<>accountnumber1 AND SupplierBankIFSCCode<>ifsccode1 AND (SupplierGSTINNumber.Equals(gstin1)) AND (SupplierGSTLegalName.Contains(legalname1))

@Vitor_Soares If my variables have upper nd lower cases then what should be my expression to compare them?

@Vitor_Soares sometimes pancardoutput1 will have no data

@Seema_Jethe

Taking letters only in SupplierGSTLegalName, legalname1, gstin1, SupplierGSTINNumber for exemple:

SupplierPANNumber<>pancardoutput1 AND SupplierBankAccountNumber<>accountnumber1 AND SupplierBankIFSCCode<>ifsccode1 AND (SupplierGSTINNumber.ToLower.Equals(gstin1.ToLower)) AND (SupplierGSTLegalName.ToLower.Contains(legalname1.ToLower))

you can see that: (SupplierGSTINNumber.ToLower.Equals(gstin1.ToLower)) AND (SupplierGSTLegalName.ToLower.Contains(legalname1.ToLower)) - On this you can use equals or contains, if you want the exactly match use equals ( be carefull with blank spaces, wrong names…), else if you want somes keys in name use contains.

@Vitor_Soares sometimes pancardoutput1 will have no data”

No problem with that because its diferent.

@Vitor_Soares so if SupplierPANNumber value is “EJAPS0276M” and pancardoutput1 value is ASDFG6789K and both are strings then what should be the expression to compare both strings in this case?

@Vitor_Soares and if both the strings have numbers then will the expression work

The best think i guess is you putting this:

Not SupplierPANNumber.ToLower.Equals(pancardoutput1.ToLower) And Not SupplierBankAccountNumber.ToLower.Equals(accountnumber1.ToLower) And Not SupplierBankIFSCCode.ToLower.Equals(ifsccode1.ToLower) And (SupplierGSTINNumber.ToLower.Equals(gstin1.ToLower)) And (SupplierGSTLegalName.ToLower.Contains(legalname1.ToLower))

Yes it will

@Seema_Jethe if you have null in some field you need to do this:

it’s a example.
1ª You are validate all at once, i mean, all the validation needs to be true to go to the statement “True”.
2ª If the variables have null from DataBase or SQL, do this:
((Not SupplierPANNumber.ToLower.Equals(pancardoutput1.ToLower) or not String.IsNullOrEmpty(pancardoutput1) or not String.IsNullOrEmpty(SupplierPANNumber))

Doing this you are saying that any field is null or empty, the geral condition will be false so do “else”.

@Vitor_Soares i tried using your expression but it throws error also legal name1 contains only letters and gstin1 contains both numbers and letters Below is the screenshot of error