Skip to content

Power Pages: Form Label Best Practices

Nicholas Hayduk January 28, 2025 3 Min.To Read

One of the fundamental features of Power Pages is the ability to create or edit Dataverse data via Forms. The layout of a Power Pages Forms is defined using Dataverse table forms, which are the same as those used in model-driven Power Apps. Part of that layout includes the labels for the fields of the form. In this post we’ll look at the various options Power Pages provides to customize those field labels.

One of the fundamental features of Power Pages is the ability to create or edit Dataverse data via Forms. The layout of a Power Pages Forms is defined using Dataverse table forms, which are the same as those used in model-driven Power Apps. Part of that layout includes the labels for the fields of the form. In this post we’ll look at the various options Power Pages provides to customize those field labels.

Labels Defined in the Dataverse Table Form

To create a form in Power Pages, the first step is to create the Dataverse table form. This includes adding the various columns from that table to the form.

When a column is added to the form, the label for that field will default to the display name of that column. Once added to the form, the label for the field can then be changed.

By default, Power Pages will respect whatever label is defined on the Dataverse table form.

Labels Defined in Form Metadata

It is possible to override the field label that is defined on the Dataverse table form. The no-code way of doing this is using Form Metadata.

Form Metadata is a feature that allows you to change some of the default behaviour of the form without using JavaScript, and one of the things you can change is the label.

Form Metadata can be created manually using the Power Pages Management app (for the Enhanced Data Model) or the Portals Management app (for the Standard Data Model), or you can change the form labels via the Power Pages Design Studio, which will create the Form Metadata rows for you.

However, I recommend only using Form Metadata only in cases where it is not practical to change the label directly on the Dataverse table form.

Our best practice is to always create new Dataverse table forms that are specific to Power Pages, and not to attempt to reuse forms that might be use in another model-driven app. We’ll often use a naming convention to identify these Power Pages-specific forms, usually adding ” – Web” or ” – Portal” to the end of the Dataverse table form name.

I recommend this because even in the rare cases where a form for Power Pages needs to be identical to another form that may already exist, it is very likely in the future that the form will need to be different. It is much simpler from an ALM perspective to not have to change which Dataverse table form a Power Pages form points to.

I would also challenge any situation where it is believed that the form used in a model-driven Power App should be the same on a Power Pages site. I’ve found that in practice that this situation is rare – forms for Power Pages typically need different fields, labels and layouts, so if you think you should be reusing a form, give it a bit a bit more thought as to how that form might be better optimized. Unless the audience for the Power Pages site and the model-driven app is the same, it is likely the forms should be different.

So when should you use Form Metadata to change the label on your form?

  • When you need more characters than can fit in a Dataverse table form label (as of now, the maximum is 1000 characters)
  • When you are using the same form multiple times on your Power Pages site, and you just need small label differences

As you can see, the situations where I use Form Metadata to change the label of a field are pretty limited. Form Metadata is great to do a lot of cool things, but I think it is much cleaner to make label changes to the underlying Dataverse table form instead of using Form Metadata.

Changing Labels Using JavaScript

So far we’ve just talked about making a permanent change to a label. But what about changing labels on the fly? For that, we can use JavaScript.

For example, perhaps the requirements for your project are that the label for a particular field is based on the value of another field.

Here is the JavaScript that accomplishes that:

$(document).ready(function () {
    $('#new_field').change(function () {
        if ($(this).val() == '124900001') {
            $('#new_field2').closest('td').find('label').text('Label 1');
        } else {
            $('#new_field2').closest('td').find('label').text('Label 2');
        }
    }).change();
});

In this case, we’re checking the value of new_field, and based on that, changing the label of new_field2. The code that changes the label finds the label element that exists within the same table cell as the input control itself, and then updates the text. Remember that, unlike in model-driven Power Apps, it is not unsupported to change a label by direct DOM manipulation.

Only use JavaScript in cases where the label needs to be dynamic. Otherwise, just change the label directly in the Dataverse table form.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top