How can i create a business exception if an argument contains letters?

Hello,

How can i create a business exception if an argument contains letters, it suppose to have just account number but sometimes came a name there and makes the process fails.
in.AccountNumber.ToString.Contains( letter?

Thanks

1 Like

Hello,

In order to do that, first you need an ‘if’ activity to check if your variable contains any letters. The easiest way of doing that is to use the .ToString.IsNumberical method.

So, in your case, the condition would be: in.AccountNumber.ToString.IsNumerical.
On the ‘Then’ side of the ‘If’ activity, you should just leave it empty. On the ‘Else’, you should put a ‘Throw’ activity. The value inside the ‘Throw’ activity should be: new BusinessRuleException(“Explanaition of the Exception”)

Hope this helps!

1 Like

HI @andres.alvarez

You can try with Throw activity

AccountNumber.ToString.IsNumeric
New BusinessRuleException("Your text here!!")

Regards
Gokul

2 Likes

Thank you so much, it works

1 Like

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