AAvoid Errors by Adding Validation Rules for Custom Text Fields and Numeric Fields

AAvoid Errors by Adding Validation Rules for Custom Text Fields and Numeric Fields

Read Complete Release Notes 


Feature released in SummitAI Asset Management (#18251, Alps)

What is happening now?

The Administrators can add Rules by adding manual scripts for Custom Fields (text and numeric fields, such as Vehicle Number, Date of Transfer, Date of Sale, and Depreciation Reserve) to avoid errors while entering values in these fields. Based on the configuration, only the allowed values can be entered in the above fields.

While adding/updating the Asset details on the ADD ASSET and UPDATE ASSET pages (Asset > User > manage Assets > Asset Inventory > Click FIXED > Click a hyperlinked value under In-store column header > Select the required Asset(s) and click ADD or UPDATE icon on the ACTIONS panel), the text and numeric Custom Fields are validated as per the configuration on the VALIDATE CONTROLS page. For more information about validating controls, see Configuring Asset Category Using Form Builder.

Configuration

On the VALIDATE CONTROLS page (Admin > Basic > Infrastructure > Form Builder > Select a Tenant > Select Module as Asset Management > Click FIXED > Click ADD NEW on the ACTIONS panel > Provide data in all the fields under FORM DETAILS tab > Click NEXT > Drag & drop the required controls and configure their properties > Click NEXT > Click ADD VALIDATION RULES FOR SAVED CONTROLS on the ACTIONS panel > Click ADD icon > Select the required text or numeric Custom Field from the drop-down list and set the condition as “is not empty” > Click NEXT > Select Script Type as Manually Add Script > Enable the On Control Change check box and click SAVE > Click SAVE), the Administrator needs to add the following manual script that enables the Custom Field validation on the ADD ASSET page:


  • To configure the condition where Depreciation Reserve must be <= Original cost:


var AssetCost = (IsNullOrEmpty($('#BodyContentPlaceHolder_txt_64').val()) || isNaN($('#BodyContentPlaceHolder_txt_64').val()) ? 0 : parseFloat($('#BodyContentPlaceHolder_txt_64').val()));

var DepReserve = (IsNullOrEmpty($('#BodyContentPlaceHolder_txt_65').val()) || isNaN($('#BodyContentPlaceHolder_txt_65').val()) ? 0 : parseFloat($('#BodyContentPlaceHolder_txt_65').val()));

if(DepReserve>AssetCost)

{

InitOnScreenNotification('Depreciaiton Reserve should not be greater than Asset cost', 'validationmsg');

      return false;

}


  • To validate the vehicle number field, following code must be added:


var inputtxt = $("#BodyContentPlaceHolder_txt_135").val(); 

var numbers = /^[a-zA-z]{2} \d{2} [a-zA-Z]{2,} \d{4}$/; 

if(!inputtxt.match(numbers))

{InitOnScreenNotification('Vehicle number is not in correct format', 'validationmsg');

return false;};


  • For condition to accept date later than the Date of Purchase and earlier or equal to system date for all Categories:


var TransferDate = new Date($('#BodyContentPlaceHolder_dat_139').val())

var DOP = new Date($('#BodyContentPlaceHolder_dat_67').val())

var currentDate= new Date();

if((TransferDate < DOP) || (TransferDate > currentDate))

{

InitOnScreenNotification('Transfer Date should not be greater than Current Date or Less than Date of Purchase', 'validationmsg');

return false;

}

var DOP = new Date($('#BodyContentPlaceHolder_dat_67').val())

var currentDate= new Date();

var SaleDate = new Date($('#BodyContentPlaceHolder_dat_140').val())

if((SaleDate < DOP) || (SaleDate >currentDate))

{

InitOnScreenNotification('Sale Date should not be greater than Current Date or Less than Date of Purchase', 'validationmsg');

return false;

}