Make the input of a String Field in ALL CAPS

charri04
Tera Expert

Hello developers,

I have a field on the Vendor Contact table that is a string field. I need to ensure that any data that is entered into that field is in ALL CAPS.

Is there an easy way to accomplish this?

Best regards,

 

charri04

3 ACCEPTED SOLUTIONS

Brad Bowman
Kilo Patron
Kilo Patron

You can do this with a before Update Business Rule on the Vendor Contact table with the Filter Condition <<field_name>> changes:

(function executeRule(current, previous /*null when async*/) {
	current.u_string_limit = current.field_name.toUpperCase();
})(current, previous);

 

Or you could also use an onChange Client Script when this field changes to see the change on the form before the record is submitted/saved:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

	var upper = newValue.toUpperCase();
	if (newValue !== upper) {
		g_form.setValue('field_name', upper);
	}
}

 

View solution in original post

@charri04 Should use Business Rule to ensure it. Client Script will only check when the value is entered from the form. If there was a script include or REST API to enter the record, Client Script won't run.

View solution in original post

ersureshbe
Giga Sage
Giga Sage

Hi, Can you check below client script to achieve your expectation.


function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '')
return;

var str = newValue.toUpperCase();
if (str != newValue)
g_form.setValue("short_description", str);
}

 

Regards,
Suresh.

View solution in original post

8 REPLIES 8

Hi @Hitoshi Ozawa 

Yeah I was thinking about using the "Variable Validation Regex" but since I don't have a catalog item for the vendor contact table, the agents are creating the vendor contacts directly on the table through workspace.

 

Best regards,

 

charri04

@charri04 BTW, it's not possible with UI Policy.

It's possible to create a UI Policy that will convert the value to all CAPS but if the user changes the value, UI Policy will not run.

 

Yes, you can do this with a scripted UI Policy, but it doesn't work as well as the Business Rule or onChange Client Script as a lowercase value could still be entered on the form by the user, then if the form is updated, not saved, the lowercase will remain until the next time the form/record is loaded.

ersureshbe
Giga Sage
Giga Sage

Hi, Can you check below client script to achieve your expectation.


function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '')
return;

var str = newValue.toUpperCase();
if (str != newValue)
g_form.setValue("short_description", str);
}

 

Regards,
Suresh.