Showing posts with label class. Show all posts
Showing posts with label class. Show all posts

Thursday, May 29, 2014

How to update cross-reference in batch

As you can see in AX 2012 updating cross references is not a batch job any more. But is worth setting it up to be run automatically during the night.

There is the article on MSDN describing this subject but without a batch, and if it looks too complicated for you, as for me, I would suggest another way found on AXForum (in Russian).

Once you started cross-reference updating from the client, you can easily find this job in Batch Job menu.





As we can see it is xRefUpdateIL class used for this goal, that in turn runs UpdateAll method.




So, it is possible to create your own job or batchable class to run, but we can just change the recurrence and set up other parameters, like alerts, for the ended batch job and change then its status to Waiting.



The same is true for partial reference update, say, for certain tables and classes of a project.



Happy cross-reference updating!


Friday, November 30, 2012

Generating Sales order confirmation in XML file in AX 2012

Let's say we need to provide one of our vendors with a Sales order confirmation in the form of XML file for the further consuming in their automated system. We suppose your license configuration is OK for that.

First of all, the appropriate service has to be set up in AIF module of AX 2012. (For the previous version, take a look at Microsoft Dynamics AX AIF: Sending Outbound Documents Automatically post) Given that we are going to export this information, we need to create a new outbound port.

Setting new Outbound port

Open the form of Outbound ports (System administration/Setup/Services and Application Integration Framework) to set up one: give it a name and short description to recognize it later among others.

Adapter should be File system adapter to generate XML file.
URI is the path where you can find generated XML files. Of course, AX has to have appropriate rights for this folder.



Now, we are choosing in the drop-list the appropriate service defined in AOT. For the most documents these services are already created; however, if you need to set up some specific or even new document service, please refer to the development manual.

The one we are looking for is SalesSalesConfirmationService. As you can see, all the document services are named in a very evident style: you always know for which document it serves.



Do not worry, if you cannot find this service in the list because it exists but needs to be registered from AOT  like follows.

Open Services branch in AOT tree, find this service in it, and register by the context menu item. You need to do it every time you add a new document service. Now this service appears in the list.



Read method will be enough for our job, so we activate our new port. Now we can proceed with the next step:

Adding a batch job maintaining AIF module

For my particular case, I am adding two tasks within it:

 - AifOutboundProcessingService responsible for outbound processing; and
 - AifGatewaySendService that will save XML files in the folder of URI, defined on the preceding step.



Note that you have to strictly follow the sequence so that a document will be pushed in the Message queue first and then a file will be created.


Do not forget to start the batch job with the right recurrence rules. You find more detail on how to deal with this batch job here.

Print management for clients

Finally, we change the print management for the client to whom we want to send XML files while updating Sales order confirmation.



Choose Print archive as a Destination to avoid the real printing and to generate an XML file.


Since now, when I confirm a sales order for this client I get after within one-two minutes an appropriate XML file in the folder.



For your environment, of course, you need to use your own parameters like those for the file folder or period of time for the batch job.

Also, it is possible to set up Sales order confirmation as a batch job, too.

Let me know if you have any troubles with this!

Tuesday, December 1, 2009

How to add all descendant classes to a new project

I bumped into the problem of a class compilation with no licence for X++ source code.

Forward compile option is not enough to make my changes working. Thus I need to export-import all descendant classes as well as the class I changed - FormLetter in my case.

I therefore have to add all these classes to my project. Natural laziness saved me again from this manual work.

I hope this short job inspired by system class SysCompilerOutput and miklenew's job from AXForum will help you in similar situations.






// add to a new project all descendant classes for forward compilation
public static void SISCreateCompileForwardProject(Args _args)
{
#AOT
str project = 'SIS_CompileForward';
SysCompilerOutput sysCompilerOutput;
Dictionary dictionary = new Dictionary();
DictClass dictClass = new DictClass(className2Id("Formletter"));
int numOfClasses = dictionary.classCnt();
ProjectNode sharedProjects;
ProjectNode newProject;

void addToProjectForwardClass(DictClass _dictClass, Dictionary _dictionary, int _numOfClasses)
{
ClassNode classNode;
DictClass dictClassLoop;
DictClass childClass;
int i;
;
if (_dictClass)
{
classNode = infolog.findNode(#ClassesPath + #AOTDelimiter + _dictClass.name());

if (classNode)
{
newProject.addUtilNode(UtilElementType::Class, classNode.name());

for (i=1; i <= _numOfClasses; i++)
{
dictClassLoop = _dictionary.classObject(_dictionary.classCnt2Id(i));

if (dictClassLoop.extend() == _dictClass.id())
{
childClass = new DictClass(dictClassLoop.id());
addToProjectForwardClass(childClass, _dictionary, _numOfClasses);
}
}
}
}
}
;

sharedProjects = infolog.projectRootNode().AOTfindChild('Shared');
sharedProjects.AOTAdd(project);
newProject = sharedProjects.AOTfindChild(project);
newProject.loadForInspection();
newProject = newProject.getRunNode();
addToProjectForwardClass(dictClass, dictionary, numOfClasses);
newProject.AOTsave();


}