Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

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

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.

  • 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 228,552 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 228,552 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

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans