View Article

Require a Unique Value to Create a New Record

By Xelence Documentation posted 09-11-2023 14:51

  

Introduction

This process configures a lookup form to require a unique value, in this case an SSN, to create a new record.

To complete this configuration, you must first make the field required when the user clicks the New button, then add a query constraint to ensure that the user has not entered a value that already exists in the database (you will need an existing query to check for duplicate entries). If the user does not enter/enters an existing value, your app will display a plain text error informing the user what is preventing the record creation.

Finally, you must configure the New button to use the value the user entered as a parameter, so that when the app creates the new record, the new record already contains that value.

Prerequisites

  • The maintenance form must exist.
  • The lookup form must exist.
  • The entity must exist.
Quick Steps
1 Open the Lookup form
2 Select the field you want to require, then click the Add Constraint icon
3 Enter the constraint details
4 Click the Add Query Constraint icon
5 Enter the constraint details
6 Click the Set Query Parameters icon
7 Enter the parameter, then click OK twice
8 Open the New button properties, then click the Parameters icon
9 Enter the parameter, then click OK
10 Save the form

Detailed Steps

Step 1. Open the Lookup form.

Open the form you want to configure. This example uses the Customer Lookup form.



Step 2. Select the field you want to require, then click the Add Constraint icon.

The field is in the Search Criteria section. This example uses the SSN field.

You can also right click the field and add a new constraint.


Step 3. Enter the constraint details.

The important properties are:

  • Type: Specifies the type of validation you want. In this example, the field will be required.
  • Action: Determines when the app executes the validation. In this example, the app executes the validation when the user clicks the New button.
  • Message ID: Identifies the system message to display if the validation is met.
  • Message: Ad hoc message to display instead of the Message ID text.

 

Asterisk sign gets displayed over the field once required constraint is set.


Step 4. Click the Add Query Constraint icon.

If you want to require the user to enter a unique SSN, you need a constraint to confirm it is unique.

 

Step 5. Enter the constraint details.

The important properties are:

  • Type: Specifies the type of constraint you want. This validation is for a query.
  • Query ID: Identifies the query you want to use. This must already exist before you can enter it here.
  • Action: Determines when the app executes the validation. In this example, the app executes the validation when the user clicks the New button.
  • Operator: Comparison operator to be used on the result the query returns.
  • Value: Specifies the value for the comparison. In this example, if the query result is 1, the validation is met (because the value exists in the database in exactly one other instance). The checkbox means the value is constant, and in this case must be checked.
  • Message ID: Identifies the system message to display if the validation is met.
  • Message: Ad hoc message to display instead of the Message ID text.
The query in this case is a scalar query that returns the number of instances of the SSN value from the entity's table. Unless this query returns 0, the SSN used in the query is a duplicate.

 

Step 6. Click the Set Query Parameters icon.

This query takes a parameter, so you have to enter it.

 

Step 7. Enter the parameter, then click OK twice.

In this example, the parameter is whatever value the user has entered into the SSN field.

 

Step 8. Open the New button properties, then click the Parameters icon.

You must now set the parameter for your app to use when it creates a new record.

Make sure the New button has an Active Form to navigate to when clicked.


Step 9. Enter the parameter, then click OK.

In this example, the parameter value is the SSN.


Step 10. Save the form.


Then, run the Preview. Xelence displays the form output. You can test your updated settings.

When you have previewed your form, it should look something like this:

If you try to create a new record with a blank SSN field or by entering an existing SSN, the system displays an error message.

If you enter a unique SSN and create a new record, the maintenance form populates the SSN field.


What are the improvements over S3 Version 6?

Earlier, to validate a condition, we used to add a session field in the session tab in Maintenance form and a validate new button in Lookup form. Now, we don’t need to add session field in the session tab, instead we can directly apply a constraint on the field itself.


Related Articles

Create a Lookup Form


This post is part of the Lookup Form topic. Click here to open the Lookup Form Overview.

This post is also part of Controls and Buttons topic. Click here to open Forms Toolbox Controls

#Xelence
#Forms

#ControlsandButtons

0 comments
78 views