Sunday, 15 December 2024

Derived dimensions in d365 FO X++

public static void main(Args _args)

inventParameters  inventParameters;


select    inventParameters;

RefRecId  defaultDimension;


defaultDimension = InventSite::find('21').DefaultDimension;


// Deriving default dimensions linked to inventory site

DimensionDefault derivedDimension = LedgerDimensionFacade::serviceApplyDerivedDimensionsForAttribute(defaultDimension,

inventParameters.SiteDimensionAttribute, Ledger::current());


// Merging derived default dimension linked to inventory site with original default dimension

boolean precedenceEnabled = DimensionAttributeDerivedDimensions::derivedDimensionPrecedenceEnabled();


if (precedenceEnabled && DimensionAttributeDerivedDimensions::dimensionAttributeHasDerivedDimensionPrecedence(inventParameters.SiteDimensionAttribute))

{

defaultDimension = LedgerDimensionDefaultFacade::serviceMergeDefaultDimensions(derivedDimension, defaultDimension);

}

else

{

defaultDimension = LedgerDimensionDefaultFacade::serviceMergeDefaultDimensions(defaultDimension, derivedDimension);

}

DimensionSetEntity  dimensionSetEntity;


select * from dimensionSetEntity

where  dimensionSetEntity.RecordId == defaultDimension;

info(strFmt('%1', dimensionSetEntity.displayvalue));
}

No comments:

Post a Comment

Clean up jobs in D365FO

  https://anithasantosh.wordpress.com/2024/11/07/clean-up-jobs-in-d365fo/