Accessing dataset via DataSource

I have a pop up form with a TWebDataSource linked to some controls. The form has a property Dataset: TDataset.

After the form is created the Dataset (in this case a TXDataWebDataset) and this is set as the Datasources Dataset and the data shows in the controls.

When I later try to access the dataset with

MySource.DataSet.FieldByName('ProductId').AsInteger := Integer(lProduct.Properties['Id']);

I get the exception

ERROR
Uncaught TypeError: Cannot set property 'ProductId' of null | TypeError: Cannot set property 'ProductId' of null at Object.SetJSONDataForField

Where am I going wrong?

That error indicates that the underlying JS object being edited by the dataset doesn't have a property ProductId, or that there is no underlying object.

I have tracked down the issue. It's not on the dataset side it's on the array side.

I have a call that retrieves a TJSObject from a TJSArray and then call Properties['Id']. however, javascript has converted this into an actual object, so properties doesn't exist. I can call lProduct.Id and that is correct, but the webcore app won't compile with that call.

Ok, That was a possible error, but not this error.

This is a rookie error - the dataset was not in edit mode.

I would expect a 'Dataset not in edit mode' error not some Null error.

It was raised in TBaseJSONDataSet.SetFieldData where R (FEditRow) is undefined. The Buffer passed into that routine is the correct record, although that isn't used in the method - actually the line that used it is commented out as it seems to be replaced by FEditRow.

2 Likes

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.