I have a problem addig a record in a related foundset. When running from mobile application I can see that the master record ID is the same as the foreign key in the children records (for example -1076) I can navigate thru all the forms in the application and I see those values are right but when I sync the master record gets a UUID and the children gets a different fk, equal between them but different to the parent key.
This is the data model declaration in the service application
- Code: Select all
/** @type {JSFoundSet<db:/galaco_mobile/orders>} */
var _fsOrders = databaseManager.getFoundSet('db:/galaco_mobile/orders');
_fsOrders.loadAllRecords();
var _ordersRelations = new Array();
_ordersRelations.push('orders_to_orders_details');
dataModel.addFoundSet(_fsOrders, _ordersRelations);
customers_to_customers$userid.loadAllRecords();
var _customersRelations = new Array();
_customersRelations.push('customers_to_customers_products');
dataModel.addFoundSet(customers_to_customers$userid, _customersRelations);
and I create the record like this:
- Code: Select all
var _orderRC = foundset.getRecord(foundset.newRecord());
_orderRC.customers_id = _customerID;
_orderRC.fecha = new Date();
databaseManager.saveData();
if (_fromHistory) {
// Get all the customers products and add them to the details table
if (utils.hasRecords(_orderRC.orders_to_customers.customers_to_customers_products)) {
_orderRC.orders_to_customers.customers_to_customers_products.loadAllRecords();
/** @type {JSFoundset<db:/galaco_mobile/customers_products>}*/
var _fsProducts = _orderRC.orders_to_customers.customers_to_customers_products;
for (var i = 1; i <= _fsProducts.getSize(); i++) {
_fsProducts.setSelectedIndex(i);
if (utils.hasRecords(_fsProducts.getSelectedRecord().customers_products_to_products)) {
/** @type {JSRecord<db:/galaco_mobile/orders_details>}*/
var _rcItem = _orderRC.orders_to_orders_details.getRecord(_orderRC.orders_to_orders_details.newRecord());
//_rcItem.orders_id = _orderRC.order_id;
_rcItem.cantidad = 1;
_rcItem.precio = _fsProducts.getSelectedRecord().customers_products_to_products.uc;
_rcItem.importe = _rcItem.cantidad * _rcItem.precio;
_rcItem.products_id = _fsProducts.getSelectedRecord().customers_products_to_products.product_id;
}
}
}
}
I'm sure I'm missing something but I do not get what it is. Any one can help me please?
Thanks in advance