Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

how to add default main account in financial dimension on Service management model AX

Posted on by 10,270

please anybody tell me what class i use to add default main account value inside the form of service order AX 2012

*This post is locked for comments

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: how to add default main account in financial dimension on Service management model AX

    DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();

    DimensionAttribute      dimensionAttribute = dimensionAttribute::findByName("Main_Account");

    DimensionAttribute      dimensionAttributeProject = dimensionAttribute::findByName("Project");

    DimensionAttributeValue dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, "Your account number",false,true);

    DimensionAttributeValue dimensionAttributeValueProject = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttributeProject, "Your project",false,true);

    valueSetStorage.addItem(dimensionAttributeValue);

    valueSetStorage.addItem(dimensionAttributeProject );

    defaultDimension = valueSetStorage.save();

  • Codehunter Profile Picture
    Codehunter 10,270 on at
    RE: how to add default main account in financial dimension on Service management model AX

    i need to add both project and main account at the same time;how can i handle that??

  • Suggested answer
    Saju Kanakaraj Profile Picture
    Saju Kanakaraj 605 on at
    RE: how to add default main account in financial dimension on Service management model AX

    Can you paste your code here.

    Also explain what you are trying to do.

    Do you have project dimension in your active dimension list? If no, Ask functional to add project dimension. As per my understanding you need to initialize the dimension value when you create new record. I would suggest you to create new default dimension field in parameter form & assign the dimension value in init value of the datasource or table as below.

    void initvalue()

    {

    datasource.newdimension = ParametersTable::find().defaultdimension;

    }

    Please refer the link to add new dimension field in form.

    mukesh-ax.blogspot.in/.../how-add-financial-dimension-on-forms.html

  • Codehunter Profile Picture
    Codehunter 10,270 on at
    RE: how to add default main account in financial dimension on Service management model AX

    i need to add another dimension type of project ;is it possible??

  • Codehunter Profile Picture
    Codehunter 10,270 on at
    RE: how to add default main account in financial dimension on Service management model AX

    please help

  • Codehunter Profile Picture
    Codehunter 10,270 on at
    RE: how to add default main account in financial dimension on Service management model AX

    thanks but when i add this code ,i found that the project gets blank

  • Suggested answer
    Saju Kanakaraj Profile Picture
    Saju Kanakaraj 605 on at
    RE: how to add default main account in financial dimension on Service management model AX

    If the value should be defaulted when create new record, You can write it in two places.

    1. Form data source initvalue

    2. Table initvalue method.

    Still it is depends upon the criteria.

    If you want to default any value from the form arguments. Then it should be done at the form datasource level.

  • Codehunter Profile Picture
    Codehunter 10,270 on at
    RE: how to add default main account in financial dimension on Service management model AX

    where i should add this code?? is it in initvalue() of form data source

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: how to add default main account in financial dimension on Service management model AX

    Because it is not ledger Dimensions it is DefaultDimensions.  

    Here you go

    DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();
    
     DimensionAttribute      dimensionAttribute = dimensionAttribute::findByName("Main_Account");
     DimensionAttributeValue dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, "Your account number",false,true);
    
    valueSetStorage.addItem(dimensionAttributeValue);
    
    defaultDimension = valueSetStorage.save();  

    Using this code you can create new DefaultDimension.

  • Codehunter Profile Picture
    Codehunter 10,270 on at
    RE: how to add default main account in financial dimension on Service management model AX

    the highlighted line is blank as shown above which i add value in initvalue of SmaserviceOrderlineDS.please help.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,104 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans