Setting a field after omitting a record

I currently have a foundset of more than 1 record. I want to set a field in any of the other records (doesn’t matter which). In FMP a suitable technique would be to omit the current record, then set the field (taking effect in whatever record is now current). Nothing more complicated than that.

Not so in Servoy. Setting the field doesn’t take effect. Here’s the code that doesn’t work.

var count = foundset.getSize(); 
application.output('current count = ' + count); // = 6
controller.omitRecord();
pref_com = 1; // setting the required field

In an attempt to grab the attention of the current record I’ve tried and failed with this variation:

var count = foundset.getSize(); 
application.output('current count = ' + count); // = 6
controller.omitRecord();
var ix = foundset.getSelectedIndex();
foundset.setSelectedIndex(ix);
pref_com = 1; // setting the required field

It simply brings back the omitted record. Anyone have recommendations?

Kind regards,

Addendum. Since posting the above I’ve verified the Omit function is indeed successful, returns “true”.

if you do this:

application.output('current count = ’ + foundset.getSize());
application.output(pref_com);
controller.omitRecord();
application.output('after ommit count = ’ + foundset.getSize());
application.output(pref_com);

(or do not print pref_com but an id or other dataprovider to be sure. What happens then?)

application.output('current count = ' + foundset.getSize()); // = 5
application.output(pref_com); // = 1.0
var result = controller.omitRecord();
application.output('result = ' + result); // = true
application.output('after omit count = ' + foundset.getSize()); // = 4
application.output(pref_com); // = 0.0
pref_com = 1; 
application.output(pref_com); // = 1.0

Problem has gone away. Obviously some other as yet unknown factor is at play here. Will chip away at this issue this morning.

Thanks.

Absolutely bizarre!! Put the identical code into the actual solution and it goes back to showing a full count right after returning “true” for omitting a record.

In the meantime I’ve thought of and successfully tested an alternative route to my desired result.

But very strange. Thanks.