web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Suggested Answer

Using Oninitialized form datasource event handler .

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Community Member Profile Picture
    on at

    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
    60,286 on at

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

    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
    60,286 on at

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

    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
    60,286 on at

    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

News and Announcements

Season of Giving Solutions is Here!

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
TAHER Mehdi Profile Picture

TAHER Mehdi 3

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#2
Volodya Profile Picture

Volodya 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans