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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
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

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

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    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'.

  • ShivamKotwalia Profile Picture
    on at

    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.

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

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

    Please close the thread my verifying the answer.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Swathi,

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

  • 5400 Profile Picture
    7,162 on at

    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.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans