Hallo,
i want to disable MainAccount in financial dimension Purchase requisitions Line,
but its error Object reference not set to an instance of an object., need advise for my case how can i solve ?
my reference to link :
https://d365dev.com/2018/04/20/disable-editing-of-specific-financial-dimensions-on-form/
i just change event handler to
[FormEventHandler(formStr(PurchReqTable), FormEventType::Initialized)]
public static void PurchReqTable_OnInitialized(xFormRun sender, FormEventArgs e)
{
DimensionEntryControl dimControl = _sender.design().controlName(identifierStr(DimensionEntryControlTable));
DimensionEnumeration dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger();
DimensionAttributeSetStorage dimensionAttributeSetStorage;
DimensionAttribute dimensionAttribute;
DimensionAttributeSetItem dimAttrSetItem;
const str MainAccounttmp = 'MainAccount';
dimensionAttributeSetStorage = new DimensionAttributeSetStorage();
while select dimensionAttribute
where dimensionAttribute.Name != MainAccounttmp // Exclude specific dimension which should be not editable
join dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimensionAttribute.RecId
&& dimAttrSetItem.DimensionAttributeSet == dimensionSetId
{
dimensionAttributeSetStorage.addItem(
dimensionAttribute.RecId,
dimensionAttribute.HashKey,
NoYes::Yes);
}
dimControl.parmEditableDimensionSet(dimensionAttributeSetStorage.save());
}
Thanks
Hi Dodi, The issue is in below line. 'DimensionEntryControlTable' form control exists in SalesTable form, as the article is using SalesTable so no issues for that code. However, you are trying to use same control name in PurchReqTable and this form does not have control under the name 'DimensionEntryControlTable'.
Try replacing it with 'LineDimensionEntryControl' as that's the control name for Financial Dimensions at line level
Issue: DimensionEntryControl dimControl = _sender.design().controlName(identifierStr(DimensionEntryControlTable)); Fix: DimensionEntryControl dimControl = _sender.design().controlName(identifierStr(LineDimensionEntryControl));
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,817
Most Valuable Professional
nmaenpaa
101,156