Creating DIEF Entities for DocuRef in Dynamics AX

by | Updated August 15, 2016 | Development, Dynamics AX

Since it is nearly impossible to generalize the DocuRef table entity in Dynamics AX, we need to create the code that will allow the data to be inserted into the table. The biggest issue is that we need to get a RefRecId and RefTableId.

Using Customer Notes for DocuRef in AX

For this example, we will be using Customer Notes, but you can see how this would work with any other entity that can connect to DocuRef.

The first thing we need to do is edit the existing customer entity staging table (DMFCustomerEntityTable). We need to add the field to the table for the Note value we want to put into DocuRef. Make sure the EDT type is set to Note so it will match up to the Note field on the DocuRef table. For each note you need to add, create another column into DMFCustomerEntityTable.

The second step is to create a method in the DMFCustomerEntityClass class. Here is where you are going to handle the insert/update from the staging table to the DocuRef table. You can either create one of these for every note you want to create/update per customer or you can handle it all in the one method.

public void generateNote(boolean _isUpdate)

{

DocuRef docuRef;

str note;

 

note = strLRTrim(entity.Note);

 

if (note != ”)

{

select forUpdate docuRef

where docuRef.RefRecId == target.RecId

&& docuRef.RefTableId == target.TableId

&& docuRef.Name == ‘Note Name’;

 

if (docuRef)

{

docuRef.Notes = note;

docuRef.update();

}

else

{

docuRef.clear();

docuRef.RefRecId = target.RecId;

docuRef.RefTableId = target.TableId;

docuRef.Name = ‘Note Name’;

docuRef.Notes = note;

docuRef.TypeId = ‘Note’;

docuRef.RefCompanyId = curext();

docuRef.insert();

}

}

}

 

The next method that we need to look at is on the same class. In the insertUpdate() method we need to add the call to our new method.

public Common insertUpdate(Common _target, boolean _callInsertLogic = false, boolean _callValidateLogic = false)

{

Common                             ret;

CustTable                           custTable;

boolean                             isUpdate;

 

if(target.RecId)

{

isUpdate = true;

}

 

ret = super(_target, _callInsertLogic, _callValidateLogic);

 

if (ret)

{

this.generateNote();

}

 

if (!this.parmIsCompare())

{

custTable = CustTable::find(entity.AccountNum);

if (custTable && (entity.AccountBalance != 0) && !isUpdate) //check for customer/Accountbalance existance

{

this.generateBalance();

}

}

return ret;

}

 

You can see that the call is after the super call, so the insert should already be run. This means we have a recID in target that will allow us to insert into DocuRef.

You can see that using this method, we can easily add comments for a number of other entities. Simply go to the Relations on the DocRef table to see where it is hooked up to.

Related Posts

  • Since the release of Microsoft Dynamics 365, there have been a lot of rumors around when Microsoft support for Dynamics AX 2009 and Dynamics AX 2012 will end. Microsoft Dynamics AX support…

  • Over on the AX Support site on MSDN, Daniel Durrer has taken the time to keep tabs on the latest builds for Microsoft Dynamics AX 4.0, 2009 and 2012.  I…

  • Dynamics AX supports the business case of a customer returning goods through the use of a return order. The blog post will start with a customer invoice, then show how…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events

june

02jun2:00 pm2:30 pmBusiness Intelligence for Batch Manufacturers

16jun10:00 am10:30 amHow AP automation can speed up month-end close in D365 Finance

17jun11:00 am12:00 pmConfab Live with Stoneridge – Real Time Marketing Strategies for Success

23jun10:00 am10:30 amThe Modern Manufacturer: Cost Accounting in D365

30jun10:00 am10:30 amAP Automation Checklist for a 2022 Rebound

30jun2:00 pm2:30 pmAchieving Success: How Technology Is Helping Nonprofits Thrive

july

01jul11:00 am12:00 pmConfab Live with Stoneridge – Dataverse Virtual Entities

14jul12:00 pm12:30 pmBeyond Reporting - What Business Intelligence Can Do For Your Agribusiness

15jul11:00 am12:00 pmConfab Live with Stoneridge – Integration Strategies for End User Success

21jul10:00 am10:30 amThe Modern Manufacturer: Manufacturing Software in the Real World

21jul12:00 pm1:00 pmIs it Worth it to Upgrade to Dynamics 365 Finance and Supply Chain Management? - Everything AX Users Need to Consider

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X