Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Using Oninitialized form datasource event handler .

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

hi,

i need to make some changes to the standard form in 

Cash and bank management > Inquiries and reports > Checks 

so i created an extension of the form and added the required fields. i need to perform some functionality as well but i am not able to do anything since the entire form is not editable. on checking the datasourse property i fount the allowedit(), allowcreate(), allowdelete() all were set to NO.

so i created created a class and pasted the Oninitialized form datasource event handler and wrote the below code.

but it doesn't seem to be working.

public static void BankChequeTable_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
BankChequeTable bankChequeTable ;
FormDataSource bankChequeTable_ds = sender.formRun().dataSource('BankChequeTable');
FormRun element = sender.formRun();
bankChequeTable_ds.allowEdit(true);
bankChequeTable_ds.allowCreate(true);
bankChequeTable_ds.allowDelete(true);

}

 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Using Oninitialized form datasource event handler .

    i tried doing both the methods you suggested. i wrote 2 oninitialized datasource event handlers since there are 2 datasources but that did not work.

    so i tried writing it on the form level oninitialized event handlers but that too dint work, this is the code:

    [FormEventHandler(formStr(BankChequeTable), FormEventType::Initialized)]

       public static void BankChequeTable_OnInitialized(xFormRun sender, FormEventArgs e)

       {

           FormDataSource bankChequeTable_ds   = sender.dataSource(formDataSourceStr(BankChequeTable, BankChequeTable ));

           FormDataSource reasonTableRef_ds    = sender.dataSource(formDataSourceStr(BankChequeTable, ReasonReferenceTable));

           reasonTableRef_ds.allowEdit(true);

           reasonTableRef_ds.allowCreate(true);

           reasonTableRef_ds.allowDelete(true);

           bankChequeTable_ds.allowEdit(true);

           bankChequeTable_ds.allowCreate(true);

           bankChequeTable_ds.allowDelete(true);

       }

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Using Oninitialized form datasource event handler .

    Or you can write your code on initialized of the form, after super of form's init() and enable both DS there. But it does not meter, try to enable both and see it will resolve your issue.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Using Oninitialized form datasource event handler .

    so then i need to copy the Oninitialized form datasource event handler for the second table and write the same code?

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Using Oninitialized form datasource event handler .

    This form has 2 DS, second one is disabled as well. They are joined with outer join, so try to allow create\delete\edit for second as well.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Using Oninitialized form datasource event handler .

    hi,

    yes i debugged the code. so first it hits the init method and the super in that method gets called. when super is executed, my code which i have written above gets executed. all the statements are getting executed but i still cant edit the form.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Using Oninitialized form datasource event handler .

    Hi Sanaa,

    Are you sure that your code is built properly and actually get executed? Did you try to debug it ?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans