1

AX 2012 has introduced Delegates on classes. I've reviewed a bunch of documents on the web. All of them illustrate the usage on custom classes. They serve to illustrate the technology rather than real-life scenarios we have to deal with.

I'm looking for an example to capture changes in AX such add/change a worker, customer, vendor etc. to start with. I want to capture the information and pass it to a .net application. I'm having a hard time finding any examples.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
RT.
  • 435
  • 2
  • 9
  • 25

1 Answers1

0

See this answer for use of static event delegates to capture changes: Table Update Event Handler

Please be aware that events may be bypassed by using doUpdate etc. and by calling record.skipEvents(true).

Also consider using SQL Server feature Change Data Capture.

Community
  • 1
  • 1
Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • Jan, Thank you for your response. I don't want to use Change Data Capture as it is in the data repository layer. I would like to use Table Update Event Handler. However, I see a problem with it. If a field like first name changes, I would've to capture it in the pre- event for the field in dirPersonName table. Since dirPersonName is used for all names (customers, vendors, workers etc.), and if I'm interested in only name change for customers, is it possible to figure out whether the change occurred for a customer and not for a vendor or worker. – RT. Jun 10 '14 at 13:13
  • You would have to handle that in your preUpdate handler. You could check whether `CustTable::findByPartyRecId(dirPersonName.Person)` returns a customer. – Jan B. Kjeldsen Jun 10 '14 at 14:56
  • Jan, A couple of follow-up questions for you. 1. Does the pre-event have access to system generated values such as number sequence for an Insert operation? 2. If I perform some database updates in a pre-event, will they be rolled back if the operation (Insert, update, delete) fails? I'm planning to test these myself pretty soon. – RT. Jun 11 '14 at 14:25
  • 1. It will have access to the affected record and any field value whether assign through number sequence or not. 2. Yes, as the update operation is in a transaction. – Jan B. Kjeldsen Jun 11 '14 at 18:29
  • Jan, one more question: I'm inserting information into a custom AX table (SaveDataPerCompany = No) as and when inserts/updates/deletes happen. We have multiple legal entities and all of them will generate entries for the custom table. Everything is working fine up till this point and I've verified there are entries in the table. Now, I want the ability to show the data in the custom table in an AX form. I added the table as the data source for the form and dropped the fields on to a grid. However, none of the entries in the table are showing up in the form. Any idea why? – RT. Jun 11 '14 at 20:20
  • My extrasensory mind tells me you forgot to change the `DataSource` property of your grid. – Jan B. Kjeldsen Jun 11 '14 at 21:34
  • There is no datasource property for the grid, is there? When you drag and drop the columns from your datasources, the field gets the datasource_fieldName, right? I also set the CrossCompanyAutoQuery property on the datasource to Yes. – RT. Jun 12 '14 at 12:11
  • There is a datasource property on the grid control. – Jan B. Kjeldsen Jun 12 '14 at 15:52
  • Yes, there is. But it doesn't show if you add your grid before you add your datasource. I believe that is what happened in my case. Your extrasensory mind is working really well!!! Thank you for all your answers. – RT. Jun 13 '14 at 12:35