relation.newRecord() not working

Where FormA is the master, and Form B is the form (on a tabpanel) where the method resides, I am executing the following method:

function XXX ()
{
	// if there is an exiting related record, change it...
	if (utils.hasRecords(tableA_to_tableB))
	{
		tableA_to_tableB.field1 = 'a_value'
		databaseManager.saveData()
	}
	else
	{
	// ...create one.
		tableA_to_tableB.field1.newRecord()
		tableA_to_tableB.field1 = 'a_value'
		databaseManager.saveData()
	}
}

This was working yesterday and no longer works today. It’s like the relation has stopped working.
The method is not trapping that records exist and when they don’t exist, the method does not allow their creation giving me a ‘TypeError: Cannot set property’ error. I have checked the relation (allowCreation, AllowParentDelete, deleteRelated), its fields, field types and values. I know I can record variables and go to the native table but this seems a little clumsy?

function XXX ()
{
// if there is an exiting related record, change it…
if (utils.hasRecords(tableA_to_tableB))
{
tableA_to_tableB.field1 = ‘a_value’
databaseManager.saveData()
}
else
{
// …create one.
tableA_to_tableB.field1.newRecord() //I think it should be tableA_to_tableB.newRecord()
tableA_to_tableB.field1 = ‘a_value’
databaseManager.saveData()
}
}

My apologies…that was a typo. The code you suggested is what I have.
Is there any way a relation should stop working. I can see the priammry and secondary tables and enter records into them from a native form.

Hi Nick,

nickbarnett:
Is there any way a relation should stop working.

I have seen relations ‘stop working’ when the table it related to had aggregates on columns that didn’t exist anymore.
So you might want to check that first.

Hope this helps.

Thank You! Thank You! Thank You!

Hi Nick,

nickbarnett:
Thank You! Thank You! Thank You!

This means that this was the culprit ? :)

ROCLASI:
I have seen relations ‘stop working’ when the table it related to had aggregates on columns that didn’t exist anymore.

I suppose this was in 3.5, right? In 4.x, this should be flagged as an error in the error view. If it doesn’t, please file a case because that’s a bug.

Hi Sandor,

svroemisse:
I suppose this was in 3.5, right?

This was indeed in 3.5.x