Morten Sæther

← Blog

Forms and Data Collection

#8 · 11 March 2026

Forms people finish, with data you can trust at the other end

Forms are where external users touch your data - submitting tickets, updating profiles, registering for things. They’re also where you lose people. Every extra field is another chance for someone to decide this isn’t worth it today.

Internal users will push through a bad form because it’s their job. Customers won’t. So the bar is higher here than anywhere else in the portal.

Step by step

1. Decide what kind of form you need

Before you build anything, answer four questions: where does this form sit in what the user is trying to do, what’s required versus nice to have, what do you already know about this person that you shouldn’t be asking again, and are they doing this on a phone?

Then pick your type. There are two:

2. Build a basic form

A support ticket form, start to finish.

Set it up: in the Portal Management app, under Content → Basic Forms, create a new one, name it, and point it at the Case table.

Configure it:

Table Name: Case (incident)
Form Name: "Portal Case Form" (create this in Dataverse)
Mode: Insert
On Success: Display Success Message
Success Message: "Your support ticket has been submitted."

The success message is plain text per language; it doesn’t substitute field values. If you want the ticket number on the confirmation, set On Success to Redirect and use Append Attribute Value to Query String with ticketnumber, then read it on the landing page.

Lock it down:

Put it on a page: edit your support page, add the Form component, select the form you just configured.

3. Make it pleasant to fill in

Show fields as they become relevant:

// Example: Show additional fields based on issue type
function showAdditionalFields(issueType) {
    const techFields = document.getElementById('technical-fields');
    const billingFields = document.getElementById('billing-fields');
    
    // Hide all additional fields first
    techFields.style.display = 'none';
    billingFields.style.display = 'none';
    
    // Show relevant fields based on selection
    if (issueType === 'technical') {
        techFields.style.display = 'block';
    } else if (issueType === 'billing') {
        billingFields.style.display = 'block';
    }
}

Don’t ask for what you already know. Liquid renders in the page copy or web template, and the user object is HTML-encoded, which is not the same as being safe inside a JavaScript string. So put the values in data attributes and read them from the script:

<!-- Page copy or web template -->
{% if user %}
<div id="portal-user" hidden
     data-email="{{ user.emailaddress1 | escape }}"
     data-firstname="{{ user.firstname | escape }}"
     data-lastname="{{ user.lastname | escape }}"></div>
{% endif %}
// The form's Custom JavaScript field. Input IDs are the column logical names.
document.addEventListener('DOMContentLoaded', function() {
    const u = document.getElementById('portal-user');
    if (u) {
        document.getElementById('emailaddress').value = u.dataset.email;
        document.getElementById('firstname').value = u.dataset.firstname;
        document.getElementById('lastname').value = u.dataset.lastname;
    }

    // Set default priority and category
    document.getElementById('prioritycode').value = '2'; // Normal priority
    document.getElementById('casetypecode').value = '1'; // Question
});

The contact itself is set by Associate Current Portal User, not by the browser.

Group related fields so the form reads in chunks rather than as one long column - contact information together, issue details in their own section, technical fields separately for the people who need them, and a clearly marked area for attachments.

4. Validate

Client-side, for instant feedback. Required fields and regex rules you set per field in the design studio. For anything beyond that, the form runs the validators in Page_Validators on submit, so add yours there rather than writing a function nothing calls:

// The form's Custom JavaScript field: email format check that blocks submit
if (window.jQuery) {
    (function ($) {
        $(document).ready(function () {
            if (typeof (Page_Validators) == 'undefined') return;
            var v = document.createElement('span');
            v.style.display = 'none';
            v.id = 'emailaddressValidator';
            v.controltovalidate = 'emailaddress';
            v.errormessage = '<a href="#emailaddress_label">Please enter a valid email address.</a>';
            v.validationGroup = '';
            v.initialvalue = '';
            v.evaluationfunction = function () {
                return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test($('#emailaddress').val());
            };
            Page_Validators.push(v);
        });
    }(window.jQuery));
}

Rules that span several fields go in a wrapper around entityFormClientValidate, which runs on the submit button; return false to stop the submit.

Server-side, because client-side validation is a courtesy, not a control: Dataverse business rules with scope set to Entity, so they run on the server and not only in a form, and plug-ins when the logic gets real.

Never trust the browser. It’s the one part of your stack the user controls.

5. Multi-step forms when the process warrants it

Reach for multistep forms when you’ve got a complex registration, data spread across several tables, branching based on earlier answers, or an external system in the loop.

Setting one up: in the Portal Management app, under Content → Multistep Forms, create one, name it, set the start step, and end with a Redirect step to the success page.

The steps, for a registration: contact details first, then company details, then preferences, then a review page before submit.

And the branching, as a step of type Condition, which evaluates an expression against the record from the previous step:

Step Type: Condition
Condition: customertypecode = <the Business Customer value>
Next Step: Company Information
Next Step If Condition Fails: Preferences and Settings

6. The extras

File uploads. An accept attribute or a size check in JavaScript only steers the file dialog; anyone can skip it. The restrictions that hold are the form’s own attachment settings, which the server enforces:

Attach File: Yes
Allow Multiple Files: Yes
Accept: application/pdf,image/png,image/jpeg
Restrict Files to Accepted Types: Yes
Maximum File Size (in kilobytes): 5120
File Type Error Message: "Accepted formats: PDF, PNG, JPG."
File Size Error Message: "Maximum size: 5 MB per file."

Without Restrict Files to Accepted Types, the accept list is only a suggestion to the dialog. Attachments are stored as notes, so the web role also needs Create and Append on the note table and Append To on Case.

Conditional fields:

// Example: Show different fields based on customer type
function handleCustomerTypeChange(customerType) {
    const businessFields = document.getElementById('business-customer-fields');
    const individualFields = document.getElementById('individual-customer-fields');
    
    if (customerType === 'business') {
        businessFields.style.display = 'block';
        individualFields.style.display = 'none';
        
        // Make business fields required
        businessFields.querySelectorAll('input, select').forEach(field => {
            field.required = true;
        });
        
        // Remove required from individual fields
        individualFields.querySelectorAll('input, select').forEach(field => {
            field.required = false;
        });
    } else {
        businessFields.style.display = 'none';
        individualFields.style.display = 'block';
        
        // Reverse the requirements
        businessFields.querySelectorAll('input, select').forEach(field => {
            field.required = false;
        });
        individualFields.querySelectorAll('input, select').forEach(field => {
            field.required = true;
        });
    }
}

What this looks like in practice

The full TechStart Solutions support ticket form:

Customer information, pre-populated - name, email and phone read-only for signed-in users, plus a lookup to their account.

Issue details - issue type (Technical, Billing, General), priority (Low, Normal, High), a required subject, and a rich text description.

Technical details, only shown for technical issues - affected product or service, error messages, steps to reproduce.

Attachments - multiple files, with size and type restrictions enforced.

The validation rules behind it: subject at least 10 characters, description at least 50 for technical issues, at least one attachment on billing issues, and format checks on phone and email.

And the security: authenticated users only, cases can only be created against the submitter’s own contact record, uploads stored with access controls, and every submission logged for the audit trail.

7. Keep it fast, especially on a phone

Load lookup data when it’s needed rather than up front, debounce validation so you’re not firing on every keystroke, write efficient queries behind your dropdowns, and cache the static ones.

For mobile:

/* Example: Mobile-optimized form styling */
.portal-form {
    max-width: 100%;
    padding: 1rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-control {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }
    
    .form-col {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .btn {
        width: 100%;
        padding: 14px;
        font-size: 16px;
    }
}

How to make a mess and fix it

Record created, but no redirect. Check the form’s On Success settings, and the page permissions on the redirect page.

Validation messages in the wrong language. Localised messages go in the form metadata.

File uploads failing silently. Size limits, allowed types, storage configuration - in that order.

“Access denied” on submit. Table permissions first, then which web roles they’re assigned to, then whether the user is in one.

Conditional logic not firing on mobile. Test the JavaScript on a real device and check your event handlers work with touch.

Seven habits worth keeping

  1. Design from the user’s side, not from the table schema
  2. Start with a working HTML form, then enhance it
  3. Write error messages that say how to fix it, not just that something’s wrong
  4. Use the site’s design system so forms don’t look bolted on
  5. Keep it accessible - screen readers, keyboard navigation, the lot
  6. Validate server-side, always
  7. Test with real people, real devices, real data

Wrapping up

A good form feels like nothing at all and still produces clean data. Understand what the user came to do, strip out everything that isn’t needed, and be honest about which fields are required - every one you add costs you completions.

Next: detail pages, and giving people everything they need on one screen.