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.