Hi,
I have to implement validations on the editable detail of a section. For the purpose, I am using addRecord
But while I am trying to get the value of the lookup field which is connecting the records to the main section, it is returning undefined.
Please refer below code:
addRecord: function()
{
this.DurationValidation();
this.callParent(arguments);
}
DurationValidation : function()
{
var invalidMessage="";
try
{
var esqDuration = this.Ext.create("Terrasoft.EntitySchemaQuery", {
rootSchemaName: "UsrPRDetail"
});
esqDuration.addColumn("UsrDurationmin");
var groupFilters = this.Ext.create("Terrasoft.FilterGroup");
var currentPR = this.get("UsrPR");
console.log(currentPR);
var filterId = this.Terrasoft.createColumnFilterWithParameter(this.Terrasoft.ComparisonType.EQUAL, "UsrPR", currentPR);
groupFilters.addItem(filterId);
esqDuration.filters.add(groupFilters);
esqDuration.getEntityCollection(function(result) {
if (!result.success) {
this.showInformationDialog("Request error");
return;
} else {
var totalDuration = 0;
result.collection.each(function(item) {
totalDuration += item.get("UsrDurationmin");
});
this.set("totalSessionDuration", totalDuration);
console.log(totalDuration);
this.showInformationDialog(totalDuration);
invalidMessage = this.get('Resources.Strings.DurationLimitExceeded');
this.showInformationDialog(invalidMessage);
}
}, this);
}
catch(e)
{
console.log(e);
}
finally
{
return {
invalidMessage: invalidMessage
};
}
}
Due to this undefined value, I am not able to check the total duration of details elements in current section record. Please guide in this regard.