pjohns
16th October 2002, 14:34
Hello,

I have a form field which is being used to allocate a sequential number to our Baan record, via the program script. At the moment the form field is set to input which allows the user to overtype the auto allocated number. I want to prevent this but the changes I am trying are effecting the functionality of the seq. number allocation.

When the session is opened a seq number is allocated to the form field the user then populates the form and saves the record. The user can also copy another record and when saved a new seq. number will be allocated.

To make the form field non-editable I have set the field type to 'Display Only' in Maintain Forms. I have then entered a form section into the session script so that the form, upon opening, runs the function to create the next free seq number and displays the field. But when I make these changes the seq number is only generated when I open the session for the first time. If I add a record and then try to add another the new seq number is not generated the same happens if I try to copy a record.

Could you please advise where I'm going wrong?

I have attached a file showing extracts from my script.

Thanks

PJ

mark_h
16th October 2002, 15:28
If it worked before, why not just put attr.input=false in the before.input section of the field. I know this is not really the best answer, but I was just wondering while the script downloads.

Mark

mark_h
16th October 2002, 15:35
It looks like you changed the form to display only, but left in the before.input section. I do not believe this will get executed since it is a display only field. You may want to change this to before.display.

Mark

FransG
16th October 2002, 15:37
The problem is in the form section. You use the init.form. This section will only be triggered when you 'open' the form. So, if the record changes this has no impact on the init.form section.

You also save the seq. number even though you're not sure if it will be used. Maybe you should save the number in case you save a record. In that case you can show always the correct number by putting the get.first.free.number() to the before.display.object section. But do not save the seq. number because it will save multiple times while incrementing and that is not what you want.