New unsave record not visible in another foundset

Hi,

I would like to access a record that was just created, but not saved in the database, through other foundset instance, different then the one where it was created.

// file.js

function testFoundSet() {
    databaseManager.setAutoSave(false);

    var foundSetA = databaseManager.getFoundSet("server", "table_test");
    foundSetA.loadRecords("some sql query");

    foundSetA.newRecord();
    foundSetA.field1 = 12;
    foundSetA.field2 = "Some text";

    return globals.processData(foundSetA.record_id);
}

// globals.js

function processData(recordId) {
    var foundSetB = databaseManager.getFoundSet("server", "table_test");
    foundSetB.loadRecords(recordId);

    // Here the foundSetB will have 0 records.
    // What I would like is to have the new record that was just added, but not saved.
}

I know I could pass the foundSetA to the globals.processData, but let’s say I can’t do that. Or how can I do it in case the call is made from a function in a table calculation file, where the foundSetA is the table itself and actually it would miss from the code because we are inside the foundset there? Something like this:

// table_test_calculations.js

function test_calculated_value() {
    // databaseManager.setAutoSave(false); and foundSetA.newRecord(); were already called from another place

    return globals.processData(record_id);
}

This should be possible and it’s really useful in the same client. How can it be achieved?

Thanks,
Bogdan.

this is not possible because the other foundset has no way to query for that new not saved record.

But can you implement it in a new release? You only have to make sure that in the current client all foundsets are persistent. At least in the current client!

Thanks,
Bogdan.

but how do you want to “transfer” the new record to another foundset?

If this would be possible then that would really be a manual thing, so foundset.add(foundset.getRecord()) or something like that. which would be quite horrible,

Much better is that you give the record as a return value. Why are you giving the record_id then trying to load it again? Why not just pass around the record itself?

How can I pass the current record from a Calculations method? As I mentioned in this example:

// table_test_calculations.js

function test_calculated_value() {
    // databaseManager.setAutoSave(false); and foundSetA.newRecord(); were already called from another place

    // HERE, INSTEAD OF record_id, HOW CAN I PASS THE CURRENT RECORD THAT IS BEING CALCULATED?
    return globals.processData(record_id);
}

create a self relation (a relation with now fk-pk and left and right table are the same)
then you can do something like:

return globals.processData(mytable_to_mytable.getSelectedRecord());

OK, Thank, I’ll try it. This is really useful if it works. I should have thought about :) It’s logic!