
Hi Team,
I am trying to update the Business Unit financial dimension on a journal line based on the InvoiceId.
I retrieve the invoice record from CustInvoiceJour and use its DefaultDimension:
ledgerJournalTrans.DefaultDimension = custInvoiceJour.DefaultDimension;
To find the dimension value, I am using:
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttribute;
select firstOnly dimAttrValue
where dimAttrValue.DisplayValue == paymentTable.CatalogId;
if (dimAttrValue.RecId)
{
dimAttribute = DimensionAttribute::find(dimAttrValue.DimensionAttribute);
info(strFmt("CatalogId=%1, Dimension=%2",
paymentTable.CatalogId,
dimAttribute.Name));
}
I checked in SSMS using the following query:
SELECT DAV.DISPLAYVALUE,
DA.NAME
FROM DIMENSIONATTRIBUTEVALUE DAV
JOIN DIMENSIONATTRIBUTE DA
ON DAV.DIMENSIONATTRIBUTE = DA.RECID
WHERE DAV.DISPLAYVALUE = 'PVC'
Result:
PVC BusinessUnit
PVC Brand
The same value exists in multiple dimensions. Because of this, the lookup is not consistently identifying the Business Unit dimension, and the Business Unit value is not getting updated.
What is the recommended approach to update only the Business Unit dimension in the invoice's DefaultDimension based on CatalogId without hardcoding the dimension name?
Thanks.