/*
onAddNewRecord is Called after the addNew is called and the item is added to the datasource.
*/
onAddNewRecord({ datasource, item }) {
console.log('Entering AppCustomizations.onAddNewRecord');
if (this.page.name === 'createSR' && datasource.name === 'dsCreateSr') {
this.page.state.xxx_descriptionUpdated = false;
}
console.log('Exiting AppCustomizations.onAddNewRecord');
}
/*
onValueChanged is called after data has changed on a field in a datasource. It allows for an opportunity to reject the change, and while you can’t reject it (it already happened), you can use some additional datasource APIs to alert the user of failures, etc
*/
onValueChanged({ datasource, item, field, oldValue, newValue }) {
console.log('Entering AppCustomizations.onValueChanged');
//
// check if there is data in newValue
//
if (this.page.name === 'createSR' && datasource.name === 'dsCreateSr' && field === 'description' && newValue != undefined && newValue != "") {
//
// we only want to null the description first time, use custom state (xxx_descriptionUpdated or use other names as preferred) to track if it has been updated before on this SR
//
if (this.page.state.xxx_descriptionUpdated === undefined || this.page.state.xxx_descriptionUpdated === false) {
this.page.state.xxx_descriptionUpdated = true;
//
// description is derived from below states (subcategory or topcategorydesc) in addNewServiceRequest function in CreateSRController Controller, if any of them match, null the value.
//
if (newValue === this.app.state.subcategory || newValue === this.app.state.topcategorydesc) {
console.log('Removing Description Value: ' + newValue);
item[field] = "";
}
}
console.log('Existing AppCustomizations.onValueChanged');
}
}