Default Dimensions for Extension Table
Hi,
I was trying to add Default Dimensions to a Master Data Table from my Extension. So I added the "Dimension - Single" action to my Page according to the pattern used in e.g. Customer List.
No problem to depoy it, but unfortunately the "Default Dimension" table has a Table Relation, which is also validated.
IF (Table ID=CONST(13)) Salesperson/Purchaser ELSE IF (Table ID=CONST(15)) "G/L Account" ELSE IF (Table ID=CONST(18)) Customer ELSE IF (Table ID=CONST(23)) Vendor ELSE IF (Table ID=CONST(27)) Item ELSE IF (Table ID=CONST(152)) "Resource Group" ELSE IF (Table ID=CONST(156)) Resource ELSE IF (Table ID=CONST(167)) Job ELSE IF (Table ID=CONST(270)) "Bank Account" ELSE IF (Table ID=CONST(413)) "IC Partner" ELSE IF (Table ID=CONST(5071)) Campaign ELSE IF (Table ID=CONST(5200)) Employee ELSE IF (Table ID=CONST(5600)) "Fixed Asset" ELSE IF (Table ID=CONST(5628)) Insurance ELSE IF (Table ID=CONST(5903)) "Service Order Type" ELSE IF (Table ID=CONST(5904)) "Service Item Group" ELSE IF (Table ID=CONST(5940)) "Service Item" ELSE IF (Table ID=CONST(5714)) "Responsibility Center" ELSE IF (Table ID=CONST(5800)) "Item Charge" ELSE IF (Table ID=CONST(99000754)) "Work Center" ELSE IF (Table ID=CONST(5105)) "Customer Template" ELSE IF (Table ID=CONST(849)) "Cash Flow Manual Revenue" ELSE IF (Table ID=CONST(850)) "Cash Flow Manual Expense"
Any idea, how I can solve that? Does it actually make sense to have the Table Relation here?
Unfortunately you cannot extend dynamic table relations yet. It is on our backlog, but hasn't been been picked up yet. I will add a +1 request from you :-)
Please add a +1 request for me to.
Please describe scenario for this - the user can set the default Dimensions within Business Central - in which scenarios is it needed to set this from an Extension.
Our ISV solution is in the automotive retail space. Therefor we are dealing with Vehciles. When selling something to a Customer (A Sparepart or a Service), it is often required to select for which specific Vehicle that Sale is done. You select the Vehicle in the Document Header.
So we have the additional Vehicle Master Entity and would like to be able to derive Dimensions from the selection based on the standard Default Dimension Concept.
Initially you mention you want to insert a default dimension, however for the scenario you mention that you want to "derive" e.g. get the default dimension, can't you get the default dimension in this scenario?
Maybe my wording is a bit confusing. Let me explain the scenario again:
We have a Vehicle Table, a Vehicle Card and a Vehicle List. On the Vehicle Card and Vehicle List Pages I want to add the same Dimension related functions like on e.g. Customer Card (Dimensions) and List (Dimensions-Single, Dimensions-Multiple) in order to be able to assign a Default Dimension to the Vehicle.
When I now use one of the Vehicles in a Sales Order, I want the Dimension Set ID not only be derived from the Default Dimensions of Customer, Salesperson/Purchaser, Campaign, Responsibility Center and Customer Template, but additionally from the Vehicle.
But due to the Table Relation of the Table ID field in the Default Dimension Table, it is not possible to register/insert any records not foreseen by the NAV Standard. The same problem also exists in the Default Dimension Priority Table.
In general it would be great if we could extend conditional Table Relations as @JesperSchulz suggested.
Thank you - got it, we will investigate possible solutions to this.
Here is the solution we came up with: The table relation is blanked and replaced by the code in trigger "No.".OnValidate() that verifies if the record with primary key equal to "No." in the table set in "Table ID" field. The removed table relation had been handling the renaming of the related tables. This is now implemented by the call of function COD408.RenameDefaultDim() in the trigger OnRename() of all related tables.
Extensibility: "Table ID" in table 352 is verified against the list of table IDs returned by COD408.DefaultDimObjectNoList(). This function collects all tables that match the following conditions:
- have fields related to global dimensions
- do not have "Dimension Set ID" field
- their primary key include one field
If the extension table satisfies these conditions, its ID will be accepted by table 352 automatically. If the table does not get to the list it can still be added by subscription to the event COD408.OnAfterSetupObjectNoList() and modifying the buffer table.