Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft Dynamics AX 2012 Development Cookbook

You're reading from   Microsoft Dynamics AX 2012 Development Cookbook Customizing Dynamics AX to suit the specific needs of an organization is plain sailing when you use this cookbook of modifications. With more than 80 practical recipes it's the perfect handbook for all Dynamics AX developers.

Arrow left icon
Product type Paperback
Published in May 2012
Publisher Packt
ISBN-13 9781849684644
Length 372 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Mindaugas Pocius Mindaugas Pocius
Author Profile Icon Mindaugas Pocius
Mindaugas Pocius
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Microsoft Dynamics AX 2012 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
1. Preface
1. Processing Data FREE CHAPTER 2. Working with Forms 3. Working with Data in Forms 4. Building Lookups 5. Processing Business Tasks 6. Integration with Microsoft Office 7. Using Services 8. Improving Development Efficiency 9. Improving Dynamics AX Performance

Adding a document handling note


It is good practice to add some kind of note to the record when doing data renaming, merging, or any other data manipulation task, whether it's manual or automatic. Dynamics AX allows adding a note or a file to any record by using the so-called Document handling feature.

By default, it is enabled for all tables, but can be restricted to fewer tables by changing its configuration parameters.

Document handling can be accessed from the form action pane by clicking on the Attachments button, choosing Document handling from the File | Command menu or selecting the Document handling icon from the status bar. Document handling allows adding text notes or files to any currently selected record.

Dynamics AX also allows adding document handling notes from the code too, which helps developers or consultants to add additional information when doing various data migration or conversion tasks.

In this recipe, we will add a note to a vendor account.

How to do it...

Carry out the following steps in order to complete this recipe:

  1. 1. Open Accounts payable | Common | Vendors | All vendors, and locate the vendor account that has to be updated:

  2. 2. Open the AOT, create a new job named VendAccountDocu, and enter the following code. Use the previously selected vendor account:

    static void VendAccountDocu(Args _args)
    {
    DocuRef docuRef;
    VendTable vendTable;
    vendTable = VendTable::find('3001');
    docuRef.RefCompanyId = vendTable.dataAreaId;
    docuRef.RefTableId = vendTable.TableId;
    docuRef.RefRecId = vendTable.RecId;
    docuRef.TypeId = 'Note';
    docuRef.Name = 'Imported';
    docuRef.Notes = 'This vendor was imported.';
    docuRef.insert();
    }
    
  3. 3. Run the job to create the note.

  4. 4. Click on the Attachments button in the form's action pane or select Document handling from the File | Command menu to view the note added by our code:

How it works...

All the document handling notes are stored in the DocuRef table, where the three fields RefCompanyId, RefTableId, and RefRecId are used to identify the parent record. In our recipe, we will set those fields to the vendor company ID, vendor table ID, and vendor account record ID, respectively.

Next, we will set note type, name, and description, and insert the document handling record. In this way, we will add a note to the record. The code in this recipe could also be added to a separate method for further reuse.

You have been reading a chapter from
Microsoft Dynamics AX 2012 Development Cookbook
Published in: May 2012
Publisher: Packt
ISBN-13: 9781849684644
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image