Retail Attributes on sales lines

Recently I've dived into Retail. There will be some posts about retail and the problems I've faced with solutions.

First off will be the Retail Attributes, they can be problematic here is a data base diagram illustrating a simplyfied view, assuming the value is of type text.




And here is the select statement for listing all sales lines with their attributes.


        SalesTable salesTable;
        SalesLine salesLine;

        RetailSalesTableInstanceValue instanceValue;
        EcoResAttribute attribute;
        EcoResAttributeValue attributeValue;
        EcoResTextValue     textValue;
  
while select salesId           
    from salesLine
            join SalesId 
                from salesTable
                where salesTable.SalesId == salesLine.SalesId
            join SalesId, RecID
                from instanceValue
                where   instanceValue.SalesId == salesLine.SalesId
                &&      instanceValue.HeaderOrLineNum == 1 //0 is header, 1 is line
                join    InstanceValue, Value, Attribute 
                    from attributeValue
                    where attributeValue.InstanceValue == instanceValue.RecId
                    join textValue
                        where textValue.RecId == attributeValue.Value
                    join RecId, Name
                        from    attribute
                        where   attribute.RecId == attributeValue.Attribute
                        &&      attribute.Name == 'EncryptedKey'
        {           
            info(strFmt('%1 %2 %3'
, salesLine.SalesId
attribute.Name
, textValue.TextValue
));
        }

Comments

Popular posts from this blog

Call a simple Logic app from X++

SysOperationFramework with use of Query