locked
Business Rule - Ensure code as an integer RRS feed

  • Question

  • Hi, I'm developing MDS models in 2008 R2 and I want to ensure that the code attribute on my entity is always a number. How do I do this? I tried creating a business rule that said the code must contain the pattern [0-9]. However this always passes even with values like 98a for the code. I also tried using a rule that said the code must be between 0 and 1000 but again this always passed. Any help appreciated. Thanks
    Tuesday, December 18, 2012 2:39 PM

Answers

  • Hi,

    I don't think so we have straight way to check this.Some of the ways can be used-

    1.Default the code value and choose auto increment value.

    2.If the input contains a specific set of values like (A-Z,a-z,$,&,etc), you can use the similar expression given by Nagesh.

    3.If there is no easier way, external workflow can be used. A small C# code that can parse the value of code as INT and if it fails, just fail the BR.

    Hope this helps!

    • Marked as answer by MDSDeveloper Thursday, December 20, 2012 12:15 PM
    Wednesday, December 19, 2012 12:57 PM

All replies

  • Hi,

    Can you try: - Code Contains Pattern [%A%-%Z%] OR Code Contains Pattern [%a%-%z%] in If condition?

    Wednesday, December 19, 2012 12:29 PM
  • Hi,

    I don't think so we have straight way to check this.Some of the ways can be used-

    1.Default the code value and choose auto increment value.

    2.If the input contains a specific set of values like (A-Z,a-z,$,&,etc), you can use the similar expression given by Nagesh.

    3.If there is no easier way, external workflow can be used. A small C# code that can parse the value of code as INT and if it fails, just fail the BR.

    Hope this helps!

    • Marked as answer by MDSDeveloper Thursday, December 20, 2012 12:15 PM
    Wednesday, December 19, 2012 12:57 PM
  • Many thanks for the prompt reply. I was unable to use the auto increment feature as I am using the 2008 R2 version. The solution I used - I checked for the pattern [a-z,A-Z] in my business rule and if true then invalidate the code attribute. Best regards
    Thursday, December 20, 2012 12:19 PM