I have this code that will create a related record if there is no related record already existing. This is done when the field gains focus.
//see if the related record exists
if(!forms.contact_main.gconst01_to_address.address_id)
{
//if not, create one and set the focus back to
//the field they clicked in
var fieldName = application.getMethodTriggerElementName();
//create a new record in foundset
forms.contact_main.gconst01_to_address.newRecord(true);
elements[fieldName].requestFocus();
}
This code never works right. The condition is always skipped (never true). So I ran the debugger and watched the related field “forms.contact_main.gconst01_to_address.address_id” and it always has some number in it, even though I have no record in that related table.
Do I understand correct that the relation is named ‘gconst01_to_address’? If so why don’t you do a check on child records like:```
if (!databaseManager.hasRecords(forms.contact_main.gconst01_to_address))
IT2BE:
Do I understand correct that the relation is named ‘gconst01_to_address’? If so why don’t you do a check on child records like:```
if (!databaseManager.hasRecords(forms.contact_main.gconst01_to_address))
Well, I tried that and the same problem. So I decided to create some records manually in the address table that are related to some contacts. When I viewed them from my contact form through a tab panel to the addresses, none where listed. This is maybe why it is not working.
So, do tab panels automatically show related records by the relation that is set to them?