E10 Customization to force text field to uppercase

In Part screen customization, I need to force a text field to always be entered as uppercase.
Here’s what I have so far (doesn’t work) plus I’ve tried ToUpper and several variations:

private void SetExtendedProperties()
{
	// Begin Wizard Added EpiDataView Initialization
	EpiDataView edvPart = ((EpiDataView)(this.oTrans.EpiDataViews["Part"]));
	// End Wizard Added EpiDataView Initialization

	// Begin Wizard Added Conditional Block
	if (edvPart.dataView.Table.Columns.Contains("CommercialBrand"))
	{
		// Begin Wizard Added ExtendedProperty Settings: edvPart-CommercialBrand
		edvPart.dataView.Table.Columns["CommercialBrand"].ExtendedProperties["Uppercase"] = true;
		// End Wizard Added ExtendedProperty Settings: edvPart-CommercialBrand
	}
	// End Wizard Added Conditional Block
}
1 Like

Before Field Change Event Handler on the Part data View. run .ToUpper() on ProposedValue.

1 Like

Or bettter yet a BPM Pre-Processing on ChangePartNum method.

I tried this… it compiled but didn’t function properly. I queried the record, changed the value and it left it lowercase. Did I misunderstand your suggestion?

private void Part_BeforeFieldChange(object sender, DataColumnChangeEventArgs args)
{
	// ** Argument Properties and Uses **
	// args.Row["FieldName"]
	// args.Column, args.ProposedValue, args.Row
	// Add Event Handler Code
	switch (args.Column.ColumnName)
	{
		case "CommercialBrand":
			try {
					if (edvPart.Row > -1)
					{
						if ((args.Row["CommercialBrand"].ToString()) != "")
							args.Row["CommercialBrand"].ToString().ToUpper();
					}
				}
				catch(Exception ex){MessageBox.Show("Ownership uppercase error");}
			break;
	}
}

You are not assigning the result … ToUpper() returns a string you need to assign it back to the variable. try

args.ProposedValue = ((string)args.ProposedValue).ToUpper();
2 Likes

I get compile errors when I enter the following:

args.ProposedValue = ((“CommercialBrand”)args.ProposedValue).ToUpper();

Error: CS1026 - line 1710 (3544) - ) expected
Error: CS1002 - line 1710 (3544) - ; expected
Error: CS1525 - line 1710 (3544) - Invalid expression term ‘)’

Commercial brand is not a valid type… I gave you the exact code you needed there.

Here’s some reading for further clarification regarding casting

1 Like

My apologies. Thought I was supposed to substitute the field name (CommercialBrand) into the “string” value.

I have now put in exactly what you proposed and it worked perfectly. Thank you Jose.

I will do some reading on casting and type conversions.

Thanks again!

1 Like