Technology Encyclopedia Home >Tencent Cloud Weida low-code custom page, a field in the form wants to be used as a key and cannot be repeated. How to set it?

Tencent Cloud Weida low-code custom page, a field in the form wants to be used as a key and cannot be repeated. How to set it?

To set a field in Tencent Cloud Weida low - code custom page form as a non - repeatable key, follow these steps:

Explanation

In a form, a key field is used to uniquely identify each record. By setting a field as non - repeatable, you ensure that no two records in the form have the same value for this field. This is useful for maintaining data integrity and preventing duplicate entries.

Steps to Set

  1. Open the Form Designer: Log in to Tencent Cloud Weida and navigate to the custom page where your form is located. Open the form in the form designer.
  2. Select the Field: Locate the field in the form that you want to use as a non - repeatable key. Click on the field to select it.
  3. Set the Validation Rule: In the properties panel of the selected field, look for the validation or rule - setting section. There should be an option to add a custom validation rule.
  4. Add Uniqueness Validation: In the custom validation rule, you can use a script or a built - in function to check for uniqueness. For example, if the form is connected to a data source, you can write a rule that queries the data source to see if the value entered in the field already exists. If it does, an error message is displayed to the user.
    • A simple example of a custom validation rule in a pseudo - code format could be:
// Assume 'formData' is the data source and 'selectedField' is the field we want to check
function validateUniqueness(value) {
    for (let i = 0; i < formData.length; i++) {
        if (formData[i].selectedField === value) {
            return false; // Value already exists, validation fails
        }
    }
    return true; // Value is unique, validation passes
}
  1. Set an Error Message: Along with the validation rule, set an appropriate error message that will be shown to the user when they try to enter a duplicate value. For example, "This value has already been used. Please enter a unique value."

Tencent Cloud Service Recommendation

If you want to manage and store the form data more effectively, you can use Tencent Cloud's Cloud Database service. It provides reliable and scalable database solutions to store the data collected from your Weida low - code custom page forms. You can easily integrate the form with the Cloud Database to ensure data security and efficient data management.