How to post PO by Code in Dynamics AX

I have task to integrate Dynamics AX with another application by posting PO from out side Dynamics AX, so I used AIF and build new web service to be used from out of AX and call the method below to post PO (packing slip, or invoice) .
public str CreatePostProductReceipt(PurchId _PurchId, Num _PackingSlip, ItemId  Itemid, Qty qty,
InventSiteId  InventSiteId ='', InventLocationId  InventLocationId= '' , inventBatchid batchid = '', InventSerialId  serialId = '', inventsizeId inventsizeId ='', InventColorId InventColorId ='')
{
PurchFormLetter             purchFormLetter;
PurchParmUpdate             purchParmUpdate;
PurchParmTable              purchParmTable;
PurchParmLine               purchParmLine;
PurchTable                  purchTable;
PurchLine                   purchLine;
PurchId                     purchId;
Num                         packingSlipId;
InventDim                   inventDim;
str                 ret='';
System.Exception    err;
;
packingSlipId   = _PackingSlip;
purchTable      = PurchTable::find(_PurchId);
ttsBegin;
try
{
// Create PurchParamUpdate table
purchFormletter = PurchFormLetter::construct(DocumentStatus::PackingSlip); // to post invoice change to DocumentStatus::invoice
purchFormLetter.createParmUpdate(true);
purchParmUpdate = PurchFormLetter.purchParmUpdate();
// Set PurchParmTable table
purchParmTable.clear();
purchParmTable.TransDate                = SystemDateGet();
purchParmTable.Ordering                 = DocumentStatus::PackingSlip;
purchParmTable.ParmJobStatus            = ParmJobStatus::Waiting;
purchParmTable.Num                      = packingSlipId;
purchParmTable.PurchId                  = purchTable.PurchId;
purchParmTable.PurchName                = purchTable.PurchName;
purchParmTable.DeliveryName             = purchTable.DeliveryName;
purchParmTable.OrderAccount             = purchTable.OrderAccount;
purchParmTable.CurrencyCode             = purchTable.CurrencyCode;
purchParmTable.InvoiceAccount           = purchTable.InvoiceAccount;
purchParmTable.ParmId                   = purchParmUpdate.ParmId;
purchParmTable.insert();
// Set PurchParmLine table
while select purchLine
where purchLine.PurchId == purchTable.purchId && purchline.ItemId == Itemid
{
purchParmLine.InitFromPurchLine(purchLine);
inventDim = purchline.inventDim(true);
// Set batch and serial number
if(InventSiteId != '')
inventDim.InventSiteId = InventSiteId;
if(InventLocationId != '')
inventDim.InventLocationId = InventLocationId;
if(batchid != '')
inventDim.inventBatchId = batchId;
if(serialid != '')
inventDim.inventSerialId = serialID;
if(inventsizeId != '')
inventDim.inventsizeId = inventsizeId;
if(InventColorId != '')
inventDim.InventColorId = InventColorId;
purchParmLine.InventDimId = inventDim::findOrCreate(inventdim).inventDimId;
purchParmLine.ReceiveNow    = 1 ; //PurchLine.PurchQty;
purchParmLine.setInventReceiveNow();
purchParmLine.ParmId        = purchParmTable.ParmId;
purchParmLine.TableRefId    = purchParmTable.TableRefId;
purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);
purchParmLine.setLineAmount();
purchParmLine.insert();
}
ttsCommit;
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
purchFormLetter.transDate(systemDateGet());
purchFormLetter.proforma(false);
purchFormLetter.specQty(PurchUpdate::PackingSlip);
purchFormLetter.purchTable(purchTable);

// This is the ID we hard code as the product receipt ID, if we do the posting via UI
// user would have the option to manually enter this value
purchFormLetter.parmParmTableNum(purchParmTable.ParmId);
purchFormLetter.parmId(purchParmTable.ParmId);
purchFormLetter.purchParmUpdate(purchparmupdate);
purchFormLetter.run();
return "OK";
}
catch (Exception::CLRError)
{
err = CLRInterop::getLastException();
ret = err.ToString();
return ret;
}
Return "Error";
}

Cannot create a record in Purchase order header - Updating table (PurchParmSubTable)

Error message when you post a purchase order in Microsoft Dynamics AX 2009: "Cannot create a record in Purchase order header - Updating table (PurchParmSubTable)"
Problem
When you post a purchase order in Microsoft Dynamics AX 2009, you receive the following error message:
Cannot create a record in Purchase order header - Updating table (PurchParmSubTable).
This problem occurs if one of the following conditions is true:
You enable the "Life sciences electronic signature audit trail setup" setting for all tables.
You create a record for the Common table.
You set the PurchParmTable table in the database log.
This problem occurs when you post a purchase order, a receipts list, a packing slip, and an invoice.
This problem occurs in the following products:
Microsoft Dynamics AX 2009 with Service Pack 1
Microsoft Dynamics AX 2009
Click here to read the complete post

How to Call Report from Dynamics AX 2009

After you created your report in AX you can call report from  AX form by follow the below steps:

1- Create menu item with type output by drag and drop report to MenuItems nodes under AOT.

2- Open the form that you need to call report from.

                  Note: the form should be have dataSource with the table in report

3-  Drag and Drop menu Item created in step 1 in the form under any button group.

4- Add the following method to Report

void initFromCaller(Args _args)
{
    str                   QrderId; // field used as Rang and used to filter data
    QueryBuildDataSource  qbds; // should be represent report datasource and selected record in the form

    ;

    if (! _args ||
        ! _args.caller() ||
          _args.dataset() != tablenum(TableName) )
        return;

    QrderId = _args.record().(fieldnum(TableName,FieldName));

    qbds    =  element.query().dataSourceTable(tablenum(TableName));

    if(!qbds.findRange(fieldnum(TableName,FieldName)))
    {
        qbds.addRange(fieldnum(TableName,FieldName)) ;
    }
    qbds.findRange(fieldnum(TableName,FieldName)).value(queryvalue(QrderId));

}

Inventory closing slow

May The below link lead you to solve Dynamics ax closing slowness issue by creating new indexes in the main tables used in the recalculation and closing process in Dynamics ax.



Inventory Closing slow:





JOB OPPORTUNITY

An Egyptian Group is hiring:

1- AX 2012 R3 Functional Specialist (specially Logistics, Banking, and GL)

2- AX 2012 R3 Junior Developer (X++, MS Visual Studio 2010 or newer, SSRS, MorphX)

Requirements:

+1 years experience in AX 2012 Microsoft certified is a plus

** If interested, please send your CV to: m.anwar@raneen.com.eg

Your email subject should include the Job you are seeking.

Optimize AX 2013 R3 Virtual Machine Solution Demo On Laptop

while I was  searching about the best solution to run Dynamics AX 2012 R3 Virtual machine by Hyper V or Virtual box I found the link below, and think it will be useful for all.

http://daxetlbi.blogspot.com/2014/09/optimize-ax-2013-r3-virtual-machine.html

(Vacancies)contracts and permanent jobs

Good morning,
The market for Microsoft Dynamics is very busy at the moment and we have a number of contracts and permanent roles that might be of interest to you, please take a moment to have a look.
TPC 008
Dynamics NAV Developer – based in southern Denmark, solid NAV development skills essential 5000DKK per day
TPC 015
SSRS AND SSIS BI Developer in an AX environment – UK South Coast, must have proven commercial SSRS and SSIS experience, perm role up to £50k
TPC 016
Dynamics CRM PreSales Consultant – London – working with a successful tier 1 international Microsoft Partner, £100k package available for the right person
TPC 017
Dynamics CRM development consultant – Dynamics CRM development within the hedge fund industry, based in St James, London, immediate start £400 per day
TPC 018
Dynamics AX Consultant – Paris based AX Financial Consultant, within the retail / fashion industry, this is an upgrade for a platform with over 4000 users, must have experience of larger implementations. €750 per day
TPC 019
Dynamics AX Developer – Munich – For an aviation client must be able to work in Munich due to the nature of the project there is NO work offsite option €600 per day
TPC20
Dynamics AX PM – Manchester based Dynamics AX PM role within the insurance industry, working for an end user, but will also have oversight of the Microsoft partner staff, this is an AX2015 upgrade from an AX2009 install. £700 per day
If you are interested in any of these roles or are becoming available, please get in touch on CMerchant@templeton-recruitment.com
Have a great week

Object has not been initialized Erro in Ax 2012

When user open journal lines from GL ---> General journal  ---> Line

got below error

objectnotinitialized

 

Solution:

1- Delete *.auc files from user Machine

2- release Usage data under Tools –> option –> Usage Data ---> reset button

Troubleshooting Report Issues -AX 2012

All of us facing many issues while installing, deployment and customize AX 2012 reports. the Table below include most of troubleshooting of AX reports.

Source : https://technet.microsoft.com/en-us/library/gg731894.aspx

Issue

Additional information for troubleshooting

The report is broken for any reason and the data source is a query.

Execute the query outside of the report. Confirm that the query returns expected results. Use a form, job, or Query Services to test the query. For more information, see Query Service.

The report is broken and the data source is a report data provider (RDP) class.

Debug the class. For more information, see How to: Configure the Debugger to Debug a Report Data Provider Class.

When you preview the report you receive the following error:

No report data table with name <dataset table name> exists in report schema for data provider <RDP name>.

Verify that the report is bound to tables that exist and do not bind multiple datasets to a single report data provider class. Instead, define the report to have the multiple tables pointing to the same dataset.

No data was returned in the report.

Verify you have the right company, that there is data entered for that company, and that the user has access to the expected data.

The report has a rendering error. When you try to run the report, you receive an error like the following:

An error has occurred during report processing.

The SSRS Execution Account password could be invalid.

  1. From the Start menu, point to All Programs, click the Microsoft SQL Server folder, click the Configuration Tools folder, and then click Reporting Services Configuration Manager.
  2. In Reporting Services Configuration Manager, click Connect and then click Execution Account.
  3. Set the password and then click Apply. The account and password should be the same as the Microsoft Dynamics AX proxy account. For more information, see Before you install the Reporting Services extensions.
  4. Click the ServerName/MSSQLSERVER and then click Stop. Then click Start to restart the server. Always check with the SQL administrator and make sure no other users are connected to the server before you restart the server.

The report labels do not display, or the report shows label IDs, like Labels!@SYS24426 instead of the label values.

The SSRS Service Account password could be invalid.

  1. From the Start menu, point to All Programs, click the SQL Server folder, click the Configuration Tools folder, and then click Reporting Services Configuration Manager.
  2. In Reporting Services Configuration Manager click Connect and then click Service Account.
  3. Set the password and then click Apply. The account and password should be the same as the Microsoft Dynamics AX proxy account. For more information, see Before you install the Reporting Services extensions.
  4. Click the ServerName/MSSQLSERVER and then click Stop. Then click Start to restart the server. Always check with the SQL administrator and make sure no other users are connected to the server before you restart the server.

When running a report that uses an enumeration value as a multi-value parameter of a report, you get an error like the following:

The ‘ParameterName’ parameter is missing a value.

Set the Data Type property of the enumeration parameter to Integer.

This is because the label value of enumeration items are converted to name values in theSrsReportDataContractUIBuilder.getMultiSelectFromDialogField method.

When building a report project that uses a SQL report data source, you receive the following error:

The report does not have the mandatory framework parameter AX_ReportContext.

Manually create the AX_ReportContext report parameter. For more information, see Walkthrough: Creating a Report with Parameters.

Time values in a report bound to an AOT query are displayed as h:mm:ss tt in Visual Studio preview and the Microsoft Dynamics AX client instead of the actual time.

Select the field in the report design and set the following properties:

  • Expression property to=Microsoft.Dynamics.Framework.Reports.BuiltInMethods.ConvertAXTimeToDateTime(Fields!timefield.Value)
  • Format String property to hh:mm:ss

An AOS connection error message indicates you cannot establish a connection to the AOS.

To delete, rename, save, or restore a report model element, you must have a connection to the Application Object Server (AOS). If the AOS is disconnected or stops running after a reporting project is opened, an AOS connection error message will display. To continue, restart or restore the connection to the AOS, and then repeat the command that failed.

The Undo command is not functioning in the report model.

In Model Editor, only unsaved commands can be undone. Once a command is saved, it cannot be undone by using the Undo command. To revert a saved command, you must manually modify the report element. If you are using source code control, another option is to discard the file that is checked out if no other changes have been made.

The saved report model customization is not visible in Application Explorer.

Application Explorer does not automatically refresh as Model Editor saves changes to the model store database. To view changes in Application Explorer, right-click the model element, and then click Refresh.

The saved report model customization is not visible in the AOT.

The AOT does not automatically refresh as Model Editor saves changes in the model store database. To view changes in the AOT, in the Development Workspace Tools menu, click Development tools, Application objects, and then Refresh runtime model data.

When previewing a report in Visual Studio you receive the following error:

The %0 parameter is missing a value %1

Verify that you did not create a report with a Labels expression in the Values property of the report parameter. This is not supported because Reporting Services resolves parameter labels after the parameter evaluation and execution occur.

--or--

Verify that you did not set the Allow Blank property to True to make the parameter optional. This is not supported for dataset bound parameters by the reporting framework. The following items identify the alternative approaches for OLTP and OLAP reports:

  • OLTP reports – use an extended data type (EDT) to add a null-value string variable to the drop-down list as a default. When running the report, you can set the parameter value to NULL by not selecting anything from the drop-down list.
  • OLAP reports – add a value All to the drop-down list to indicate that no filtering is to be done by the parameter.

The query for the report was changed but the report does not reflect the change.

After you run the report, the query and ranges are cached in the SRSReportQuery table. To refresh the cache, you must manually delete all records in the SRSReportQuery table for any reports or report parameters that use the query that was changed.

   

Locking or hiding a range for a report parameter is not working. At runtime, the parameter is enabled and the user is able to filter on the range. This occurs when a report is bound to a query that has a range value with a Status property value of Locked or Hidden.

SQL Server Reporting Services does not honor the query range Status property.

The Label reference does not display properly. The Value property is set to theParameters!MyParm.Value parameter.

The parameter must be explicitly bound to data using a dataset in the Visual Studio Tools for Microsoft Dynamics AX report model.

The parameter is explicitly bound to datasets with two columns, label and value. The value displays properly. The Label reference displays properly everywhere except in the client.

The report viewer control does not support the ability to specify report parameter labels, only values.

When you build a Visual Basic project for a report, the project does not build.

-or-

You receive the error “The business logic assembly ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null does not contain a class for report Report1.”

You must clear out the namespace setting of the Visual Basic project. In Solution Explorer, right-click the project, and then clickProperties. In the Application area, delete the text in the Root namespace field.

In Visual Studio, you build a project and receive the error, “System.InvalidOperationException: Object is currently in use elsewhere.”

This error indicates a synchronization issue. Close the solution and then rebuild the report.

When you debug a C# data method, the SQL Server Reporting Services server crashes.

This is a known issue if you are debugging a C# data method on a machine that is running a 64 bit operating system. To work around this issue, open Visual Studio 2008, load the C# file, set the break point, and then attach to the Reporting Services process. For more information, see Debugging Managed Code in Microsoft Dynamics AX.

Reports that run for more than ten minutes time out. For example:

  • If you are previewing a report in Visual Studio and a timeout occurs, you will receive the following error:

Timeout error occured when calling AOS service. Use Dynamics AX Client Configuration Utility to change WCF configuration values. Exception details: The request channel timed out while waiting for a reply after 00:00:59.9449945. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

  • If a user is trying to view a report in the Microsoft Dynamics AX client and a timeout occurs, the user will receive the following error in the InfoLog:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

See Tips to help prevent long-running reports from timing out.

Errors are generated when reports are saved to a file, printed to a printer, or emailed.

View the detailed error messages that are recorded for the Reporting module in the Exceptions form. Click System administration > Periodic > Services and Application Integration Framework > Exceptions.

The same report contains different information when saved to different file formats.

For example, a sales invoice report that is saved to an .HTML file may contain header information, line items, and totals. When the same report is saved to an .XML file, it may contain only the line items and totals.

This is by design. For more information about how reports are rendered in the available file formats, see Exporting Reports (Report Builder 3.0 and SSRS) in the SQL Server documentation.

Users receive the following error when clicking on a drill-through link on a report in Enterprise Portal:

[CompanyName] is not a valid company. Check the value and try again.

This situation may occur when Reporting Services 2008 or Reporting Services 2008 R2 is running in SharePoint integrated mode. To resolve this issue, install Reporting Services 2008 R2 with Service Pack 2.

clip_image001Note

SharePoint integrated mode is supported if you are using Microsoft Dynamics AX 2012 R2 or later.

Tables are not aligned correctly when viewing reports in right-to-left (RTL) languages.

This is a known issue with the Reporting Services tablix control. For more information about the issue, see Known Issue: Dynamic Precision designs spacing issues in RTL languages in the Microsoft Dynamics AX Business Intelligence blog.

The Reporting Services extensions become unusable when additional Reporting Services instances are installed on the same computer. As a result:

  • Reports cannot be deployed.
  • Reports cannot be displayed.

To resolve this issue, configure all the Reporting Services instances on the computer. For more information about how to install and configure multiple instances of Reporting Services on the same computer, see Install multiple instances of Reporting Services on the same computer (for use with Microsoft Dynamics AX).

When printing a report that has been saved as a PDF file, the printer page size does not correspond to the PDF page size.

To resolve this issue, select the Choose paper source by PDF page size check box in the Print window that is displayed when printing the report to the printer.

When using an environment that includes a hardware load balancer, such as F5, reports that run for more than five minutes time out.

To resolve this issue, adjust the timeout period specified in the hardware load balancer. For example, if you are using F5, set theIdle Timeout field to 7200 seconds or higher. For more information, see the F5 Knowledge Base.

You need to adjust the alignment of a report.

For tips on adjusting the alignment, see this blog post: SSRS report tips to adjust alignment for pre-formatted print stock (i.e. 1099-MISC form).

Running AX report through batch job in AX2009 (batch printing)

Running batch report in AX2009 (batch printing)

Since the change of AX2009 batch framework, printing of report through batch can be done through two methods:
- Printing from server (to printer or file)
- Printing from client (the legacy batch processing)
Prerequisites: For both of the method, there're some mandatory setup:

  1. Enable any of the AOS that you want to make it as batch AOS
    (Administration -> Setup -> Server configuration)
  2. Create batch group for printing.
    Eg. One for client printing and one for server printing.
    (Administration -> Setup -> Batch groups)
  3. Add the batch group created in #2 into the AOS enabled for batch processing (in #1)

complete article available here

Dynamics AX Workflow types - AX 2012

To create a workflow, you must first select the type of workflow that you want to create. This topic lists the types of workflows that you can create in each module. The topic also describes what each type of workflow is used for, and whether the workflows of each type are associated with a specific company in the organization or with the whole organization.

https://technet.microsoft.com/en-us/library/dd362043.aspx

Data Import/Export Framework error

Troubleshoot issue with a Data Import/Export Framework installation from cumulative update 7 for Microsoft Dynamics AX 2012 R2

After you install cumulative update 7 for Microsoft Dynamics AX 2012 R2, the Data Import/Export Framework appears to be installed, but you receive error messages when many forms are opened like the following:

You receive an “Assembly containing type Microsoft.Dynamics.AX.DMF.ServiceProxy.DmfEntityProxy is not referenced.” error

Reason: When you install cumulative update 7 for Microsoft Dynamics AX 2012 R2, the Data Import/Export Framework appears to be installed for members of the System Administrators role. However, the binary components of the framework are not present.
Solution:

please click here to get solution

Regular maintenance activities in Dynamics AX that affect performance

The following list describes some of the maintenance activities that we recommend that you perform regularly in your production environment:
  • Defragment indexes – You can defragment indexes from either SQL Server Management Studio or the Intelligent Data Management Framework (IDMF).

  • Update SQL Server statistics from SQL Server Management Studio – We recommend that you run both manual and automatic updates of statistics. Manual updates may become more important as the size of your database increases, because automatic updates are less likely to be completed on large data sets.

  • Reduce the size of the database – You can use IDMF to keep the size of the production database small. A small database makes database operations more efficient. For example, you can delete or archive data that is not required in your production system.

Troubleshoot an installation of the Data Import/Export Framework from InformationSource

This post describes how to troubleshoot issues with a Data Import/Export Framework installation from InformationSource.

The Data Import/Export Framework does not compile

After you install the Data Import/Export Framework, if you cannot compile, validate that the Data Import/Export Framework was installed correctly.

  1. Verify that the Microsoft Dynamics AX Data Import/Export Framework service is running.

  2. Verify that the Data Import/Export Framework DLLs are present in C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin folder:

    • Microsoft.Dynamics.AX.DMF.Mapper.dll

    • Microsoft.Dynamics.AX.DMF.PreviewGrid.

    • Microsoft.Dynamics.AX.DMF.ServiceProxy.dll

    • DMFConfig.xml

    • Microsoft.Dynamics.AX.DMF.DriverHelper.dll

Resolution

Copy the DLLs from the installation location (C:\Program Files\Microsoft Dynamics AX 2012 Data Import Export Framework Client Component) to the C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin folder.

Exception message while you use Data Import/Export Framework

While you use the Data Import/Export Framework, you might receive the following error message:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException

Verify that the following files are present in the C:\Program Files (x86)\Microsoft Dynamics AX\60\Server\Bin folder on the server that is running the AOS instance:

  • DMFConfig.xml

  • DMFClientConfig.xml

  • Microsoft.Dynamics.AX.DMF.ServiceProxy.dll.config

Resolution

Copy the .xml and the config files from the installation location (C:\Program Files\Microsoft Dynamics AX 2012 Data Import Export Framework Server Component) to the C:\Program Files (x86)\Microsoft Dynamics AX\60\Server\Bin folder on the server that is running the AOS instance.

Changes to the location of the Data Import/Export Framework service

If you have to update the location where you run Integration Services and the Data Import/Export Framework service, you can update the endpoint address in the Microsoft.Dynamics.AX.DMF.ServiceProxy.dll.config file to use the new server name.

<endpoint address="http://<<NEW MACHINE NAME>>:7000/DMFService/DMFServiceHelper.svc"

NoteNote

The Microsoft.Dynamics.AX.DMF.ServiceProxy.dll.config file is located in the C:\Program Files (x86)\Microsoft Dynamics AX\60\Server\Bin folder on the server that is running the AOS instance.