which trigger i must use?

i have an unbound form to save 1 field to 1 tabel

the code is like this :
t_sub_wilayah.kotamadya_kode:= KodeKotamadya;

if I used it with command button i can work successfully

but if i put in on trigger (form or text box) if cannot be done :frowning:

I already put it on OnLookUp trigger, onValidate, on aftergetcurrrecord, etc

all failedā€¦ do you know which trigger i must used to solve problem like this?

Assuming the source table is different than the form, you should put your code on OnAfterValidate trigger on the field on the form.

However, why not put the code on the table instead?

I second Alex on this, you should attempt, where possible, to keep code off the forms. There are instances where you need to put code on the form, but it is ā€œbest practiceā€ not to put code on a Form that could be called from the table, or another object.


Yes, but not only that. You should also have Dynamics NAV version 5.1 in mind, where you will not be able to have code on forms. So better rethink your development code now and then later get an easier upgradeā€¦

In general if you need to put business logic on a Form, then you are doing it wrong. Take a big step back and redesign what ever you are trying to do.

Actually that might change [;)] Even the BAD team have put code on forms, so it might last a little longer until they can clean up all their errors. Just look at planning and production.

so?if we use nav 5.1, we donā€™t have to use C/AL ?

do you mean same code and same C/AL Global?

but we should put it on table?

am I right that if we put it in the form is more safety than put it in table?

No, ALL 5.1 NAV development will be done in C/AL, in the same editor that we use now. The only thing that will be added is RDL layout development in external RDL editors, which can then be saved within the NAV report object. Then with the web services, it will be much easier to hook up .NET development to NAV functionality. However, NAV development itself will be in C/AL.