web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Make all fields on the form to Upper case

(0) ShareShare
ReportReport
Posted on by

Hi All,

I am working on a requirement to make all the fields on the form to Upper case.

Can anyone help me with this ?

Thanks in advance !!

I have the same question (0)
  • Wahaj Rashid Profile Picture
    11,321 on at

    Hi,

    Thank you for your query.

    Do you need to make the labels upper case or the field values?

    And when you say all fields, does it include optionsets, lookups, multiline texts?

  • Sandeep Profile Picture
    on at

    Hi Wajah,

    Thanks for your reply.

    Only the field values needs to be changed to upper case.

    Is it possible to change to upper case for all the data types which you mentioned ?

  • Suggested answer
    Wahaj Rashid Profile Picture
    11,321 on at

    Hi Sandeep,

    You can use JavaScript to change the field's text to Upper case.

    Please note, it only makes sense to do this for text fields.

    Let me explain:

    • Optionset: its better to change the actual option labels (because these are predefined values).
    • Lookups: primary field value is shown from the related entity.
    • Numbers: obviously no caps here.

    So to change the text fields to upper case, here is the logic:

    • On load of the form, loop through each attribute and attach on change event for text fields.
    • In the event handler, change the value to upper case.

    Here are steps to follow:

    • Create a web resource (JScript) or use existing. Add following sample code (you can change the names as per your need):


    // Register on Load of the Form, pass exuection context as first parameter
    function onLoad(executionContext) {
    
        // Get Form Context
        const formContext = executionContext.getFormContext();
    
        // Get Attriibutes collection
        const attributes = formContext.data.entity.attributes;
    
        // Attach On Change for all attributes
        attributes.forEach(addOnChangeForCaps);
    
    }
    
    // Attach On Change Function for string attributes.
    function addOnChangeForCaps(item, index) {
    
        
        const attribute = item;
    
        if (attribute.getAttributeType() === "string") {
            
            attribute.addOnChange(toCaps);
    
        }
    
    
    }
    
    // On change, set value to UPPER
    function toCaps(executionContext) {
    
        const attribute = executionContext.getEventSource();
    
        const attrValue = attribute.getValue();
    
        attribute.setValue(attrValue.toUpperCase());
    
    }
    
    

    • Register the first function (onLoad) on the on load event of the form, do not forget to pass execution context as first parameter.
    • Save and Publish the form (and web resource).

    Now, when the user types and leaves a text field, the value converts to the upper case automatically.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
Pallavi Phade Profile Picture

Pallavi Phade 32

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans