My requirement was to add a new custom dimension named “EmployeeDepartment” that retrieves the existing department values.
However, this new dimension should be visible only on a specific form. Typically, financial dimensions are derived from the accounting structure. If we configure this new dimension within the accounting structure, it becomes visible across all forms — which is not what we want.
To achieve this requirement, I developed the following custom code.
----------------------------------
[FormEventHandler(formStr(LedgerJournalTransDimension), FormEventType::Initialized)]
public static void LedgerJournalTransDimension_OnInitialized(xFormRun sender, FormEventArgs e)
{
if(sender.args().menuItemName() == menuItemDisplayStr(LedgerJourTransDimLedgerJourTrnVendPaym))
{
DimensionEntryControl dimControl = sender.design().controlName(identifierStr(DimensionEntryControl));
DimensionEnumeration dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger();
DimensionAttributeSetStorage dimensionAttributeSetStorage;
DimensionAttribute dimensionAttribute,dimensionAttributeloc;
DimensionAttributeSetItem dimAttrSetItem;
dimensionAttributeSetStorage = new DimensionAttributeSetStorage();
while select dimensionAttribute
where dimensionAttribute.Name != "MainAccount" // In my case i don't need Main Account in my form
join dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimensionAttribute.RecId
&& dimAttrSetItem.DimensionAttributeSet == dimensionSetId
{
dimensionAttributeSetStorage.addItem(
dimensionAttribute.RecId,
dimensionAttribute.HashKey,
NoYes::Yes);
}
select dimensionAttributeloc
where dimensionAttributeloc.Name == "EmployeeDepartment" ;
if(dimensionAttributeloc)
{
dimensionAttributeSetStorage.addItem(
dimensionAttributeloc.RecId,
dimensionAttributeloc.HashKey,
NoYes::Yes);
}
dimControl.parmEditableDimensionSet(dimensionAttributeSetStorage.save());
dimControl.parmDisplayedDimensionSet(dimensionAttributeSetStorage.save());
}
}
-------------------
Reference blog : https://d365dev.com/2018/04/20/disable-editing-of-specific-financial-dimensions-on-form/
Created a new custom dimension.
No comments:
Post a Comment