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 :
Finance | Project Operations, Human Resources, ...
Answered

Not Getting Data For Data Source

(0) ShareShare
ReportReport
Posted on by 100

I guess I'm having a moment. I have extended a table and added a field. I have extended a form, that uses the table as a datasource. When I do the following, in the form events, it gives me a null reference.

FormDataSource ds = sender.formRun().dataSource(formDataSourceStr(ProdParmRelease, ProdParmRelease));
ProdParmRelease prodParmRelease = ds.cursor();

Info(enum(prodParmRelease.PrintRouteCardV2));

I can see the new field when I do a table browse of the extended table. What the heck am I missing?

I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Moved to D365 Finance forum.

    First of all, you need to understand what exactly is giving you the null reference error. You shared three lines of code that do even more than three things. Which line does throw the error? And can you share your full event handler code?

    By the way, when sharing your code, please click "Use rich text formatting" -> Insert -> Code, so that it's easier to read.

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Also, is this PrintRouteCardV2 your new field? If yes, please remember that you need to use your own prefix when adding fields. Otherwise you will get issues if MS adds a field called PrintRouteCardV2.

    docs.microsoft.com/.../naming-guidelines-extensions

  • NoDozing2 Profile Picture
    100 on at

    Thanks for the advice. Here's the event code snippet:

        [FormDataSourceEventHandler(formDataSourceStr(ProdParmRelease, ProdParmRelease), FormDataSourceEventType::Activated)]
        public static void ProdParmRelease_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
        {
            FormDataSource  ds = sender.formRun().dataSource(formDataSourceStr(ProdParmRelease, ProdParmRelease));
            ProdParmRelease prodParmRelease = ds.cursor();
            FormRun         currentForm    = sender.formRun();
            SRSPrintDestinationSettings printJobSettings;
           Info(enum(prodParmRelease.PrintRouteCardV2));
            currentForm.design().controlName(formControlStr(ProdSetupRelease, SetupButtonPrintRouteCardV2)).enabled(prodParmRelease.PrintRouteCardV2);
            printJobSettings = new SRSPrintDestinationSettings(prodParmRelease.SetupPrintRouteCardV2);
            prodParmRelease.SetupPrintRouteCardV2 = printJobSettings.pack();
  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    First of all, your "sender" variable is already the correct form data source. So you don't need to do any tricks to get a handle to that data source.

    Second, what are you trying to do with the line that is marked with yellow? For me it doesn't even compile so I wonder how you are able to even run your code. If you want to print the enum value, try

     info(strFmt("%1", prodParmRelease.PrintRouteCardV2));

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans