Sales order Holds
Sales orders in D365 can have holds, stopping their further processing. He is the data diagram over the tables.
A select statement would look like this, showing all sales orders that have a certain hold code.
A select statement would look like this, showing all sales orders that have a certain hold code.
SalesTable salesTable;
MCRHoldCodeTrans
holdCodeTrans;
MCRHoldCodeTable
holdCodeTable;
while select SalesId,
from
salesTable
join
MCRHoldCode, InventRefId
from
holdCodeTrans
where holdCodeTrans.InventRefId ==
salesTable.SalesId
//Needs setup
parameter
&& holdCodeTrans.MCRHoldCode == 'RX
Item'
{
info(strFmt('%1 %2
%3 %4'
,
salesTable.SalesId
,
holdCodeTrans.MCRHoldCode));
}
A more complex view including Retail Attributes on sales order lines, which was the actual task.
SalesTable salesTable;
SalesLine
salesLine;
MCRHoldCodeTrans
holdCodeTrans;
MCRHoldCodeTable
holdCodeTable;
RetailSalesTableInstanceValue
instanceValue;
EcoResAttribute
attribute;
EcoResAttributeValue
attributeValue;
EcoResTextValue textValue;
while select salesId, ItemID, LineNum
from salesLine
join
SalesId
from
salesTable
where
salesTable.SalesId == salesLine.SalesId
join
MCRHoldCode, InventRefId
from
holdCodeTrans
where holdCodeTrans.InventRefId ==
salesTable.SalesId
//Needs setup
parameter
&& holdCodeTrans.MCRHoldCode == 'RX
Item'
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
//Needs setup
parameter
&& attribute.Name == 'EncryptedKey'
{
i++;
info(strFmt('%1 %2
%3 %4 %5 %6 %7'
, i
,
salesLine.SalesId
, salesLine.ItemId
, salesLine.LineNum
, textValue.TextValue
, attribute.Name
,
holdCodeTrans.MCRHoldCode));
}
Comments
Post a Comment