I’ve a simple transformation with AS:LookupValueEx function, but it ends with error. I’m not sure if it is implemented in HTML5 version. It works well in flash version. The concerned transformation part looks like this:
Failed getting lookup text for lookup: 07766b7c-adf6-4ad8-ab90-fcee7e4b0274
Transformation result invalid.
Exception happened during transformation. See inner exception for details:
An error occurred during a call to extension function 'LookupValueEx'. See InnerException for a complete description of the error.
Failed getting lookup text for lookup: 07766b7c-adf6-4ad8-ab90-fcee7e4b0274
Exception was encountered while getting scalar value.
Incorrect syntax near the keyword 'FROM'.
Incorrect syntax near the keyword 'FROM'.
Incorrect syntax near the keyword 'DESC'.
Incorrect syntax near the keyword 'FROM'.
Incorrect syntax near the keyword 'FROM'.
Incorrect syntax near the keyword 'DESC'.
The Lookup Value method expects 4 parameter. When I run the query in SQL console (query generated from Architect), there is no issue.
DECLARE @PriceDiscountProfileDetail_parDate AS DateTime;
DECLARE @PriceDiscountProfileDetail_parDiscountProfileId AS UniqueIdentifier;
DECLARE @PriceDiscountProfileDetail_parProducerBusinessPartnerId AS UniqueIdentifier;
DECLARE @PriceDiscountProfileDetail_parProductId AS UniqueIdentifier;
DECLARE @PriceDiscountProfileDetail_parSiteId AS UniqueIdentifier;
SET @PriceDiscountProfileDetail_parProducerBusinessPartnerId = '83ac9df9-3538-4207-af1e-9c987c74fef5'
SET @PriceDiscountProfileDetail_parProductId = '371ab9a1-a07f-4a7e-908b-3cb17ba11966'
SET @PriceDiscountProfileDetail_parDate = '2021-07-01'
SET @PriceDiscountProfileDetail_parSiteId = '0cccfab0-b2f5-45c2-b4e3-fa4b3f91e606'
SET @PriceDiscountProfileDetail_parDiscountProfileId = NULL
-----------------------------------------------------------------
-- PriceDiscountProfileDetail
-----------------------------------------------------------------
SELECT
[PriceDiscountProfileDetail].[refProductId] AS [refProductId],
[PriceDiscountProfileDetail].[refSiteId] AS [refSiteId],
[PriceDiscountProfileDetail].[DiscountPct] AS [DiscountPct],
[PriceDiscountProfileDetail].[Priority] AS [Priority],
[PriceDiscountProfileDetail].[Id] AS [Id],
[PriceDiscountProfileDetail].[refProducerBusinessPartnerId] AS [refProducerBusinessPartnerId]
FROM
[PriceDiscountProfileDetail] AS [PriceDiscountProfileDetail]
WHERE (
([PriceDiscountProfileDetail].[IsValidForSpecialOffers] = 1) AND
((([PriceDiscountProfileDetail].[refProducerBusinessPartnerId] IS NULL OR [PriceDiscountProfileDetail].[refProducerBusinessPartnerId] = @PriceDiscountProfileDetail_parProducerBusinessPartnerId) AND ([PriceDiscountProfileDetail].[refSiteId] = @PriceDiscountProfileDetail_parSiteId OR [PriceDiscountProfileDetail].[refSiteId] IS NULL) AND [PriceDiscountProfileDetail].[refDiscountProfileId] = @PriceDiscountProfileDetail_parDiscountProfileId AND @PriceDiscountProfileDetail_parDate BETWEEN [PriceDiscountProfileDetail].[ValidFrom] AND [PriceDiscountProfileDetail].[ValidUntil] AND ([PriceDiscountProfileDetail].[refProductId] = @PriceDiscountProfileDetail_parProductId OR [PriceDiscountProfileDetail].[refProductId] IS NULL))));
There seem to be sorting used at the same time. Can you check how the query looks when you display SQL of the sort set? Turning on debug for data service or tracing SQL Server commands could also help to reveal how the final query looks like.
I’m sorry. There is SortSet on that Datastructure an it is used in the Lookup Value part only. When I remove it, it started to work. But the SortSert is essential for that lookup. It is not complicated SortSet - 4 field sorting. This SortSet works well in FLASH version. Any suggestion would be appreciated. Thank you!
The TRIM function we use in order to render multi-column lookup values in SQL is supported from Microsoft SQL Server 2017.
The only way how to make it working will be to change the lookups on the sorted columns to not to have multiple columns in the ValueDisplayMember or to remove the default lookups from those entity fields altogether.
So you mean any Default lookup on Entity filed with multiple columns in ValueDisplayMember causes error, if the AS:LookupValueEx function is calling Lookup with SortSet, which is trying to get data from that Entity?
It does not depend on where from it is called. A sort set with columns that have a lookup with multiple columns in ValueDisplayMember produces TRIM function in the SQL, which is supported from MSSQL 2017 and up.
I can create UDF (user-defined function) TRIM as combination of LTRIM and RTRIM, but it has to be called as dbo.TRIM. Upgrading SQL server is not possible as version 2012 is still supported by Microsoft. Is there a way from your side to implement backward compatibility with older SQL server or add some parameter config file to set the compatibility?
I don’t think it is possible to replicate the TRIM function with UDF. The easiest would be to get rid of the lookups with multiple columns on those sorted fields.