TableRelation in C/AL Code ?

Ok. So what you’re really looking for is to code a customer table lookup, not a custom table relation! [:)]

I would start by creating a new function on the custom table to avoid coding it on the page. This new “LookupAvailableResources” could be something like this:

resource.reset; Resource.setrange(Available,true); IF PAGE.RUNMODAL(0, Resource) = Action::LookupOk then validate("Mat. No.", Resource."No.");

Thx Erik, this code open the resource list page. Or i did an mistake ?

I did function in my custom table. And after i call this function in my page on the Mat. No. OnLookup trigger.

Arnaud’

IF PAGE.RUNMODAL(0, Resource) = Action::LookupOk then
Above code will run the Page which is set in resource table’s LookupPageID property.

Isn’t that you are expecting?

No, i just want to have the same like in this screenshot.

It is possible only if you use Table Relation but you dont want to set Filter on Table Relation.

If you want to do it via coding then the resource list will open in a new page.

Yes that’s the expected result.

But you can also apply the same table filter by setting the table relation manually on the Mat. No. control directly on the page. But you cannot do it via C/AL code.

Hummm ok thx so I ask impossible thing :stuck_out_tongue:

Last question, if I put filter manually i have an error with French language version.

It translate the CONST “Yes” in french language.

Error message : Le filtre “Oui” n’est pas valide pour le champ Availble de la table Resource. “Oui” is not an option. “The existing options are: No, Yes”

Yes, sorry you must use Yes also in the development system.

But I actually come to think of a way where you can still do it and not “hardcode” the filter.

You could create another new field in your custom table. Call it “Availability Filter” and create it as a Boolean type Flow Filter field.

Then you can use this filter field in your table relation to the “Mat. No.” field so the relation instead will be Available=FIELD(Availability Filter).

It doesn’t works :confused:

I just tested it here and it does work on my NAV 2013. Exactly what did you do and which part doesn’t work?

It doesn’t filter the available resource. I must affect value to my flowfilter ?

How can i change the availibity of a product ?

If you have created the new flowfilter field, then all you need to do is to set this filter. And that you can set either in the OnOpenPage trigger or on the OnAfterGetRecord trigger. Simply by SETRANGE(“Availability Filter”,TRUE). Or it can be set manually by the user. The flow filter field will show up in the “Limit Totals” filter.

But i don’t understand the relation between the “Available” field in the Resource table and the “Availibity Filter” field in my custom table.

The relationship is what you specify in the table filter in the relationship setup. You can see it as an optional/variable filter.

Thanks it works.

Hello after research,

the filter doesn’t works when i put my RTC in french language. Before i had errors message if you remember, this message doesn’t appear but the filter doesn’t works :confused:

Thanks in advance !

Arnaud’

Did you create captions in both ENU and French?

Which captions ?