Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

How to set Default value to one of the fields in form group control using X++

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

I am trying to customize 'Create new Customer record' form. Requirement is to set default values for some of the fields. One of the fields is part of field group from CustTable and is added as group control using X++. If it is a direct field, we can set as <FormFieldname>.value().

How can I set default value to one of the fields in the field group?

Appreciate any help on this.

*This post is locked for comments

  • 5400 Profile Picture
    5400 7,160 on at
    RE: How to set Default value to one of the fields in form group control using X++

    Don't hardcode any value for initializing. Please check how the value is coming from customer parameters from as default.

    If you are hardcoding any value, functional people cannot be change if required in near future, so it will bound to technical person. Please provide some setup in parameters UI from where you can default.

    Like sale order Type.

    Please check \Forms\SalesCreateOrder\Data Sources\SalesTable\Methods\initValue method how it is mapped.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set Default value to one of the fields in form group control using X++

    Hi Swathi,

    Put it under initvalue() method so as to be called when creating a new record.

  • Martin Dráb Profile Picture
    Martin Dráb 230,370 Most Valuable Professional on at
    RE: How to set Default value to one of the fields in form group control using X++

    initValue() of the datasource would be a better place.

    Please close the thread my verifying the answer.

  • RE: How to set Default value to one of the fields in form group control using X++

    Thanks Martin

    It worked .. one thing i wanted to mention was that if you want this to happen on opening of your form than place this code under the run method of your form and not on the init method of the form.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,370 Most Valuable Professional on at
    Re: How to set Default value to one of the fields in form group control using X++

    If a form control is bound to a table field, you should always work with the data source and not with the form control directly. It's not about the problem you have right now, but you can also have several controls for a single field and so on.

    The assignment is extremely simple - just use DatasourceName.FieldName, e.g. CustTable.DlvMode = 'ABC'.

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans