Tuesday, November 30, 2010

Which Report Template does the Auto Report Uses?

The Ax will use "FrontPage" report template for Auto Report.

Thursday, November 25, 2010

Download Project Time Management for AX 2009

Here is the link for downloading the Project Time Management for Microsoft Dynamics AX 2009 from partner source.

https://mbs.microsoft.com/partnersource/support/selfsupport/productreleases/ax2009projecttime.htm?printpage=false

Monday, November 22, 2010

Changing Production Order Status to started

Here is a simple code which changes the production order status to started.
If your production module is setup-ed to post the PickingListJournal
automatically when the production is started - the code help you to post
even the picking list journal automatically.

prodTable = ProdTable::find("PRD_00000588");////pass your prodId
prodTable.autoUpdate(ProdStatus::StartedUp);

you cannot extend this to other status like ReportAsFinished and Ended

Saturday, November 20, 2010

Using DictClass

The below code is used to print number of methods in a Class ans even their names.

The same code can be extended to all other objects like DictTable class for tables,
dictEnum class for enums etc...

static void dictClass(Args _args)
{
int noOfMethods,i;
DictClass dictClass = new DictClass(ClassNum(InventMovement));
/// InventMovement is the Class
;

noOfMethods = dictClass.objectMethodCnt();
for(i = 1 ; i <= noOfMethods ; i++)
{
info(strfmt("%1. InvemntMovment - %2",i,dictClass.objectMethod(i)));
}
pause;
}


By using DictClass you can also print the number of Static methods and their names.

static void dictClassStatic(Args _args)
{
int noOfMethods,i;
DictClass dictClass = new DictClass(ClassNum(InventMovement));
;
noOfMethods = dictClass.staticMethodCnt();
for(i = 1 ; i <= noOfMethods ; i++)
{
info(strfmt("%1. InvemntMovment - %2",i,dictClass.staticMethod(i)));
}
pause;
}

Wednesday, November 17, 2010

To create sales order from text file by using AxSalesTable and AxSalesLine Classes.


static void loadCSVFileSalesOrder(Args _args)
{
Dialog dialog;
DialogField dialogFileName;
SysOperationProgress simpleProgress;
Filename filename;
FileIOPermission permission;
TextIO textIO;
NumberSeq numSeq;
InventTable inventTable;
str s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12;
Real r1,r2,r3,r4,r5,r6;
int i1,i2,i3,i4,i5,i6,i;
Container c1,c2;
Container filterCriteria;
AxSalesLine axSalesLine = new axSalesLine();
AxSalesTable axsalesTable = new axSalesTable();
#File
#avifiles
;
dialog = new Dialog("Importing Text File");
dialogFileName = dialog.addField(typeid(Filenameopen), "File Name");
filterCriteria = ['*.txt'];
filterCriteria = dialog.filenameLookupFilter(filterCriteria);
dialog.run();

if (dialog.run())
filename = dialogFileName.value();

if(!filename)
{
info("Filename must be filled");
throw("");
}

permission = new fileIOpermission(filename,#io_read);
permission.assert();
textIO = new TextIO(filename,#io_read);
textIO.inFieldDelimiter(';');///Change the Delimeter if it is , or ; etc

simpleProgress = SysOperationProgress::newGeneral(#aviUpdate, 'Importing sales data',100);

if(textIO)
{
while(textIO.status() == IO_Status::Ok)
{
c1 = textIO.read();
s11 = conpeek(c1,1);
if(strlen(s11) > 1)///checks for the customer account
{
axsalesTable.parmSalesId();
axsalesTable.parmCustAccount(Conpeek(c1,1));// Cust Account
axsalesTable.save();

axSalesLine.parmSalesId(axsalesTable.parmSalesId());
axSalesLine.parmItemId(Conpeek(c1,2));//ItemId
axSalesLine.axInventDim().parmInventSiteId(Conpeek(c1,3));//// InventSiteId
axSalesLine.axInventDim().parmInventLocationId(Conpeek(c1,4));//// InventLocationId
axSalesLine.parmSalesQty(conpeek(c1,5));//Sales Quantity
axSalesline.parmSalesPrice(conpeek(c1,6));//Sales Price
axSalesLine.save();

i++;
simpleProgress.incCount();
simpleprogress.setText(strfmt("Lines imported: %1", i));
info(strfmt("Sales Order : %1 has been created",axsalesTable.parmSalesId()));
sleep(10);
}

}
}
}

Importing data from text file in Axapta

The code will help you to import data from text file and create a sales order.


static void loadCSVFile(Args _args)
{
Dialog dialog;
DialogField dialogFileName;
SysOperationProgress simpleProgress;
Filename filename;
FileIOPermission permission;
TextIO textIO;
NumberSeq numSeq;
InventTable inventTable;
str s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12;
Real r1,r2,r3,r4,r5,r6;
int i1,i2,i3,i4,i5,i6,i;
Addressing a1,a2,a3;
TransDate d1,d2,d3;
salesTable salesTable,salesTable1,salesTable2;
salesLine salesLine,salesLine1,salesLine2,salesLine3,salesLine4;
InventDim inventDim,inventDim1,inventDim2;
Container c1,c2;
CompanyInfo companyInfoLoc = CompanyInfo::find();
Container filterCriteria;
#File
#avifiles
;
dialog = new Dialog("Importing Text File");
dialogFileName = dialog.addField(typeid(Filenameopen), "File Name");
filterCriteria = ['*.txt'];
filterCriteria = dialog.filenameLookupFilter(filterCriteria);
dialog.run();

if (dialog.run())
filename = dialogFileName.value();

if(!filename)
{
info("Filename must be filled");
throw("");
}

permission = new fileIOpermission(filename,#io_read);
permission.assert();
textIO = new TextIO(filename,#io_read);
textIO.inFieldDelimiter(';');///Change the Delimeter if it is , or ; etc

simpleProgress = SysOperationProgress::newGeneral(#aviUpdate, 'Importing sales data',100);

if(textIO)
{
while(textIO.status() == IO_Status::Ok)
{
c1 = textIO.read();
s11 = conpeek(c1,2);
if(strlen(s11) > 1)
{

numSeq = numberSeq::newGetNum(SalesParameters::numRefSalesId());
salesTable.SalesId = numSeq.num();///SalesId
salesTable.initValue();
salestable.CustAccount = Conpeek(c1,1);// Cust Account
salesTable.InvoiceAccount = Conpeek(c1,1);//Cust Account
salestable.SalesId = salestable.SalesId;
salesTable.initFromCustTable();
salestable.ShippingDateRequested = systemdateget();
salesTable.ShippingDateConfirmed = systemdateget();
salesTable.insert();

salesLine.SalesId = salesTable.SalesId;
salesLine.initFromSalesTable(SalesTable);
salesLine.initValue();
salesLine.ItemId = Conpeek(c1,2);//ItemId
inventTable=salesLine.inventTable();
salesLine.initFromInventTable(inventTable);
inventDim1.InventSiteId = Conpeek(c1,3);//// InventSiteId
inventDim1.InventLocationId = Conpeek(c1,4);//// InventLocationId
salesLine.inventDimId = InventDim::findOrCreate(inventDim1).inventDimId;
salesLine.initFromCustTable();
salesLine.SalesQty = conpeek(c1,5);//Sales Quantity
salesLine.QtyOrdered = conpeek(c1,5);// Sales Quantity
salesLine.SalesPrice = conpeek(c1,6);//Sales Price
salesLine.LineAmount = salesLine.SalesPrice * salesLine.SalesQty;//Sales Amount
salesLine.AssessableValue_IN = salesLine.LineAmount;
salesLine.Address_IN = companyInfoLoc.Address;
salesLine.ExciseType_IN = companyInfoLoc.ExciseType_IN;
salesLine.TIN_IN = companyInfoLoc.TIN_IN;
salesLine.ECCNumber_IN = companyInfoLoc.ECCNumber_IN;
salesLine.IECNumber_IN = companyInfoLoc.IECNumber_IN;
salesLine.STCNumber_IN = companyInfoLoc.STCNumber_IN;
salesLine.SalesTaxRegistrationNumber_IN = companyInfoLoc.SalesTaxRegistrationNumber_IN;
salesLine.TAN_IN = companyInfoLoc.TAN_IN;
salesLine.State_IN = companyInfoLoc.State;
salesLine.RemainSalesPhysical = salesLine.SalesQty;
salesLine.RemainSalesFinancial = 0;
salesLine.RemainInventPhysical = salesLine.QtyOrdered;
salesLine.LineNum = SalesLine::lastLineNum(salesLine.SalesId) + 1.0;
salesLine.insert();
i++;
simpleProgress.incCount();
simpleprogress.setText(strfmt("Lines imported: %1", i));
info(strfmt("Sales Order : %1 has been created",salesTable.SalesId));
sleep(10);
}

}
}
}

Tuesday, November 16, 2010

To print comments related to workflow

This code helps you to print the comments related to a workflow.

static void printWorkFlowComments(Args _args)
{
SmmLeadTable smmLeadTable;
WorkFlowTrackingTable workFlowTrackingTable;
WorkflowTrackingCommentTable workflowTrackingCommentTable;
;
smmLeadTable.RecId = 5637145827;////smmLeadTable buffer //// Change the table where the workflow is enabled.

while select workFlowTrackingTable order by RecId asc where workFlowTrackingTable.ContextRecId == smmLeadTable.RecId
{
select firstonly workflowTrackingCommentTable where workflowTrackingCommentTable.TrackingId == workFlowTrackingTable.TrackingId;
if(workflowTrackingCommentTable)
{
print workflowTrackingCommentTable.Comment;
print workflowTrackingCommentTable.TrackingMessage;
}
}
pause;
}