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

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    can you show us the code what you have written.

    please use onaftergetcurrentrec trigger

  • mmv Profile Picture
    11,471 on at

    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.

  • Verified answer
    Community Member Profile Picture
    on at

    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

  • Suggested answer
    RockwithNav Profile Picture
    8,646 Super User 2025 Season 2 on at

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

  • Suggested answer
    Ashwini Tripathi Profile Picture
    4,624 on at

    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.

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 NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans