Pages

April 29, 2013

Microsoft Dynamics AX 2012 development Cook Book

 Microsoft Dynamics AX 2012 development Cook Book

  • Paperback: 372 pages
  • Publisher: Packt Publishing (May 4, 2012)
  • Language: English
  • ISBN-10: 1849684642
  • ISBN-13: 978-1849684644

What you will learn from this book
  • Explore data manipulation concepts in Dynamics AX
  • Build scripts to assist data migration processes
  • Organize data in Dynamics AX forms
  • Enhance your application by using advanced form controls
  • Create custom lookups using AOT forms and dynamically generate them from the X++ code
  • Create and post Dynamics AX journals from code
  • Create and manage purchase and sales orders from code
  • Create a custom electronic payment format and process a vendor payment using it
  • Integrate your application with Microsoft Office Suite
  • Create various Microsoft Office documents that can be used for exporting/importing business data for further distribution or analysis
  • Integrate the system with external systems using various approaches
  • Improve your development efficiency and experience
  • Learn simple but effective tips on how to improve overall Dynamics AX performance
Click here to download this Ebook
TheAxapta Repository/AX2012DEvCookBook
-Harry

April 27, 2013

Official Dynamics AX 2012 R2 Content (update) - Where is it, and how can you find out about updates?

Official Dynamics AX 2012 R2 Content (update) - Where is it, and how can you find out about updates?

Hey friends,

I found a good link for Dynamics AX 2012 Resources/Library contents/MSDN links etc.
I am sharing this like for you all to let you know more about Ax World.
Thanks to Mr. KEES HERTOGH who post this valuable post for all of us.

Official Dynamics AX 2012 R2 Content (update) - Where is it, and how can you find out about updates?

Once again many thanks to Mr. Herthogh.
-Harry

How to install microsoft dynamics ax 2009 on windows 7

How to install microsoft dynamics ax 2009 on windows 7

Here is steps to install AX on Win-7 (non-server OS),

Dynamics AX Basic Installation:

  1. Make sure you are logged in through your domain account (domain\user) on your laptop, not local system account.
  2. You should have local admin rights on your laptop.
  3. Install SQL Server 2008 with SP1. Service account for this should be local system.
  4. Install AX 2009. You need to be connected to your domain while installing AX. Ignore warning that says this operating system is not supported. 
  5. AOS again should run under local system, instead of your domain account. Because this way you can use AX when you are out of your domain network.
    Hint: At the time of installation select Network service and after successful installation convert AOS service account to Local System.

  6. On the next screen, uncheck checkbox which says start AOS after installation.
  7. Click Install and you are done with the basic AX 2009 installation.
  8. To get it running with SQL Server 2008 SP1, you need AX 2009 SP1.
  9. Install AX 2009 SP1.
  10. Start AOS. (Optional: you may need to change the AOS service account to Local System).
  11. In AX, AdministratorSetupSecuritySystem service account, Set BC Proxy Account to your domain account (user , domain.com).
  12. Import Demo Data.

Dynamics AX Role Center & Enterprise Portal Installation:
  1. EP needs Sharepoint portal to be installed on your laptop. To install WSS / MOSS on your Windows 7 OS follow this link. http://theaxapta.blogspot.in/2013/03/installing-microsoft-sharepoint.html
  2. Once you have installed & configured Sharepoint, install Role center & Enterprise portal from the AX installation CD. It will run fine; I have checked it on my laptop.
  3. If you have Visual Studio 2008 installed, then you can also install enterprise portal development tools.
-Harry

April 24, 2013

Creating Vendors through X++ in AX 2012- PART II

Creating Vendors through X++ in AX 2012- PART II

Privious Post: 

--Create vendor and associate with vendor--

public void convertToVendor(VendorRequestCreate          _vendorRequestCreate)
{
    VendorRequestCreate                  vendorRequestCreate = VendorRequestCreate::find(_vendorRequestCreate.VendorNo,true);
    ;
if(_vendorRequestCreate.DirPartyType    == DirPartyBaseType::Person)
        vendTable.Party         = dirPerson.RecId;
else
        vendTable.Party         = dirOrganisation.RecId;
ttsBegin;
    vendTable.AccountNum    = NumberSeq::newGetNum(VendParameters::numRefVendAccount()).num();
ttsCommit;
if(vendTable.AccountNum == '')
        vendTable.AccountNum= int2str(_vendorRequestCreate.VendorNo);
    vendTable.Currency      = _vendorRequestCreate.CurrencyCode;
    vendTable.VendGroup     = _vendorRequestCreate.VendGroupId;
    vendTable.PaymTermId    = _vendorRequestCreate.PaymTermId;
    vendTable.DefaultDimension = _vendorRequestCreate.DefaultDimension;
    vendTable.OneTimeVendor = _vendorRequestCreate.OneTimeSupplier;
    vendTable.PaymMode      = _vendorRequestCreate.PaymMode;
    vendTable.BankAccount   = _vendorRequestCreate.BankAccount;
    vendTable.WI_Remarks    = _vendorRequestCreate.Remarks;
    vendTable.WI_DepartmentEmail = _vendorRequestCreate.DepartmentEmail;
    vendTable.insert();
    this.createPostalAddress(_vendorRequestCreate);
    this.createCommAddress(_vendorRequestCreate);
    this.createBankDetails(_vendorRequestCreate,vendTable.AccountNum);
    this.createContact(_vendorRequestCreate,vendTable.Party);
if(vendTable.RecId)
    {
        vendorRequestCreate.VendAccount = vendTable.AccountNum;
        vendorRequestCreate.update();
        info(strFmt('Vendor %1 has been successfully created',vendTable.AccountNum));
    }
}

-Harry

April 23, 2013

Compilation error in SysReportLibraryExport class

Compilation error in SysReportLibraryExport class

Recently I moved some code in live server and while compile the application I found that there was a compilation issue in the Class declaration of SysReportLibraryExport class but it seems to be fine with other environments.

clip_image001

I found that this issue is particular client based not on server. I done some R&D like…

1. I compiled this class on server  and it compiled fine. syntax error is gone and there are no more issues in it even though i have opened it on the application





2. Then I complied the same class on Client desktop, here its shows the error
      Compilation error in SysReportLibraryExport class

3. I again compile this class on another client on which reporting extension is installed 
(Reporting Extension require a SQL BD server for client), and it compiled fine here.

So the conclusion is  that this error in not show stopper for your application, you can use you environment.

-Harry



April 22, 2013

Configuration and Security Keys in Axapta

Configuration and Security Keys in Axapta

Security Keys
Microsoft Dynamics AX consists of a number of modules. For example, General Ledger, Project, and Administration. To make it easier for an administrator to set up security keys, they are organized the same way for all modules. Only nine security keys are allowed for each module in the Navigation Pane.
Security keys allow administrators to set security on a user group level. Minimizing access on a user group level helps to reduce the attack surface against potential attacks.
Applying Security Keys

The main reasons to apply user-level security are to:
  • Allow users to do only their designated tasks.
  • Protect sensitive data in the database.
  • Prevent users from inadvertently breaking an application by changing code or objects on which the application depends.
You need to apply a security key to:
  • Tables
  • Views
  • Menus
  • Menu items
  • Form controls
  • Report controls
To create security keys in Microsoft Dynamics AX:
  1. Expand the Data Dictionary node in the Application Object Tree (AOT).
  2. Right-click the Security Keys node, and then select New Security Key.
  3. Right-click the security key object, and then click Properties.
  4. Rename the security key by modifying the Name property.
  5. Right-click the object, and then click Create from the shortcut menu.
  6. Right-click the object, and then click Save from the shortcut menu.
  7. Right-click the object again, and then click Check In. This opens the Check in form.
Security Key Properties:

Property Rules
ID Always ship a security key with the same ID as it has been shipped with before.
If you try to create a new security key with an ID that has already been used for a security key in Microsoft Dynamics AX, an error will occur.
Name One of the nine security keys on a branch (the parent) should take the name of the module. For example, BOM. The other keys (up to eight more on a branch) should have the name of the module followed by one of the following suffixes: Daily, Journals, Inquiries, Reports, Periodic, Setup, Misc, or Tables. For example, BOMReports, BOMSetup, and LedgerPeriodic.
Enterprise Portal keys should have a prefix of EP followed by the name of the role. For example, EPAdmin and EPConsultant. Additional security keys for the role should take one of these suffixes: Misc, Info, Report, or Task. For example, EPAdminInfo and EPConsultantTask.
Application Integration Framework (AIF) keys should be the same as the name used for the service. The format is the module that the service is contained in, the document name, followed by Service. For example, in the Sales module, SalesSalesOrderService.
If you attempt to create a security key with a name that has already been used for a security key in Microsoft Dynamics AX, an error will occur.


Label Mandatory property.
AnalysisVisibility Mandatory property for top-level security keys (keys that have no parent key). 
Set to High for any key that corresponds to a core module in Microsoft Dynamics AX, for example, Ledger.
Set to Low for keys associated with tables that will not usually be used for reporting.
Set to None for keys associated with system functionality that should not be shown for end-user reporting.



Configuration Keys


Configuration keys should be defined so that the installation can be set up with only the features needed for each particular installation. By disabling configuration keys, administrators can reduce the potential surface of attack, thereby helping to increase the security of their Microsoft Dynamics AX installation.
Configuration keys allow administrators to enable or disable features in the application for all users. Disabling features helps to minimize the attack surface against potential attacks.
Applying Configuration Keys

Configuration keys are applied to:
  • Tables
  • Fields
  • Indexes
  • Views
  • Menus
  • Menu items
  • Form controls,
  • Report controls
  • Extended data types
  • Enumerations
Configuration keys are applied by setting the ConfigurationKey property on these objects in the Application Object Tree (AOT).
Creating Configuration Keys

To create a configuration key
  1. Expand the Data Dictionary node in the AOT.
  2. Right-click the Configuration Keys node, and then select New Configuration Key.
  3. Right-click the configuration key object, and then click Properties.
  4. Rename the configuration key by modifying the Name property.
  5. Right-click the object, and then click Create on the shortcut menu.
  6. Right-click the object, and then click Save on the shortcut menu.
  7. Right-click the object again, and then click Check In. This opens the Check in form.
configuration key Properties:

Property Rules
ID Always ship a configuration key with the same ID as it has been shipped with before.
If you attempt to create a new configuration key with an ID that has already been used for a configuration key in Microsoft Dynamics AX, an error will occur.
Name Follow the standard Naming Conventions.
If you attempt to create a configuration key with a name that has already been used for a configuration key in Microsoft Dynamics AX, an error will occur.
for complete Post plz follow below link

Configuration and Security Keys Best Practice Checks

-Harry

April 20, 2013

High Flying PM......

I could not stop my self to post this....... lol
Check out this 


High Flying PM

 A man is flying in a hot air balloon and realizes he is lost. He reduces height and spots a man down below. He lowers the balloon further and shouts:

"Excuse me, can you help me? I promised my friend. I would meet him half an hour ago, but I don't know where I am."

The man below says, "Yes, you are in a hot air balloon, hovering approximately 30 feet above this field. You are between 40 and 42 degrees North latitude, and between 58 and 60 degrees West longitude."



"You must be a programmer," says the balloonist.

"I am," replies the man. "How did you know?"

"Well," says the balloonist, "everything you have told me is technically correct, but I have no idea what to make of your information, and the fact is I am still lost."

The man below says, "You must be a project manager"

"I am," replies the balloonist, "but how did you know?"

"Well," says the man, "you don't know where you are or where you are going. You have made a promise which you have no idea how to keep, and you expect me to solve your problem. The fact is you are in the exact same position you were in before we met, but now it is somehow my fault."

-Harry

Sunday Fun Day............ Cheers ...........

Hi Friends;
Finally its Sunday tomorrow,  Awhhhhh rest is best this day.
Check these funny Lines for you and your buddies check it out........

Types of Project Managers; which one are you? -- 
    If you get in my way, I'll kill you! - ideal project manager
 
 
If you get in my way, you'll kill me! - somewhat less than ideal project manager 
    If I get in my way, I'll kill you! - somewhat misguided project manager 


    
If I get in your way, I'll kill you! - A tough project manager (eats glass, live cats, etc.) 
    If get kill in will way I you. - dyslexic, functionally illiterate project manager 

    
I am the way! Kill me if you can! - messianic project manager 
    Get away, I'll kill us all! - suicidal project manager 

    
If you kill me, I'll get in your way. - thoughtful but ineffective project manager 
    If I kill you I'll get in your way. - project manager who has trouble dealing with the obvious 
    
If a you gotta in my way, I gonna breaks you arm. - project manager from New York 

    

I am quite confident that there is nothing in the way, so no one will get killed. - project manager who is about to get in big trouble 

    

If you kill me, so what? If you get in my way, who cares? - weak, uninspired, lackluster project manager 

    
If I kill me, you'll get your way. - pragmatic project manager 
    If we get in each other's way, who will get killed? - An utterly confused manager
    Kill me, it's the only way. - every project manager to date.

-Harry.................... :)

X++ code for document attachment

X++ code for document attachment





In Axapta, we can attach document with Purchase order via document handling, if you need to attached a document using your x++ code, we need to use following x++ AOT objects.
  • DocuRef (table)
  • DocuActionArchive (class)
Here is a generic method that will attach record to any table in AX based on parameters passed to it

void attachDoc(RefTableId _refTableId, RefRecId _refRecId, selectableDataArea _refCompanyId, FileName _name)
{
    DocuRef docuRef;

    DocuActionArchive archive;
    ;
    docuRef.clear();
    docuRef.RefRecId = _refRecId;
    docuRef.RefTableId = _refTableId;
    docuRef.RefCompanyId = _refCompanyId;
    docuRef.Name = _name;
    docuRef.TypeId = 'File';
    docuRef.insert();
    archive = new DocuActionArchive();
    archive.add(docuRef, _name);
}

To use this method write following code to attache the document.

this.attachDoc(tableNum(PurchTable), purchTable.RecId, purchTable.dataAreaId, filepathname);

-Harry

April 19, 2013

Creating Vendors through X++ in AX 2012- PART I

Creating Vendors through X++ in AX 2012- PART I

--Create party for the vendor--

public void TheAxaptaCreateParty(VendorRequestCreate          _vendorRequestCreate)
{
    ;
if(_vendorRequestCreate.DirPartyType        == DirPartyBaseType::Person)
    {
        dirPerson.Name                          = _vendorRequestCreate.VendorName;
        dirPerson.NameAlias                     = _vendorRequestCreate.FirstName;
        dirPerson.NameSequence                  = dirNameSequence::find('First Last').RecId;
        dirPerson.insert();
        dirPersonName.FirstName                 = _vendorRequestCreate.FirstName;
        dirPersonName.MiddleName                = _vendorRequestCreate.MiddleName;
        dirPersonName.LastName                  = _vendorRequestCreate.LastName;
        dirPersonName.ValidFrom                 = DateTimeUtil::newDateTime(systemDateGet(),str2time ('00:00:00'),DateTimeUtil::getUserPreferredTimeZone());
        dirPersonName.ValidTo                   = DateTimeUtil::maxValue();
        dirPersonName.Person                    = dirPerson.RecId;
        dirPersonName.insert();
        dirParty                                = new DirParty(dirPerson);
    }
else
    {
        dirOrganisation.Name                    = _vendorRequestCreate.VendorName;
        dirOrganisation.NameAlias               = _vendorRequestCreate.FirstName;
        dirOrganisation.LanguageId              = 'EN-US';
        dirOrganisation.KnownAs                 = _vendorRequestCreate.VendorName;
        dirOrganisation.PhoneticName            = _vendorRequestCreate.VendorName;
        dirOrganisation.insert();
        dirParty                                = new DirParty(dirOrganisation);
    }
}


-Harry

April 18, 2013

Standalone Installers Of .NET Framework

Standalone Installers Of .NET Framework 4.5, 4.0, 3.5, 3.0 & 2.0 From Microsoft Download Center


Updated: May 6, 2017.

Hi All,
Here i am sharing some links to download all .net fromaworks (standalone installations) from microsoft download center.

.NET Framework 4.7
.NET Framework 4.6.2
.NET Framework 4.6.1
.NET Framework 4.5.2

.NET Framework 4.5 Setup
.NET Framework 4.0 Setup
.NET Framework 3.5 Setup
.NET Framework 3.5 Setup Service Pack 1
.NET Framework 3.0 Setup
.NET Framework 2.0 Setup
.NET Framework Client Profile Offline Installer
-Harry

Multi Tab Lookups in AX

Multi Tab Lookups in Dynamics AX

Its a tricky post, just go through it and try to develop yours.
For example you  have a requirement in which you want to show multiple tabs on a lookup form. You have a field in which you want your user to either select a customer or vendor from a lookup then this could be the best option to show multiple tabs and let user select either customer or vendor.

Following are the steps to get this done.

* Create a new form "TheaxaptaLookupForm" with multiple tabs on it ( same as other forms)
* Create a new EDT and The FormHelp property of the EDT should be set to the form you just created "
TheaxaptaLookupForm".


For reference you can chcek this form.
AOT\Forms\DimensionsLookup


-Harry

April 15, 2013

How to deploy all AX2012 report

Deploy all AX2012 report

We have 3 different ways to deploy Dynamics AX2012 reports:
  1. Through AOT
    AOT > SSRS Reports > Reports > right click on report > Deploy Element
  2. Through Visual Studio
    Open the report project > Right click on the project or solution node > Deploy
  3. Through PowerShell
    Publish-AXReport -ReportName *
Through AOT
- Go to AOT > SSRS Reports > Reports > right click > Deploy Element





Through Visual Studio
- Open your AX/Report project
- Right click on the project or solution node
- Click "Deploy"




Through PowerShell
- Go to: Start > Administrative Tools > Microsoft Dynamics AX 2012 Management Shell
- Then enter Publish-AXReport -ReportName *

For Complete post follow below link...

http://mybhat.blogspot.in/2011/10/how-to-deploy-all-ax2012-report.html.

-Harry

April 10, 2013

Container and unbounded string (text) fields are not allowed in a WHERE expression in AX.

Container and unbounded string (text) fields are not allowed in a WHERE expression in AX.

Error: Container and unbounded string (text) fields are not allowed in a WHERE expression in AX.

Reason: Axapta does not allow you to use an unbounded string in a where clause.

cont

Solution:

You must use a ‘bounded’ string. To do this you must declare your string with a numerical limiter e.g. str 50.


Example:

PurchTable getFirstByCustomerPOId(str 50 customerPOId)
{
PurchTable purchTable;
;
purchTable.selectForUpdate(true);
select firstonly purchTable
where purchTable.My_CustomerPurchaseOrderId == customerPOId;
return purchTable;
}


-Harry

April 08, 2013

Create a From through X++ Job

Hi,
Here is small code for create a AX From through X++ Job code.

static void theaxapta_formJob(Args _args)
{
    Form                    form;
    FormRun                 formRun;
    Args                    args;
    FormBuildDesign         formBuildDesign;
    FormBuildControl        formBuildControl;
    FormBuildTabControl     formBuildTabControl;
    FormBuildTabPageControl formBuildTabPageControl;
    FormBuildGridControl    formBuildGridControl;
    FormBuildDatasource     formBuildDatasource;
    FormBuildStringControl  formString;
    ;
    form = new Form();
    formBuildDatasource     = form.addDataSource(tableStr(PurchTable)); // Main Data Source for FORM
    formBuildDesign         = form.addDesign('design');// Add design in FORM
    formBuildTabControl     = formBuildDesign.addControl(FormControlType::Tab, 'Tab');
    formBuildDesign.height(1000);
    formBuildDesign.width(1000);
    formBuildTabPageControl = formBuildTabControl.addControl(FormControlType::TabPage, 'TabPage');
    formBuildTabControl.height(500);
    formBuildTabControl.width(500);

    formBuildGridControl    = formBuildTabPageControl.addControl(FormControlType::Grid, 'Grid');
    formBuildTabPageControl.height(500);
    formBuildTabPageControl.width(100);

    formString              = formBuildGridControl.addDataField(formBuildDatasource.id(), fieldNum(PurchTable, PurchId));
    formString.label("Purchase Order Form");

    args    = new Args();
    args.object(form);
    formRun = classFactory.formRunClass(args);
    formRun.init();
    formRun.run();
    formRun.wait();
}


-Harry

April 06, 2013

UTC DateTime Null Value in Ax

UTC DateTime Null Value in Ax

Some times we need to pass or check null value in UTCDateTime field.
so here is the logic to pass null value in UTCDateTime,

just try utcdatetimenull() function in your code, it will return the same value as 

DateTimeUtil::minValue() function.

In X++ The utcdatetimenull() value is '1900-01-01T00:00:00'.

-Harry

April 04, 2013

Finding unused lables

Finding unused labels in Axapta

Here is a small job for finding labels, from a particular label file, that are not used in your whole application code. You need an updated cross reference to use the job. I assumed that you are familiar with label files.


static void findUnXedLabels(SysOperationProgress _progress = null)
{
    Label     label       = new Label('da');// The languageto use for finding the labels
    str 250   labelId     = label.searchFirst('');
    Map       mapLabels   = new Map(types::String, types::String);
    MapEnumerator   mapEnumerator;
    ;

    setPrefix("Finding UnX'ed labels");

    while (labelId)
    {
        if (label.moduleId(labelId) == "XYZ") // The particular label file
        {
            if ((select xRefNames
                     index hint Name
                     where  xRefNames.Kind == xRefKind::Label &&
                            xRefNames.Name == labelId &&
                            xRefNames.TypeName == '').RecId == 0)
            {
                mapLabels.insert(labelId, label.extractString(labelId));
            }
        }
        labelId = label.searchNext();
    }

    // The maps is used to sort the lables
    mapEnumerator = mapLabels.getEnumerator();

    while (mapEnumerator.moveNext())
    {
        info (strFmt("%1 %2", mapEnumerator.currentKey(), mapEnumerator.currentValue()));
    }
}

In standard AX you can run this check for all labelfiles and save the result to a file, by using the \Classes\SysApplCheck\findUnXedLabels method.
-Harry

April 03, 2013

AX 2012 Developer Resources

AX 2012 Developer Resources

In this post i am sharing AX 2012 resources links, including development helps, Downloads, Articles  Blogs. All links are grouped by Topic
 

Events
Introduction
Eventing Basics (code walkthrough)
Managed Handlers for Pre/Post events (code walkthrough)
Managed Code Handlers for Delegates (limitations) (code walkthrough)
Microsoft Whitepaper: Eventing (download)
Eventing Terminology and Keywords (MSDN Article)
Naming Conventions for Delegates and Event Handlers (MSDN 

X++ Language
X++ as a Managed Language in the .NET Runtime (code walkthrough)
AX 2012 X++ Language Changes, Stricter Syntax (MSDN Article)
.NET Interop to X++ Issues when X++ runs as CIL (MSDN Blog)
Deploying AX 2012 Code
New Query Object Features (code walkthrough)
Creating Code Snippets and method templates (code walkthrough)


Data Access
Computed View Columns (code walkthrough)
Valid Time State/Date Effective Framework - Part 1: Creating the table (code walkthrough)
Valid Time State/Date Effective Framework - Part 2: Querying time state tables (code walkthrough)
Microsoft Whitepaper: Using Date Effective Patterns (download)


Debugging
Debugging X++ Running in CLR using Visual Studio (code walkthrough)



General Topics
Microsoft Guide: What's New for Developers (download) [fixed link - thanks to reader Waldemar Pross]
Microsoft Guide: New, Changed and Deprecated Features (download)
Microsoft Whitepaper: Deploying Customizations Across Environments (download)
Dynamics AX 2012 System Requirements (download)
Deploying AX 2012 Code
Importing Data Using the Excel Add-Ins



Reporting
Multiple instances of Reporting Services on the same machine (TechNet Article)
Microsoft Whitepaper: Report Programming Model for Dynamics AX 2012 (download)


SysOperation Framework
From RunBase to SysOperation: Business Operation Framework (code walkthrough)
From RunBase to SysOperation: Business Operation Framework (SysOperation query and customizing BOF dialog) (code walkthrough)
MSDN SysOperation Framework (MSDN Article)
SysOperation Framework Whitepaper (download)


UnitOfWork
Unit of Work Magic (code walkthrough)


Table Inheritance
Microsoft Whitepaper: Developing with Table Inheritance (download)


Model Architecture
Models and Layers Basics (code walkthrough)
Powerful Combination of Models and Events for No-Merge Code Solutions (code walkthrough)
Deploying AX 2012 Code


Managed Code
Using Visual Studio 2010 with AX 2012 (code walkthrough)
Writing and Calling Managed Code from AX (code walkthrough)
Limitations for Managed Code Event Handlers (code walkthrough)
Proxy Classes Gotcha (code walkthrough)
Creating Proxies for Kernel Classes (classes not visible in the AOT) (code walkthrough)
Microsoft Whitepaper: Selecting the Best Development Technology for Your Scenario (download)
X++ as a Managed Language in the .NET Runtime (code walkthrough)
.NET Assembly Deployment in AX 2012
.NET Interop to X++ Issues when X++ runs as CIL (MSDN Blog)


Services
From RunBase to SysOperation: Business Operation Framework (code walkthrough)
Using System Query Service in WPF (code walkthrough)
MSDN Business Operation Framework (MSDN Article)
Microsoft Whitepaper: Services (download)
Consuming External Webservices (code walkthrough)
Trusted Intermediary in AIF (code walkthrough)


Security
Trusted Intermediary in AIF (code walkthrough)
Microsoft Whitepaper: Developing Extensible Data Security Policies (download)
Microsoft Whitepaper: Using The Policy Framework (download)


Various
10-minute AX 2012 App: WPF (code walkthrough)
10-minute AX 2012 App: Windows Azure (code walkthrough)
10-minute AX 2012 App: Windows Phone 7 PART1 (code walkthrough)
10-minute AX 2012 App: Windows Phone 7 PART2 (code walkthrough)
10-minute AX 2012 App: Windows Phone 7 PART3 (code walkthrough)app.html


Foreign-Key Table Relationships
RecIds as Foreign Keys (code walkthrough)
Microsoft Whitepaper: Migrating EDT Relations (download)
-Harry

April 01, 2013

Get Current Company in AX

Get Current Company in AX

Below is the example on how to get current company in AX 2009.
In AOT > Jobs, paste the following code:


static void curExtExample(Args _arg)
{
    str curCompany;
    ;
    // Sets curCompany to the extension of the current company.
    curCompany= curExt();
    print "Current extension is " + curCompany;
    pause;
}

You can use this code in your forms and reports also to parameterized your reports/Forms.

-Harry

Get the latest exchange rates in Dynamics AX 2012 [Using X++]

Get the latest exchange rates in Dynamics AX 2012 Using X++

Below small snippet will help you to get the latest exchange rates as on today.
I am using x-rates URL to pull the exchange rates for this example. 
Note: Please check and verify this web URL before using it [free source or not].

image

static void SR_getExchangeRates(Args _args)
{
int curPos, endPos, startPos;
TextBuffer tb = new TextBuffer();
System.Net.WebRequest webRequest;
System.Net.WebResponse webResponse;
str page;
System.IO.StreamReader streamReader;
try
{
webRequest = System.Net.WebRequest::Create("http://www.x-rates.com/d/INR/table.html");
// this will throw an webexception if cannot be reached.
webResponse = webRequest.GetResponse();
streamReader = newSystem.IO.StreamReader(webResponse.GetResponseStream());
tb.setText(”);
page = streamReader.ReadToEnd();
streamReader.Close();
tb.setText(page);
curpos = 1;
startPos = 1;
tb.regularExpressions(false);
tb.find(‘<a href="/d/INR/USD/graph120.html" class="menu">’, curpos);
startpos = tb.matchPos();
tb.find(‘</a>&nbsp;</font></td>’, startpos);
endpos = tb.matchPos();
page = tb.subStr(startpos, endpos – startpos);
info(strFmt("1 USD = %1 INR",strreplace(page,‘<a href="/d/INR/USD/graph120.html" class="menu">’,”)));
// Close the webResonse
webResponse.Close();
}
catch(Exception::CLRError)
{
throw error(AifUtil::getClrErrorMessage());
}
}
Below is the output:

image

You can integrating the exchange rates in to the tablesExchangeRate , ExchangeRateType , ExchangeRateCurrencyPair

To get exchange rates for other currencies you may need to modify the URL  as shown below. [Change INR to EUR etc.]


image

Enjoy...........

-Harry