OmitRecord problem

I want to remove the first record of a foundset when my people form opens. I’m doing:

forms.people.controller.recordIndex = 1;
forms.people.controller.omitRecord();

on the OnLoad event, but I still see the record when the form is shown.

What am I doing wrong?

Just a remark and don’t know which version you use but bare in mind that with 2.1 setting the recordindex has changed into: controller.setSelectedIndex(number index).

The omit record function gives you back a boolean. Can you tell if that’s true or false? That should give you some answers…

I changed my code to:

var myMain = currentcontroller.getName()
forms.people.controller.setSelectedIndex(1)
var myVal = forms.people.controller.omitRecord();
plugins.dialogs.showInfoDialog( “myVal”, myVal)

It didn’t help.

When it runs, the omitRecord returns false – but I’m not sure why or what to do about it…

Remark: You can also do application.output(“myVal:”+myVal). I like this better because the output shows in de debugger and doesn’t interfere with the interface of the solution.

As far as I can tell ‘false’ tells you the omit record command failed. We knew that already :shock: but it is now confirmed…

Are you sure the controller has records. What does getMaxRecordIndex tell you? when you start with that

var max = forms.people.controller.getMaxRecordIndex();
forms.people.controller.setSelectedIndex(1);
var index = forms.people.controller.getSelectedIndex();
var result = forms.people.controller.omitRecord(); 
application.output( "max:"+max+", index:"+index+", result:"+result);

Nice trouble-shooting code.

That helped identify the problem.

When I ran it, MaxRecords, SelectedIndex, and OmitRecords were 0, 0, false.

I moved the method to the OnShow event rather than the OnLoad event and it worked fine. I guess the OnLoad event fires before the foundset is loaded.

Thanks for your help!

aha… That’s it.

Your first post stated ‘when my people form opens’. That’s not true if you do this onLoad! With an onLoad you only ‘load’ the form. This event can be used to set element visibility etc. or whatever things you want to be done BEFORE you show the form for the first time.

What you could do however, if you ONLY want/need to omit on the first show of the form, is put the following code into your method attached to the onShow event:

var firstShow = arguments[0];
if (firstShow)
{
	//your code;
}

This way you check if the form is shown for the first time and it is only then that you method gets executed.

I think I found a bug.
At least I wouldn’t expect the following kind of behaviour:
I was getting false when trying to omit a record.
Tried everything, checked the number of records, set the index to different record, checked the relations between the forms, etc.
The record just wouldn’t omit.
I have just thought there’s something special about this particular record (others were omitting successfully), and this something was that it has a value in one of its fields that is used in a rowBGCalculation global method to color this row in a different color.
Unassigning the row color method off the form fixed the problem straight away.
But I would love to be able to use it.
So, is it a bug or was I doing anything wrong?

Cheers,
Maria

Maria,

You cannot access any data (like omitting records) in the form onLoad event, the foundset is not initialized yet at that point.
Instead you can use the form onsHow event, the boolean arg firstShow can be used to make sure you onit only once.

Rob

rgansevles:
Maria,

You cannot access any data (like omitting records) in the form onLoad event, the foundset is not initialized yet at that point.
Instead you can use the form onsHow event, the boolean arg firstShow can be used to make sure you onit only once.

Rob

Rob, I’m not omitting records in the form onLoad event or onShow.
It happens when the user performs certain actions while viewing the form.

Maria,

I got confused with the start of this thread.

omitRecord will try to save the record when it is edited, when this is blocked somehow the omit fails.
The rowbgcolorcalc seems to block this (does the calc change data?)

Can you show this in a small sample?

Rob