Sometimes we want to disable particular financial dimension for purchase requisition line or any other form. To achieve that we need to write code on OnInitialized event handler of the required form. please follow the steps to achieve this functionality.
- Go to desired form and make note of control that is used for financial dimension(in our case Purchtable form and DimensionEntryControlLine control name).
- Now go to desired form(Purchtable in our case) and select OnInitialized event handler as follows and paste it in your class.
- write following code in the event handler class and provide Name field value (dimension which should be disabled) as well as DimensionEntryControl name and build the project.
code :- - final output after disabling item financial dimension in our case.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | class PurchTableEventHandler { /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> [FormEventHandler(formStr(PurchTable), FormEventType::Initialized)] public static void PurchTable_OnInitialized(xFormRun sender, FormEventArgs e) { DimensionEntryControl dimControl = sender.design().controlName(identifierStr(DimensionEntryControlLine)); DimensionEnumeration dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger(); DimensionAttributeSetStorage dimensionAttributeSetStorage; DimensionAttribute dimensionAttribute; DimensionAttributeSetItem dimAttrSetItem; const str itemdimension = "item"; dimensionAttributeSetStorage = new DimensionAttributeSetStorage(); while select dimensionAttribute where dimensionAttribute.Name != itemdimension // 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()); } } |
I hope this blog was helpful to you. You can also find out more such blogs on home page and video demeonstration on my youtube channel
Comments
Post a Comment