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

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);
	}
}

 

Hi @Brad Bowman  

Thanks for the reply!

Would it also be possible to use a UI policy?

@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.

@charri04 If you don't want to script and if it's alright to just check entry from the form, you can defined a regular expression.

  1. Go to "Service Catalog" > "Catalog Variables" > "Variable Validation Regex"
    . Enter Regular Expression as "^[A-Z]+$" is the field only allows characters. If digits are allowed, enter "^[A-Z0-9]+$"
    HitoshiOzawa_0-1730347317242.png
  2. In the field definition, select "Type Specifications" tab and select the regular expression name you've defined in the "Validation Regex".
    HitoshiOzawa_1-1730347510939.png

     

Execution result:

HitoshiOzawa_2-1730347566280.png