Validation in table relation

Hi,

I’ve created a relation between tables 5608 and 5607, FA Sub Classes and Classes. Basically for each sub class one valid class has to be defined

FA Class

Code Desc

01 Test

02 test2

FA Sub Classes

Code Desc FA Class

01 XPTO 01

02 OTPX 02

Testing the lookup values on the FA Card via NAV works fine, and the values are correctly looked up, but someting is missing because it’s not validating the values… One of the test that i’ve made was choosing Classe 01 and sub class 01, that it’s correct, but before saving i’ve changed the classe to 02 without changing the subclasse and… the system saved with no error…

Shoulndt the system alerts me that SubClass 02 was invalid?

What i’ve done wrong?

Thanks in advance

Best Regards

João Martins

If I do understand you right you do allow the user to select a FA Class on the FA Card. Based on the FA Class, when selecting FA Subclass the user should only be able to select those subclasses that are linked to the FA Class that the user just selected. Right?

If so, you have to make sure (by setting the right filter on the TableRelation of the FA Subclass field on the Fixed Asset table.

Next to that, if the user does not select a FA Class but immediately selects a FA Subclass you have to write code (o the OnValidate trigger of the FA Subclass field) to populate the FA Class field with the same value as defined in the FA Class for the selected FA Subclass value.

Hi Luc,

Thanks for your reply. The tables relations are working fine. The values for subclasses that are showed are based on the FA Class value that were choosed…

My question is the validations on the table relations… Picking my above example for Class 01 the system should only accepts SubClass 01 when saving the FA. The problem is if i choose Class 01 and SubClass 01 when creating the FA, but if before saving i change only the Class to 02, the SubClass remains 01, the system doesn’t do the table relation validation.

Shouldn’t the system do the validation on this FA, checking that Class 01 and SubClass 02 are invalid?

Thanks for all

Regards

JM

We could argue about “shouldn’t”, but definitely NAV is not doing. You’ll have to code that on the relevant OnValidate triggers:

  • If you change the FA Subclass field on the OnValidate trigger of that field
  • If you change the FA Class field on the OnValidate trigger of that field

Think about what would have to happen if it did. It would be similar to what it does during a rename. It would have to go look at every field in every table to see if changing the value broke a sub-relation. And then if that sub-relation had a relation it would have to check that. And so on and so on. I would literally take minutes to change fields that had a relation.

As stated above, you’ll have to write proper code to do that.

Thanks for your anwsers guys.

Topic Closed :slight_smile:

Regards

JM

You’re welcome.