web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Disable Particular Financial Dimension (Department) which contains a predefined value

(0) ShareShare
ReportReport
Posted on by 52

Hi Everyone,

Greetings of the day.

I am performing the following task in Dynamics 365 F&O

Case: I am getting the financial dimension (Department only) from worker position to PurchReqLine level on PurchReqTable Form

Now, I want to disable that financial dimension (Department only) after getting value in it all other financial dimensions should be editable except department.

Note: Department value noting but the current users assigned department. Eg. If worker ABC has assigned department Finance so, Value & Description will come into Purchase Requisition Line.

I am trying the below code but it's not working.

[FormDataSourceEventHandler(formDataSourceStr(PurchReqTable, PurchReqLine), FormDataSourceEventType::Activated)]
public static void PurchReqLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
/*ormBuildControl _build;

PurchReqLine purchReqLine = sender.cursor();
// DimensionEntryControl dimensionEntryControl;// = new DimensionEntryControl(_build,sender.formRun());
LedgerDefaultDimensionEntryController ledgerDefaultDimensionEntryController = LedgerDefaultDimensionEntryController::construct();
//dimensionEntryControl.parmEditableDimensionSet(DimensionAttribute::findByName('Department').RecId);
ledgerDefaultDimensionEntryController.parmDimensionsToAllowEdit(purchReqLine.DefaultDimension);//DimensionAttribute::findByName('Department').RecId);//DimensionLinkAllowFieldEdit += eventhandler(BS_PurchReqTableFormEvtHandler::enableHandler);
*/
}

Also, there is a link of exactly the same scenario but in AX 2012. following is the link, The classes used in that link is not available in D365.

https://syedbaber.wordpress.com/2013/09/23/enabledisable-a-financial-dimension-segment-on-ax-form/

Thanks,

Paresh

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    RE: Disable Particular Financial Dimension (Department) which contains a predefined value

    Let me repost your code via Insert > Insert Code, to make it easier to read. Please always paste code in this way:

    [FormDataSourceEventHandler(formDataSourceStr(PurchReqTable, PurchReqLine), FormDataSourceEventType::Activated)]
    public static void PurchReqLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
    	FormBuildControl _build;
    
    	PurchReqLine purchReqLine = sender.cursor();
    	// DimensionEntryControl dimensionEntryControl;// = new DimensionEntryControl(_build,sender.formRun());
    	LedgerDefaultDimensionEntryController ledgerDefaultDimensionEntryController = LedgerDefaultDimensionEntryController::construct();
    	//dimensionEntryControl.parmEditableDimensionSet(DimensionAttribute::findByName('Department').RecId);
    	ledgerDefaultDimensionEntryController.parmDimensionsToAllowEdit(purchReqLine.DefaultDimension);
    	//DimensionAttribute::findByName('Department').RecId);
    	//DimensionLinkAllowFieldEdit  = eventhandler(BS_PurchReqTableFormEvtHandler::enableHandler);
    }

    Also, let's me throw away commented out code and unused variables. This is all what leaves there:

    [FormDataSourceEventHandler(formDataSourceStr(PurchReqTable, PurchReqLine), FormDataSourceEventType::Activated)]
    public static void PurchReqLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
    	PurchReqLine purchReqLine = sender.cursor();
    	LedgerDefaultDimensionEntryController ledgerDefaultDimensionEntryController = LedgerDefaultDimensionEntryController::construct();
    	ledgerDefaultDimensionEntryController.parmDimensionsToAllowEdit(purchReqLine.DefaultDimension);
    }

    Now I see what your code does. You create a new controller, which has nothing to do with the dimension control used in the form. Also, it's a local variable, which ceases to exist at the end of the method. Therefore your code doesn't have any effect at all.

    What you should do is modifying the existing control. I think the right approach would be calling LineDimensionEntryControl.parmEditableDimensionSet().

  • Paresh Bhagwatwar Profile Picture
    52 on at
    RE: Disable Particular Financial Dimension (Department) which contains a predefined value

    Hi Everyone,

    Good Afternoon.

    Instead of disabling the Financial Dimension "Department" I put a validation on purchReqLine level.

    Thanks,

  • Dodi Profile Picture
    73 on at
    RE: Disable Particular Financial Dimension (Department) which contains a predefined value

    Hallo, my case same like this post..

    but i want to disable main account..

    pastedimage1684149007803v1.png

    can you help me?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,122

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 918 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 646 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans