SAP Knowledge Base Article - Public

3242319 - SAP Signavio Process Governance custom form to validate digits in a number line

Symptom

On my trigger form in Process Governance, I need to create field name 'Opportunity Number'. In this field, there needs to be validations for the users filling out the form line. It should be exactly 10 digit number and may contain leading zeros.

Can you please help on how we can implement that kind of validation on a field in a trigger form so that if user enters a value which did not meet the requirements, it will display an error and not allow to submit the form.



Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.

Resolution

Why doesn't the number input fields work for this? You can use two options text field or number field.

  • Number field: You can define the minimum and the maximum values but it won't contain leading zeros.
  • Text field: It contains leading zeros but you can't limit the length and letters can be entered.

Using JavaScript will create the validations for the number line. It can check the length of the line and determine if a digit is listed and the length of the digit.

How to create a 10 digit number checker using a JavaScript task?

In Actions tab, choose JavaScript. Create a text(sting) variable in the task and reuse it in the trigger form. JavaScript will then check the length of the number (10 digit number) and if it's a number (as the variable is a text(string) field). The result will be saved in another variable. This variable will need to be created in order for the result to be saved. The Exclusive Gateway will check the result and make an automatic decision. If it determines it is the correct length and is a number, it will go to the usual process until the end. However if it determines the variable is not the correct length and/or isn't a number, a new form will be created reusing the trigger form and its data. An error message will appear to fix the 10 digit number variable. This new form will be assigned to the creator's case.

Sample JavaScript:

console.log(text + '\n')
if (text.length === 10) {
if (Number.isInteger(Number(text)))

{ console.log('\n It is a 10 digit number') }

else

{ console.log('\n It is not a number') }

} else

{ console.log('\n It is not a 10 digit number') }



Keywords

KBA , BPI-SIG-PG-JS , JavaScript for SAP Signavio Process Governance , How To

Product

SAP Signavio Process Governance all versions ; Workflow Accelerator by Signavio all versions