Validate Form Fields Using Salesforce Field Rules
Noca Forms: AI form builder you can set up from a plain-language prompt, connected to your CRM, ERP and other systems. Free plan available.
Many business forms send their data straight to Salesforce. A lead form creates a new lead, a service request creates a case, and an onboarding form updates an account.
But Salesforce has its own rules for each field. A text field might allow only 20 characters. Some fields are required. Others only accept certain formats. When a form doesn’t follow these rules, the data looks fine on the screen but fails when it’s saved to Salesforce.
Applying Salesforce field rules directly to form fields catches these problems before the form is submitted, so users can fix them right away.
Why Forms and Salesforce Rules Get Out of Sync
A form and a Salesforce object are often designed separately. Over time, small differences add up.
Common problems include:
- A form field that allows more characters than the Salesforce field
- Required Salesforce fields that aren’t required in the form
- Fields remapped to a different Salesforce field without updating their rules
- Errors that appear only after submitting, with no clear explanation
- Data that’s lost when a save fails
For example, a form field originally mapped to an 8-character Salesforce field is later remapped to a 20-character field. If the form still limits input to 8 characters, users can’t enter valid values. If it’s the other way around, users can enter more than Salesforce accepts, and the save fails.
Using Salesforce as the Source of Truth
The most reliable approach is to take field rules directly from Salesforce.
When a form field is mapped to a Salesforce field, the form can apply that field’s rules, such as:
- Maximum length
- Required status
- Other validation rules defined for the field
When the field is remapped, the rules update automatically to match the new Salesforce field.
Keeping Your Own Labels
Salesforce field labels aren’t always the best labels for a form. A Salesforce field called “Billing Street” might be shown to customers as “Street address”, and an internal field name might not make sense to users at all.
Field rules should come from Salesforce, but labels should stay as you wrote them. This keeps forms clear and user-friendly while still following Salesforce’s rules.
Checking Rules Before Submitting
Validation is most helpful when it happens before the form is submitted.
A good form:
- Checks each field against its Salesforce rules
- Shows an error message on the field that needs attention
- Lets users fix the problem without losing what they entered
- Submits only when the data is ready to be saved
If the Salesforce rules can’t be loaded for some reason, the form should remain usable, relying on the most recently saved rules where possible.
Validating Before vs. After Submitting
| Errors after submitting | Validation before submitting | |
|---|---|---|
| When users find out | After the save fails | While filling in the form |
| Error location | General message | On the specific field |
| Data loss risk | Higher | Lower |
| User experience | Frustrating | Clear and guided |
Tips for Salesforce-Connected Forms
- Map each form field to the correct Salesforce field before going live
- Review mappings when Salesforce fields change
- Use clear, user-friendly labels on the form
- Test the form with values at and beyond the field limits
- Make required Salesforce fields easy to find in the form
Forms That Fit Salesforce Perfectly
When forms follow the same rules as Salesforce, data flows smoothly from the user to the system, without surprises.
Because the best time to catch a data problem is before it’s ever saved.
Frequently asked questions
Why do forms fail when saving data to Salesforce?
Forms fail when saving to Salesforce because Salesforce has its own rules for each field, such as maximum length, required status and accepted formats, and the form does not follow them. Forms and Salesforce objects are often designed separately, so differences build up, for example a form field allowing more characters than its Salesforce field, or a required Salesforce field that is optional in the form.
How can a form use Salesforce as the source of truth for validation?
A form uses Salesforce as the source of truth by taking field rules directly from the Salesforce field each form field is mapped to, including maximum length, required status and other validation rules defined for that field. When a form field is remapped to a different Salesforce field, the rules update automatically to match. Form labels can still stay as written, so customers see clear wording instead of internal field names.
What are the benefits of validating form fields before submission?
Validating form fields before submission means users find problems while filling in the form, not after a Salesforce save fails. Errors appear on the specific field that needs attention rather than as a general message, users can fix issues without losing what they entered, and the form submits only when the data is ready to save. This lowers the risk of data loss and creates a clearer, guided experience.
How should you test a Salesforce-connected form before going live?
Before going live, map each form field to the correct Salesforce field and test the form with values at and beyond the field limits. Make required Salesforce fields easy to find in the form, use clear, user-friendly labels, and review mappings whenever Salesforce fields change. If Salesforce rules cannot be loaded, the form should remain usable by relying on the most recently saved rules where possible.