Wednesday, November 16, 2011

Generate AxBCClass

To generate AxBCClass for one table, run class AxGenerateAxBCClass.

To generate data container class, run:

static void GenerateDataContainerClasses(Args _args)
{
AfDataContainerClassGenerator dataContainerClassGenerator;
str dataContainerType;
str dataContainerClassNameGenerated; // stores the generated data container name
str dataContainerClassName; // stores the actual data container class name
str dataContainerTypeMacroLibrary;
str ds1;
str axdClassName;
classId axdClassId;
;
ds1 = 'CustInvoiceTrans';
axdClassName = 'AxdSalesInvoice';
dataContainerClassName = 'SalesSalesInvoice_CustInvoiceTrans';
axdClassId = className2Id(axdClassName);
dataContainerType = AfDataContainerUtilities::getAxdDataContainerType(axdClassId, ds1);
dataContainerTypeMacroLibrary = AfDataContainerUtilities::getAxdDataContainerTypeMacroLibraryName(axdClassName);
dataContainerClassGenerator = new AfDataContainerClassGenerator();
dataContainerClassGenerator.parmClassName(dataContainerClassName);
dataContainerClassGenerator.parmDataContainerType(dataContainerType);
dataContainerClassGenerator.parmDataContainerTypeMacroLibName(dataContainerTypeMacroLibrary);
dataContainerClassGenerator.generate();
}

Friday, February 25, 2011

Export and import Dynamics Ax labels

static void ExportLabels(Args _args)
{
str module = "TUS";
str exportFile = "\\\\tsclient\\c\\fil1.txt";
Label l;
str s;
int i;
System.IO.TextWriter tw;
;
l = new Label();
i = 0;
tw = new System.IO.StreamWriter(exportFile);
while(i < 9999)
{
s = l.extractString("@" + module + int2str(i));
if(substr(s,1,1) != '@')
tw.WriteLine("@" + module + int2str(i) + ";" + s);
i++;
}
tw.Close();
}

static void ImportLabels(Args _args)
{
str module = "TUS";
str importFile = "\\\\tsclient\\c\\fil2.txt";
Label l;
str s;
System.IO.TextReader tw;
System.String ss;
str labelid, labeltext;
int i;
str existingLabel;
;
l = new Label();
tw = new System.IO.StreamReader(importFile);
ss = tw.ReadLine();
while(ss)
{
s = ss;
i = strScan(s, ";", 1, 10);
if(i > 0)
{
labelid = substr(s, 1, i - 1);
labeltext = substr(s,i + 1,strlen(s) - i + 1);

existingLabel = l.extractString(labelid);
if(substr(existingLabel,1,1) == '@')
{
l.insert(labeltext,"",module);
}
else
{
if(existingLabel != labeltext)
info("Existing label " + labelid + ", Old value = " + existingLabel + ", New value = " + labeltext);
}
}
ss = tw.ReadLine();
}
tw.Close();
}

Tuesday, January 4, 2011

Ax BizTalk adapter fails with registry access is not allowed

Details:"An unexpected failure occurred while processing a message. The following error has occurred: Requested registry access is not allowed.".

EventType clr20r3, P1 axaifremsrv.exe, P2 5.0.0.0, P3 4831b179, P4 mscorlib, P5 2.0.0.0, P6 4be9036a, P7 2d23, P8 79, P9 system.security.security, P10 NIL.

Skyldes manglende registry key: Microsoft Dynamics Ax 2009 adapter under HKLM...EventLog\Applications