Quantcast
Channel: Dynamics AX
Viewing all 550 articles
Browse latest View live

Tutorial: Custom work types and shipment notes on the mobile device in Warehouse management module in Dynamics AX 2012 R3

$
0
0
Business case A customer requires that we upon request ship them HDMI cables packaged into special boxes that they have provided us with. The sales clerk taking the order over the phone puts in a Note whenever the goods need special packaging. The expectation is then, that the warehouse worker executing the picking will get notified of the customer requirement, so he can also pick up the special

Read XML file in AX 2009 / 2012

$
0
0

static void ReadXml_New(Args _args)
{
XmlDocument xmlDoc;
#define.node("Data\Invoice")
XmlElement xmlRoot;
XmlElement xmlField;
XmlElement xmlRecord;
XmlNodeList xmlRecordList;
XmlNodeList xmlFieldList;
XMLElement xmlEl;
XMLNode xmlNode;
//CustTable carTable;
//DictTable dTable = new DictTable(tablenum(CarTable));
int i, j, fieldId;
//#CarsXmlTags
;
// Create an XmlDocument object to hold the
// contents of the xml-file
xmlDoc = new XmlDocument();
// Load the content of the xml-file
// into the XmlDocument object
xmlDoc.load(@"c:\Users\abc\Desktop\myxmlInvoice.xml"); // @'C:\Users\abc\Desktop\Invoice.xml'

// permission.assert();
//doc = XMLDocument::newXml(xmlDoc); // this line is to take xml parse data as a parameter and creating new xml file in the code.

// Get the root node
xmlRoot = xmlDoc.getNamedElement("Data");

// Get all child nodes (records)
xmlRecordList = xmlRoot.childNodes();

// Loop through the list of records
for (i=0; i {
//carTable.clear();
// Get the current record from the
// record list
xmlNode = xmlRecordList.nextNode();
xmlRecord = xmlRecordList.item(i);
// Get all child nodes (fields)
xmlFieldList = xmlRecord.childNodes();
// Loop through the list of fields
for (j=0; j {
// Get the current field from the
// field list
xmlField = xmlFieldList.item(j);
// Set the matching field in the carTable
// to be equal to the inner text
// (the text between the tag and end tag).
info(xmlField.name());
//carTable.(dTable.fieldName2Id(xmlField.name())) =
info(xmlField.innerText());
}
// Insert the record into the carTable
//carTable.insert();
}
}

DAX 2012 toolset

Get default financial dimension values through X++ code

$
0
0

This topic is not new and we have lots of blogs available on it. Yasir Co-blogger also explained this quite well in his blog. The purpose to share this again here that I have did some minor modifications in his job to get both attributes (Value and Name) for Default dimension. Complete code is here.

static void GetDefaultDimensionAttributeName(Args _args)
{
    DimensionAttributeValueSetStorage    dimStorage;
    HcmPositionDefaultDimension          HcmPositionDefaultDimension;
    DimensionAttribute  DimensionAttribute;
    Counter                                               i;
    DimensionAttribute          dimAttr;
    DimensionAttributeValue     dimAttrValue;
    Common                      common;
    DictTable                   dictTable;
    str                         Name;
    str                         value;

    // get the dimension value from position    
    HcmPositionDefaultDimension = HcmPositionDefaultDimension::findByPositionLegalEntity(HcmPosition::findByPosition("000001").RecId,CompanyInfo::find().RecId);

    // make the dimension storage object    
    dimStorage = DimensionAttributeValueSetStorage::find(HcmPositionDefaultDimension.DefaultDimension);

    for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        // get attribute select here.
        select firstonly dimAttrValue
        where dimAttrValue.RecId == dimStorage.getValueByIndex(i)
        join dimAttr
            where dimAttr.RecId == dimAttrValue.DimensionAttribute;

        if (dimAttr && dimAttrValue)
        {
            dictTable = new DictTable(dimAttr.BackingEntityType);
            common = dictTable.makeRecord();

            if (common.TableId)
            {
                select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
                name = common.(dimAttr.NameAttribute);
                value = common.(dimAttr.ValueAttribute);
            }
        }
        info(dimAttr.Name +"----" +value + "----"+name);
    }
}

output image
i9

we can check the other examples on same topic from Yasir’s Blog – Microsoft Dynamics AX


Tutorial: Short pick goods on the mobile device in Warehouse management module of Microsoft Dynamics AX 2012 R3

$
0
0
Introduction In a typical warehouse things go out of sync from time to time. So the inventory on-hand information registered in the system becomes different from reality, or what is actually there physically. But warehouse operations need to keep being executed, and such discrepancies should not block orders from being picked. That's why in Warehouse management in AX 2012 R3 we provide a

How to pass the parameter when opening the MenuItem using X++ code AX 2009 / AX 2012

$
0
0
static void OpenDisplayMenuItem()
{
Args args = new Args();
;
args.record(VendTable::find("XYZ"));
new MenuFunction(MenuItemDisplayStr(VendTable),MenuItemType::Display).run(Args);
}

check the caller from in ax 2012

$
0
0
Public Static void main(Args _args)
{

if(_args.dataset() == tableNum(CustTable))
{
}

}

Using the .NET Business Connector to read/write data to Axapta in AX 2009


Opening Balance import through DIEF (Data Import Export Framework

$
0
0

Hi Guys and Happy Independence day to all my country mates and Happy Birth day to PAKISTAN

9

Okie, This exercise is about importing Opening Balance through DIEF (Data Import Export Framework, I am using Dynamics AX R3 CU8.

1 Create “Processing Group” – “Opening Balance”

7

2 Click Entities and select Entity as “Opening Balance”
3 Select Source data format as “Excel”
We need to create source data format record as this6

4 Click Generate Source file for generating the template, We can select all the needed fields here.

8

5 Click Modify Source Mapping,
Ops here I got the error

Error Message: Assembly containing type Microsoft.Dynamics.AX.Framework.Tools.DMF.ServiceProxy.DmfEntityProxy is not referenced.

Object ‘CLRObject’ could not be created

There can be multiple reason for this issue but I solved it through these steps.

Solution: Above mention error come because you are trying to set parameter without installing its component (Service, Server and Client). Just install those component from setup file and restart the AOS service. Now this error should not bother you this time. :)

After restarting the AX, I have open the parameter form, specified the correct shared working directory and validate the settings.

5

OK, NOW BACK TO MAIN TOPIC.

5 Click again on “Modify Source Mapping,”

As we need Journal Number to be Auto generated, I modify it by marking JournalNumber auto generated, and I also added the JournalName field in Query Criteria such that all the lines (with the same JournalName value) will be assigned the same JournalNumber

4

After this select the excel file with data in the ENTITIES form and click preview to viewing the data.

3

In the last for moving the data to staging table, click “Get staging data” then for copying the data to target, click on Copy data to target.

2

and here we have the end result

1

BIG THANK YOU AND HAPPY DAXING :)


My experience upgrading to Windows 10 in 25 mins

Troubleshooting Dynamics AX 2009 Enterprise Portal Unable to generate a temporary class

$
0
0
Recently, I bumped on this error while troubleshooting a webpart in AX 2009

Error

Server was unable to process request. ---> Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\vmeyu2da.0.cs' could not be found
error CS2008: No inputs specified


Solution:

Give the app pool iis account read/write permissions to c:\windows\temp folder

Azure VM Tip Cannot connect to VM after changes in cores and memory

Power BI for Desktop & Ax 2012

$
0
0


Power BI for desktop is a very powerful tool and can be used to mash up data from different sources. It is definitely one up to the Excel plugins and so far seems to be more lightweight and processes things faster
I will go through my findings with PowerBI and Ax to come up with some examples

Install PowerBI: Download PowerBI for Desktop and there its a usual click  install process. There are other versions available for every other device, which i will look at later. There is a detailed article on installing powerBI at c-sharpcorner.

Open up the the application and we shall create a report that looks like this

powerBI_AxSales_OverviewAX Sales over time / Region

So once we open up PowerBI, select “Get Data” and select SQL server database

powerBI_AxSales1 Select the data source

Enter the Database Server, if possible put the database name as well. Ax Databases being so large seems to slow down power BI.

Select the database server and database Select the database server and database

We will now select the Tables/Views from the list. You can use the search bar and select the checkbox. Select the following Tables/Views:

  • CustInvoiceJour
  • CustGroup
  • LogisticsPostalAddressView

After selecting the checkboxes, click the “EDIT” button in the pop up window. This will load the data preview and open the “Query Editor”

Edit Table Columns

Edit the following tables to trim the data being retrieved:

  1. LogisticsPostalAddressView
    1. Select the columns: City,CountryReqionID,RecId. Then right click and select “Remove other columns”
  2. CustGroup
    1. Select the columns: CustGroup,Name,DataAreaId. Then right click and select “Remove other columns”
    2. Add a computed field for identification. Click “Add Column” from the ribbon and then “Add custom column”. Set the new column name to CustGroupId and the formula as =[CUSTGROUP]&[DATAAREAID] Create CustGroupId field for identification Create CustGroupId field for identification

      Click Ok and this field will be added

  3. CustInvoiceJour
    1. Select fields: Custgroup, OrderAccount, InvoiceAccount, InvoiceDate, InvoiceAmountMST, SalesBalanceMST, SumTaxMST, InvoicePostalAddress, CreatedBy, DataAreaId, Partition, RecId. Right click and click “Remove Other columns”
    2. Create a new custom column “CustGroupId” similar to the one done for CustGroup Table
    3. Create a new custom column “InvoiceYear”. the

Once the above is done, Select “Close and load” button, located in the “home” ribbon bar

Relationships

So now that the tables have been defined, we need to set the relationships between them. Relationships in Power Bi, just like powerview in Excel, can only be linked via one field. Hence, why we added a computed column in the tables CustGroup and CustInvoiceJour

Click on “Manage relationships”

Delete any relationships in there (Currently there is one based off the custgroupId, but we shall delete it to make sure we add it all correctly)

  1. Relate CustInvoiceJour > CustGroup
    1. Add a new relation linking CustInvoiceJour to CustGroup using the CustGroupId on both Tables.

      Relation between CustInvoiceJour and Custgroup Relation between CustInvoiceJour and Custgroup

  2. Relate CustInvoiceJour > LogisticsPostalAddressView
    1. Add a new Relation and related CustInvoiceJour to LogisticsPostalAddressView using the InvoicepostalAddress to the RecId. See image for details

      Relation between CustInvoiceJour and LogisticsPostalAddressView Relation between CustInvoiceJour and LogisticsPostalAddressView

You should now have 2 relations setup. Close the Manage relations window and we will create our report

Creating the report

Bar Chart

in the field list at the right side of the screen, select the fields Name from the Custgroup table and then the InvoiceAmountMST field from the CustInvoiceJour Table. This will create a Table. Select the Bar chart option on the right side and it will change the view

Map

Click on a blank area in the report. From the field list select InvoiceAmountMST from the CustInvoiceJour Table and then CountryRegionId from the LogisticsPostalAddress. Then select the Map view

Sales by region over time

This will show how sales figures have been flowing by the countries
Click on a blank area in the report canvas. From the field list select InvoiceAmountMST and InvoiceYear from the CustInvoiceJournal. Make sure the InvoiceYear is on the X-Axis. Then select CountryRegionId from LogisticsPostalAddressView. Change the graph type to Line

Hoping to create more reports and make them available


Filed under: Ax 2012, BI Tagged: ax 2012, AX2012, BI, Business Intelligence, Dynamics Ax, PowerBI

Number Sequence auto-cleanup causing blocking

$
0
0

Recently a customer experienced a daily time timeout in their warehouse operations. It occurred around 10.30 every day and lasted for a few minutes. Meanwhile all warehouse operations were blocked. 

It turned out that the culprit was a number sequence configuration. One of the many features in the AX number sequence framework is to automatically clean up unused numbers for continuous number sequences.   This feature is great for number sequences that are infrequently used.  However, for the high volume number sequences this can cause blocking problems.

When generating a new number the auto-cleanup feature will test to see if it is time for clean-up, and if it is it will commence the clean-up right away –  – and the clean-up can take minutes.  Meanwhile SQL will hold locks prevent anyone from accessing the same number sequence.

Here is a setup of a number sequence that daily will run the auto clean-up, and potentially lock the system meanwhile.

clip_image001

And here is a job to detect similar issues in your installation:  

static void FindNumberSequencesCausingLocksDuringCleanup(Args _args)
{
    utcdatetime currentSystemTime = DateTimeUtil::getSystemDateTime();
    NumberSequenceTable ns;
    while select ns
        where ns.Continuous == true &&
              ns.CleanAtAccess == true &&
              ns.LatestCleanDateTime
    {
        if (DateTimeUtil::getDifference(currentSystemTime, ns.LatestCleanDateTime)
           
> ns.CleanInterval*3600)       
         {
            info(strFmt("Every %1 hour %2 will lock during cleanup, last time: %3",
                  ns.CleanInterval,
                 ns.NumberSequence,
                 ns.LatestCleanDateTime));
        }
    }
}

Options to consider:
  1. Does this number sequence need to be continuous at all?  Non-continuous number sequences are must faster, and do not require clean up!
  2. Is the automatic clean-up required to run automatically? It can also be run manually from the Number sequences form for example outside peak hours.

General Update

$
0
0
In case you hadn't noticed... I haven't posted in a while. For those of you who are connected to me in various ways, you have probably also noticed I had a job change and now work for Microsoft Dynamics AX R&D as a senior solution architect.

Essentially, in my new job I will be able to continue blogging and speaking at conferences. In fact, I will be at the AXUG Summit in October and speaking there. This blog will remain my personal blog and the open source projects will be maintained as well (more on that coming soon). Of course as a personal blog nothing I say or post here is backed up by Microsoft (see disclaimer at the bottom of the pages).

Currently we are hard at work on AX7 and I can't wait to start sharing and blogging about all the goodies for developers. But until then, it will probably be a bit quiet here (except for some planned improvements on the AX2012 build automation). Please connect with me on Twitter and stay in touch.

Woflow AX 2009 and AX 2012

$
0
0

Purchase order workflow -> enable and disable the posting buttons.

\Classes\PurchTableType\mayInvoiceBeUpdated

//For PO workflow begin
select firstonly workflowConfigurationTable
where workflowConfigurationTable.TemplateName == "PurchOrderApproval"
&& workflowConfigurationTable.Enabled == Noyes::Yes;

if(workflowConfigurationTable.RecId)
{
ok = ok && (purchTable.State == PurchReqWorkflowState::WorkflowCompleted);
}
//For PO workflow end

\Classes\PurchTableType\mayPurchaseOrderBeUpdated

//For PO workflow begin
select firstonly workflowConfigurationTable
where workflowConfigurationTable.TemplateName == "PurchOrderApproval"
&& workflowConfigurationTable.Enabled == Noyes::Yes;

if(workflowConfigurationTable.RecId)
{
ok = ok && (purchTable.State == PurchReqWorkflowState::WorkflowCompleted);
}
//For PO workflow end

Fix corrupt AX Install/Uninstall files using Microsoft Fixit

[AX2012] Get list of security roles with name

$
0
0

To get export the security roles along with the AOT name of the security will need you to either write something in X++ or go into SQL

I went the SQL route and this is my code:

select
S.AOTNAME, L.Text as AOTNAME, LD.Text as DESCRIPTION
from SECURITYROLE S
Left outer join ModelElementLabel L
on L.Module = SUBSTRING(S.Name, 2, 3)
and L.LabelId = SUBSTRING(S.Name, 5, 7)
and L.Language = 'en_us'
Left outer join ModelElementLabel LD
on LD.Module = SUBSTRING(S.DESCRIPTION, 2, 3)
and LD.LabelId = SUBSTRING(S.DESCRIPTION, 5, 10)
and LD.Language = 'en_us'

This will give a list of the AOT names and the Label name and Description


Filed under: SQL Tagged: AX2012, Dynamics Ax, SQL

Anti-Virus Exclusions for SQL Server, SSRS and Dynamics AX AOS Servers for improved performance

$
0
0
This post is about sharing my experience where I helped some clients to improve their overall application performance.
Quite often I have seen, we neglect the anti-virus softwares which run on our production boxes and scan application and data files, thereby leading to disk I/O and performance issues.
We need to add an exclusion list in our Anti-Virus software to exclude scanning files for SQL, SSRS and Dynamics AX 
A. SQL Server: 

The following paths needs to be excluded:
Sqlserv.exe C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Binn

Full Text Index Catalog C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\FTData
Data Files (.mdf/.ndf) D:\DATA (Path where SQL Database data files are located)

Log Files (.ldf) E:\Logs (Path where SQL Log files are located)

TempDB files F:\Tempdb (Path where tempdb files are located)
Backup Files (.bak, .trn) G:\Backup (Path where SQL Backup files are located)


B. SSRS Server :

ReportingServicesService.exe D:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin


C. Dynamics AX 2012 AOS Server :

Xppil folder C:\Program Files\Microsoft Dynamics AX\60\Server\AXPROD\bin\XppIL
Label files C:\Program Files\Microsoft Dynamics AX\60\Server\AXPROD\bin\Application\Appl

[AX2012] Fetching a Label value from SQL

$
0
0

Coming from my previous blog post Get list of security roles with name , I extracted the label via SQL. I had to break up the Label ID into the Module and then the number.
This allowed me to then query the table ModelElementLabel to get the label value

Following code can get the Label via SQL
NOTE: you need to query the Model database for this

DECLARE @LabelStr as nvarchar(50)
Set @LabelStr = N'@SYS12345'

select * from ModelElementLabel L
    where L.Module = SUBSTRING(@LabelStr, 2, 3)
          and L.LabelId = SUBSTRING(@LabelStr, 5, 7)
        --and L.Language = 'en_us' -- Uncomment this line to filter by language

This way you wont need to search a label value from within Ax


Filed under: Uncategorized
Viewing all 550 articles
Browse latest View live