66
reposting from https://github.com/microsoft/AL/issues/4711

--

@salgiza:
> You should consider adding the option to specify a const in the DataItemLink.
>
> As an example, the idea would mean being able to do this:
>
> ```
> dataitem(Customer; Customer)
> {
> // (...)
>
> dataitem(SalesPrice; "Sales Price")
> {
> DataItemLink = "Sales Code" = Customer."No.",
> "Sales Type" = const ("Customer");
> // (...)
> }
> }
> ```
>
> Business Central frequently uses the pattern of having two fields for an external key (one to specify the table you are linking, another to specify the key). Ex: when configuring a Sales Price, you can choose whether it applies to a Customer, Customer Group or All Customers.
>
> Now, let's say that I want to do a left outer join to that table, because I want two get all customers with a count of all salesprices assigned for the particular customer (among other customer related info).
>
> That is currently impossible, as any dataitem query filters are added to the Where clause (and that automatically excludes all records where the join didn't find a Sales Price, transforming the outer join in an inner join equivalent).
>
> I've tried to simplify the example, but in the last months I've been involved in several integrations between BC and external apps, that use OData to read data, and today marks the third time where a simple query has to be transformed into something much more complex (and less efficient) due to the fact that I had to link data against a table that used this pattern.

--

@kalberes:
> Makes sense. I do not remember what was the historical reason not supporting const here and some other places.
Category: General
STATUS DETAILS
New

Comments

D

What is the status of this idea?We have also faced this problem with an outerjoin. We need this for performance improvements.

Category: General

D

Related https://experience.dynamics.com/ideas/idea/?ideaid=3c20fb10-3802-eb11-b5d9-0003ff68e671

Category: General