If you install a model or .xpo, it’s not enough to compile the imported objects – the code may break some other objects or they just need to be recompiled to work correctly. Therefore the recommended approach is to compile AOT and generate full IL every time you did such import. Again, that’s shouldn’t be the case if installing model store.
How to resolve the error while importing model store “The delete statement conflicted with the reference constraint “FK_ManifestHistoryHasCategoryId”. The conflict occured in databaes “db_name_model”, table “dbo.ModelOperationHistory”, column ‘categoryId’. The statement has been terminated..Microsoft.Dynamics.AX.Framework.Toolds.ModelManagement.PowerShell.ImportStoreCommand” in AX 2012.
Yesterday, I struggled a lot while importing model store which has thrown below error and stopped abruptly.
“The delete statement conflicted with the reference constraint “FK_ManifestHistoryHasCategoryId”. The conflict occured in databaes “db_name_model”, table “dbo.ModelOperationHistory”, column ‘categoryId’.
The statement has been terminated..Microsoft.Dynamics.AX.Framework.Toolds.ModelManagement.PowerShell.ImportStoreCommand”
when I started my R&D, I found different resolutions but best and less time consuming which I found is I am going to share now. I tried this and works magically.
Here you go and just follow these steps.
1. Create a temporary schema in the model store database.
2. Import the model store file into the temporary schema.
3. Apply the temporary schema.
Please have a glance on scripts which I executed in Management shell.
a) Create a temporary schema in the model store database and importing the file into it.
This example imports a model store to the Microsoft Dynamics AX database and associates it with a non-default schema (TemporarySchema). The new model store is not visible to Microsoft Dynamics AX until the imported model store has been applied to the default schema (dbo) by running Import-AXModelStore with the -Apply parameter. If you have AX instances more than 1, you need to supply -config parameter in script otherwise not needed. If you have conflicts then go with -IDConflict parameter either with overwrite or push, -Verbose parameter will show you objects conflicting in importing environment.
Import-AXModelStore -File “Path\filename.axmodelstore” -config: configname -schemaname TemporarySchema -Verbose -IDConflict Overwrite
b) Apply the temporary schema.
Import-AXModelStore -apply:TemporarySchema -config: configname.
Hope this helps you.
Till then Happy Daxing..
SRSReportDataProviderPreProcessTempDB Class in Ax 2012
Hi All,
I have something to share on SRSReportDataProviderPreProcessTempDB which is robust feature for the long running report in terms of execution which I copied from different sources.
Preprocessed data providers first prepare all data and only then they call SSRS. Normally the report itself asked for data when needed and if it takes too long, a timeout will kill the execution. Preprocessing data is there to avoid this problem.
Use TempDB with SrsReportDataProviderPreProcessTempDB. Regular tables were used in a previous solution and it caused some performance issues.
Report Data Provider.
An RDP class is a X++ class that is used to access and process data for a Reporting Services report. The options for a data source type for a Microsoft Dynamics AX report are the query, business logic, and RDP. An RDP class is an appropriate data source type when the following conditions are met.
- You cannot query directly for the data you want to render a report.
- The data to be processed and displayed is from Microsoft Dynamics AX.
Preprocessing reports
SSRS uses the WCF (Windows Communication Foundation) to connect to the AOS for data access. This connection has a threshold limit and it might fail if a report takes a long time to execute. The report server execution waits for the RDP to process the data and return it. In the event where the RDP takes too long a time to execute the reporting, the service might fail. Preprocessing is a strategy to beat this issue. This recipe will help you understand how to enable preprocessing for any RDP report
How to do it
When a report processes a huge amount of data or is found to take considerable time during the execution, then you can decide to incorporate preprocessing. Follow these steps to enable preprocessing.
- Modify RDP base class: SRSReportDataProviderBase -> SRSReportDataProviderPreProcessTempDB
- Update table type: InMemory -> TempDB
- Perform a full compile of IL
- Restart the AOS
- Introduce Controller class to run the report
- Update Output Menu Item: Report -> Controller class
These are pre-processing AX-SSRS reports. in these report user connection information is taken using method parmUserConnection(). Yes, this method sets the User Connection object on the temp table(s) that are used in the RDP class to return data. As per documentation , for pre-processing RDP reports, you must set the User Connection before the tables can be used. It is a best practice to set it in the beginning of processReport() method.
Thanks for reading…
Till then Happy DaXing…
Uploading a file to FTP server through X++ using batch processing…
Hi experts,
I came with one more stuff related to the uploading file to FTP server which is using batch processing, there is a lot of code change difference in file uploading to FTP server manually and using batch processing.
A class object must have RunOn property as “Server” and every time you make changes to an object, you must generate CIL.
if you would like to debug your code while it is running using batch processing, you need to debug from Visual studio and attach process to it.
Here is a sample class which uploads file to FTP server using batch processing
Sample file upload to FTP server using batch processing
Please feel free to comment your errors or suggestions or if you would like to know how to debug batch jobs using visual studio.
Thant’s it from my side, thank you
Happy Daxing…
Model, Model store, Importing, Compilation, IL generation and Upgrade scripts.
I prepared this post from different sources which would give you clear cut picture on Importing & Compilation objects and IL generation. So, let’s begin with Model and Model store.
What is Model?
A model is a set of elements in a given layer. Each layer consists of one or more models. Each layer contains one system-generated model that is specific to that layer. Every element in a layer belongs to only one model. In other words, no element can belong to two models in the same layer, and every element must belong to a model.
A default model owned by Microsoft exists in each layer. Default models cannot be modified.
A model is permanently associated with the layer that the model was created in. If you need to move one of your models from one layer to another, you must create a project from the model in the Application Object Tree (AOT), export the project as an xpo file, create a target model in the desired layer, delete the original model to avoid having to resolve layer conflicts, and import the xpo file to the target model. If you are moving elements between models in the same layer, you can use the Move to model command in the AOT.
What is Model Store?
Models are stored in the model store. The model store is a database in which all application elements for Microsoft Dynamics AX are stored. Customizations are also stored in the model store. The model store replaces the Application Object Data (AOD) files that were used in earlier versions of Microsoft Dynamics AX. Models that have been installed in the model store are used at run time.
Note: In Microsoft Dynamics AX 2012 R2, the model store was moved into a database that is separate from the business database.
Models can be exported to files that have the .axmodel extension. These files are called model files. Model files are deployment artifacts. Model files can be signed with strong name signing and Microsoft Authenticode signing.
Differences between Model, Model store and XPOs in tabular form.
In Microsoft Dynamics AX 2012, label files, or ALD files, are part of models. A label file must be added to a model before the model can be installed. After a model has been installed, ALD files are pulled from the model store to the local of Application Object Server (AOS) instance when the AOS is started. When the AOS is shut down, the ALD files are pushed back to the model store.
ALD files from earlier versions of Microsoft Dynamics AX are not part of a model file. However, you can import these files into the model store from the Label Files section of the AOT. Use the Create from file shortcut command.
Regarding XppIL folder, you have several options, but you need to understand what it contains. IL generation creates a single assembly, Dynamics.Ax.Application. It composes of a single DLL (Dynamics.Ax.Application.dll) and many modules, namely Enums.netmodule, InterfaceTypes.netmodule, KernelTypes.netmodule and one thousand modules with other AX types (Dynamics.Ax.Application.dll0.netmodule – Dynamics.Ax.Application.dll999.netmodule). Dynamics.Ax.Application.dll doesn’t contain any code, it only references the modules.
IL generations updates these modules, so one easy (but not completely reliable) approach is to check file sizes. For example, you may make a copy before generating IL and compare files by Powershell’s Compare-Object (e.g. Compare-Object (ls XppIL\*.netmodule) (ls XppILOld\*.netmodule) -Property Name, Length
).
When you identify changed (or otherwise interested) modules, you can disassemble them (ildasm.exe) and check the content or even dump IL and compare it.
After importing the ModelStore I understand i need to do a table synchronization but what upgrade scripts need to be run? I had a look at the different checklists in AX and none of them are specific to importing a model store.
If data upgrade scripts, it all depends on what changes in data model were done. If no data upgrade is needed, updating code (by importing model store) is enough. Otherwise, upgrade scripts should be delivered with the change – either by Microsoft, a third-party vendor or you, depending on who made the change. For example, imagine that you’re an ISV and you decided to move a field from Table1 to Table2. Without data upgrade script, your customers would get a new empty field in Table2 and lose their data in Table1’s field, therefore you have to prepare a script to move the data. Obviously, you don’t want to do such things often, so this type of changes is usually done only as part of major upgrades. But sometimes you simply have to introduce a breaking change, e.g. by adding a missing unique index (data upgrade script is needed to handle duplicated values).
It is technically right about using Compile forward, but the complexity tends to rise very quickly (if you have more than few objects), it doesn’t verify that everything is really compilable in the target environment and Compile forward depends on some license, so I recommend to simply make full compilation
Hope, you grasp this…:)
Till then, Happy Daxing…,
How to clear cache for AX 2012 R2 in Windows Server 2012
Hi Experts,
Hope you are cool. I would be focusing on clear cache for AX 2012 R2 in Windows Server 2012.
Please have a glance at the following steps listed below.
1. Close the client or Stop the AOS
2. Press Windows Key + R
3. Enter Command %userprofile% in Run and press enter
4. Unhide the system files
5. Locate the AppData folder
6. The ax_{GUID}.auc file is now written to the AppData folder
7. Delete the .auc file
8. Open the client or Start the AOS.
Note: Please take backup of *.auc and *.kti files before deleting.
Happy DaXing…
Missing labels while importing label file and if it gets created, error will display.
Hi Folks,
I have one post taken from Dynamics community which resolved issues related to label file importing. let’s have dig this question which is being posted by user.
Some labels are missed. I tried to import them using import option/label only. The labels are started with ABS, when I try to create a new label file with label file ID (ABS) the following error is faced “Cannot create the label file ID ABS. The label file ID already exists” but ABS label file does not appear in the AOT nor in the drop down list appears in the import screen (Create labels in the label file). Another label file is selected from this dropdown list (HCM) and the labels are created with label Ids starting with HCM so the labels are available with another Ids and so the labels’ texts do not appear ,how can we resolve this problem ?????
Answer for this question is as follows…
Label file ABS are present on the application folder.
Usually “C:\Program Files\…. \Server\XXXXX\bin\Application\Appl\Standard”
So :
1- Stop AOS
2- Delete files axABS*.ald, axABS*.alc and axABS*.ali
3- Start AOS
4- Create the Label file ID
4- Import the Label by XPO
Another way for import the label could be, after label file creation, import the ALD file directly from AOT.
So, from Label Files Aot node, right click and choose the option Create from File. You have to repeat for all languages.
Hope this answer your question.Thanks……..
Happy DaXing………
Expression to hide/unhide column and Text box in SSRS
Hi Axaptians,
This is second post on 5th Feb and eager to update regarding expressions used in SSRS reports to hide/unhide column or text boxes. In AX 5.0, reports are configured in Morphx but in AX 6.0, reports are being design in VS which is termed as SSRS reports. So, let’s begin this.
I would give an example where I would to like to hide a column or text box by using expression.
=iif(condition,True,false)
Above express will hide column depending on action applied. Suppose, if it is checked, will hide and if not, it will unhide. Following is the example below.
=iif(Parameters!BOMConsistOfDS_Item_Notes.Value = false,True,false)
or
=iif(Parameters!BOMConsistOfDS_Item_Notes.Value = false,1,0)
As simple as that, there are lot of things to be updated regarding expressions.
Please keep in touch for more updates.
Thanks & Happy DaXing…
How to find model of specific object through X++
Hi Experts,
Hope you are doing well.
I would just like to update you with new stuff which I have learnt recently. So, I will write a piece of code which returns model of specific object, in my case, I will use Class as object but you can use others objects as well. So, here you go.
static void jobGetObjectModel(Args _args)
{
SysDictClass sysDictClass = new SysDictClass(classNum(YourClass));
SysModel sysModel;
SysModelManifest sysModelManifest;
select Model, Name, Publisher, DisplayName from sysModelManifest
where sysModelManifest.Model == sysDictClass.treeNode().AOTGetModel()
join firstonly Layer from sysModel where sysModel.RecId == sysModelManifest.Model
&& sysModel.Layer == UtilEntryLevel::sys; // Change layer here
if (sysModelManifest)
info(strFmt(“Model: %1”, sysModelManifest.Name));
else
info(“Object is not apart of model in given layer”);
}
Query will fetch Model, its name, Publisher and DisplayName.
Note: Select layer in which you are looking for…
Thanks and Happy DaXing…
Importing data from an XML file
This is a part of previous post on reading and writing xml file from/to AX.
In Dynamics AX, XML file importing is done in a very similar way as exporting. In this recipe, we will continue using the System.XML wrapper application classes. We will create a new class which reads XML files and displays the content on screen. As a source file, we will use the previously created sales.xml file.
How to do it…
Carry out the following steps in order to complete this recipe:
1. Open the AOT, and create a new class named ReadorWriteXml with the following code.
Use the document created in the previous post:
class ReadorWriteXml
{
}
public void readXMLFile()
{
XmlDocument doc;
XmlNodeList data;
XmlElement nodeTable;
XmlElement nodeId;
XmlElement nodeName;
XmlElement nodeCustAccount;
#define.filename(@’C:\Temp\sales.xml’)
doc = XmlDocument::newFile(#filename);
data = doc.selectNodes(‘//’+tableStr(SalesTable));
nodeTable = data.nextNode();
while (nodeTable)
{
nodeId = nodeTable.selectSingleNode(fieldStr(SalesTable, SalesId));
nodeName = nodeTable.selectSingleNode(fieldStr(SalesTable, SalesName));
nodeCustAccount = nodeTable.selectSingleNode(fieldStr(SalesTable, CustAccount));
info(strFmt(“%1 – %2 – %3”,nodeId.text(),nodeName.text(),nodeCustAccount.text()));
nodeTable = data.nextNode();
}
}
public static void main(Args args)
{
ReadorWriteXml file = new ReadorWriteXml();
file.readXMLFile();
}
2. Run the class. The Infolog should display the contents of the sales.xml file on the screen:
How it works…
In this recipe, we first create a new XmlDocument. We create it from the file and hence we have to use its newFile() method. Then we get all the document nodes of the table as XmlNodeList. We also get its first element by calling the nextNode() method.
Next, we loop through all the list elements and do the following:
1. Get salesId node as an XmlElement.
2. Get salesname node as an XmlElement.
3. Get cust account as an XmlElement.
4. Display the text of nodes in the Infolog.
5. Get the next list element.
In this way, we retrieve the data from the XML file. A similar approach could be used to read any other XML file.
If you need xpo file of this, please specify your mail address in comment.
Hope you understood….
Till then, Happy DaXing…
Exporting data to an xml file
Hi Folks,
Today, I would like to emphasis on exporting data to an xml file in AX 2012.
Extensible Markup Language (XML) defines a set of rules for encoding documents electronically. It allows the creation of all kinds of structured documents to exchange between systems. In Dynamics AX, XML files are widely used across the application.
For example, user profiles can be exported as XML files. Business data, such as financial statements can also be exported as extensible Business Reporting Language (XBRL) files, which are based on XML.
Probably, the main thing that is associated with XML in Dynamics AX is the Application Integration Framework. It is an infrastructure that allows exposing business logic or exchanging data with other external systems. The communication is done by using XML formatted documents. By using the existing XML framework application classes prefixed with Axd, you can export or import data from or to the system in an XML format to be used for communicating with external systems. It is also possible to create new Axd classes using the AIF Document Service Wizard from the Tools menu to support the export and import of newly created tables.
Dynamics AX also contains a set of application classes prefixed with Xml, such as XmlDocument and XmlNode. Basically, those classes are wrappers around the System.XML namespace in the .NET framework.
In this recipe, we will create a new simple XML document by using the latter classes, in order to show the basics of XML. We will create the file with the data from the SalesTable table and will save it as an XML file.
Following are the steps…
Carry out the following steps in order to complete this recipe:
1. Open the AOT and create a new class named ReadorWriteXml with the following code:
class ReadorWriteXml
{
}
public void writeXMLFile()
{
XmlDocument doc;
XmlElement nodeXml;
XmlElement nodeTable;
XmlElement nodeId;
XmlElement nodeName;
XmlElement nodeCustAccount;
SalesTable salesTable;
#define.filename(@’C:\Temp\sales.xml’)
doc = XmlDocument::newBlank();
nodeXml = doc.createElement(‘xml’);
doc.appendChild(nodeXml);
while select RecId, SalesId,SalesName,CustAccount from SalesTable where salesTable.CustGroup == ‘AGENCY’
{
nodeTable = doc.createElement(tableStr(SalesTable));
nodeTable.setAttribute(fieldStr(SalesTable, RecId),int642str(salesTable.RecId));
nodeXml.appendChild(nodeTable);
//append salesId
nodeId = doc.createElement(fieldStr(SalesTable,SalesId));
nodeId.appendChild(doc.createTextNode(salesTable.SalesId));
nodeTable.appendChild(nodeId);
//append salesname
doc.createElement(fieldStr(salesTable,SalesName));
nodeName.appendChild(doc.createTextNode(salesTable.SalesName));
nodeTable.appendChild(nodeName);
//append custaccount
nodeCustAccount = doc.createElement(fieldStr(salesTable,CustAccount));
nodeCustAccount.appendChild(doc.createTextNode(salesTable.CustAccount));
nodeTable.appendChild(nodeCustAccount);
}
doc.save(#filename);
info(strFmt(‘file is created.’, #filename));
}
public static void main(Args args)
{
ReadorWriteXml file = new ReadorWriteXml();
file.writeXMLFile();
}
2. Run the class. The XML file sales.xml should be created in the specified folder.Open it using any XML editor or viewer, such as Microsoft Internet Explorer, and review the created XML structure:
How it works…
We start the recipe by creating a new XmlDocument using its newBlank() method,which represents an XML structure. Then we create its root node named xml using the createElement() method, and add the node to the document by calling the document’s appendChild() method.
Next, we go through the SalesTable and do the following for each record:
1. Create a new XmlElement node, which is named exactly as the table name, and add
this node to the root node.
2. Create a node representing the salesId field and its child node representing its value. The salesId node is created using createElement(), and its value is created using createTextNode(). The createTextNode() method basically adds a value as text with no XML tags.
3. Add salesId node to the table node.
4. Create a node representing the sales name field and its child node representing
its value.
5. Add salesname node to the table node.
6. Add Cust Account node to the table node.
Finally, we save the created XML document as a file.
In this way, we can create documents having virtually any structure.
My next post will highlight Importing data from xml.
If you need xpo file of this, please specify your mail address in comment.
Hope you understood….
Till then, Happy DaXing…