Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Set field value from C/AL OnInit() Page event

(0) ShareShare
ReportReport
Posted on by

It has to be so easy.... but I cannot get it

I want to set the value of a field in a page from OnInit() event, but I can get it.

I have added the field "Gross Weight" in Sales Shipment Header (110), and I want it to be calculated (only if is 0) on page Posted Sales Shipment (130) event OnInit(). I know how calculate it, but I don't know how to assign the value to the field or control from the page.

Of course it will be better to set this value on the creation of the shipment, but for the moment I want to do it on the page.

Thanks

*This post is locked for comments

  • Suggested answer
    Ashwini Tripathi Profile Picture
    4,624 on at
    RE: Set field value from C/AL OnInit() Page event

    Dear Tomas, You should add your code in OnAftergetrecord as you may need to apply some filters before you can calculate the value. So once record is fetched you can apply your desired filters depending on current record and calculate your value. Depending upon your condition test you may simply assign your value. If you share your code we may suggest you in more better way.

  • Verified answer
    RockwithNav Profile Picture
    6,731 on at
    RE: Set field value from C/AL OnInit() Page event

    I believe the way you did is the best standard way of doing. 

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Set field value from C/AL OnInit() Page event

    Finally I have modified the codeunit Sales Post (80) and established the field Gross Weight in the process of converting a Sales Header into a Sales Shipment Header.

    Anyway, I will know how to set the value of a field/control in a page from C/AL. Any clue?

    Thanks

  • mmv Profile Picture
    11,467 on at
    RE: Set field value from C/AL OnInit() Page event

    OnAfterGetCurrRecord trigger is the right place based on your requirement.  OnInit will trigger only when you open the page.

    If you navigate through multiple records using the navigation buttons (Next, Previous), OnInit will not trigger.

  • Suggested answer
    Mohana Yadav Profile Picture
    60,228 Super User 2025 Season 1 on at
    RE: Set field value from C/AL OnInit() Page event

    can you show us the code what you have written.

    please use onaftergetcurrentrec trigger

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans