I have this piece of JavaScript code that's supposed to force a string of text to upper-case characters, but it won't work. I know it hits a breakpoint when I set it, but the code doesn't seem to do what it's supposed to.
I'm new to JavaScript. What am I missing here?
myapp.AddEditVehicle.beforeApplyChanges = function (screen) {
// force string to uppercase
screen.Vehicle.RegNum.toUpperCase();
};
If you'd like to tackle this in JavaScript on the client side, you need to use the following code:
myapp.AddEditVehicle.beforeApplyChanges = function (screen) {
// Write code here.
screen.Vehicle.RegNum = screen.Vehicle.RegNum.toUpperCase();
};
Alternatively, if you'd like to do this in c# on the server side, you can add the following RegNum_Validate code by selecting the Write Code option on the designer screen for your Vehicle.lsml entity:
partial void RegNum_Validate(EntityValidationResultsBuilder results)
{
// results.AddPropertyError("<Error-Message>");
if (this.Details.Properties.RegNum.IsChanged)
{
this.RegNum = this.RegNum.ToUpper();
}
}
Please bear in mind that the Write Code option for the RegNum_Validate general method will only be available if you have the Server project perspective selected at the bottom of the entity designer.