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)

Set value in datasource field whe init the form

(0) ShareShare
ReportReport
Posted on by 383

Hello every one i need to set adefault value to the for when init it i'm trying to write this code prodParmReportFinished.Unit="50"; in init value method but not working8080.2.png

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    300,904 Super User 2025 Season 2 on at

    Hi Ahmed,

    Check if the unit field has a relation with the Units of measurement table. If so, check if the value '50' is setup. Can you also elaborate on the exact code used? Do you have compilation errors, runtime errors or is it just not working?

  • AhmedSaeed Profile Picture
    383 on at

    Hi André

    the field is a string field and there is  no relation the field name is just a description

  • AhmedSaeed Profile Picture
    383 on at

    6862.2.png here is the code

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    What do you mean by "not working"? Some error? Not the expected value? Something else? We don't like to guess :)

  • AhmedSaeed Profile Picture
    383 on at

    6646.2.pngi mean that the value didn't implemented (the field stile empty )

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Did you debug it? Does the initValue method get called? Does some other method (executed later) perhaps overwrite that value?

  • André Arnaud de Calavon Profile Picture
    300,904 Super User 2025 Season 2 on at

    Is "50" a unit of measure? Usually it is a quantity and unit of measure might be created like "box 50" if there needs to be a conversion from pieces to packed boxes.

  • Suggested answer
    Mark Boy2 Profile Picture
    506 on at

    Your should overwrite the write method  not initValue method

    public void write()

    {

       super();

       prodParmReportFinished.Unit="50"

    }

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Write method is called when the record is saved, so it can't be used to initialize default values. InitValue is used for the purpose.

    And if you set some value in write method after super(), it won't be even written to the table.

  • AhmedSaeed Profile Picture
    383 on at

    no it is not a measure it just a description it could be "N50"

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