flowField onValidate() ?

hi masters :slight_smile:

i am experiencing this problem:

i have a table with a foregn key (Customer ID) and a flow field (customer name). customer name is being refreshed by calcfields in cusotmerID ‘onValidate()’.

now, i am developing a code unit which needs to validate if that field (customer name) is not empty. since it’s a flow field, i was trying to use the field.VALIDATE function, but i need to have some code in the OnValidate trigger in the customer name field…but what? EXISTS? i’m not being successful.

it’s quite a big question, but i’m guessing the answer must be easy, though i’m quite swimming among c/al functions…

thank you in advance,

mike

Have you tried to calcfields and then do a string comparison against it?

So

Calcfields(“Customer Name”);

If “Customer Name” <> ‘’ then …

My only concern here would be, why are you checking if a name exists in the flowfield before doing some functionality?

I would recomend getting the customer record and checking at that level, since its a flowfield the information would be the latest.

Cust.Reset;

If “Customer No.” <> ‘’ then

If Cust.get(“Customer No.”) then

If Cust.name <> ‘’ then begin

But the primary key value for the Customer Record is the No. so its “normal” to base functionality on whether a Customer exists or not, rather than whether the Name is blank or not. But saying that it you may have a good reason for your logic.

Regards

T

I agree with Tony, just want to add more info.

I think you are missusing the word validate. Or at least using the wrong function. VALIDATE(Name) in NAV means to call the triggers in the name field. This replicates the functionality of a user manually entering a value in that field.

My guess is that what you are doing is trying to determine if a Customer record has the Name field filled in or not, and if not to then update it with a value. In this case do it the way Tony suggests. If something else, then try to explain WHAT you want to do not HOW you want to do it.

Hi there again and Thank you both;

in effect, I did have to do a comparison with the origin field in the DB!

the question is: I thought we could copy flowfields from one table to the other as if they were “normal class” fields… just a second week rookie :slight_smile:

but this took me to a bigger problem:

wil I have to manually lookup every table each time I want to copy a flow field? It’s not ‘difficult’, it’s just an extra work to codify as well as an extra effort to the DBMS more than I was expecting…

Thanks again,

mike

Hi Mike,

You should not need to be copying fields from one table to another, the idea behind the database is to minimize the duplication of data, that way when creating functionality its best to be able to use primary keys when working with more than one dataset.

In the case of Flowfields, I try to minimize my use of them as much as possible.

The flowfields that you are copying may have pertinent fields to their calculation from the table you are copying from, and if you wish to copy the flowfield you would need ensure that these fields are copied too.

But I don’t recommend this as a usual course of action, it would mean you would need to make sure the data in those fields is correct in both tables, and you are effectively de-normalizing the database.

If you have a particular issue that you need help to resolve and develop if you provide it here we may be able to help you design the best solution.

Regards

T