In this tutorial, we'll show how to make sure users add at least two details records while adding a master. We will be using new Javascript APIs added in version 10.3. This code will work without any changes in ASPRunner.NET and ASPRunnerPro as well.
Make sure you enabled adding master and details at the same time on the master table Add page. This code needs to be added to master table Add page Javascript OnLoad event. Replace 'order details' with your details table name.
this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
// get details table Page Object
var details = pageObj.getDetailsPage( 'order details' );
// get all details records
allRecords = details.getAllRecords();
if (allRecords.length<2){
alert('You need to enter at least two details records');
Runner.delDisabledClass ( pageObj.saveButton );
return false;
}
else {
return true;
}
});
And this is how it looks in the generated application when you try to save the record:
