ax 2012

how to create sales order by code with more then one lines ax 2012.

http://axaptapiyush.blogspot.in/2012/08/create-sales-order-in-ax-2012-using-x.html might help you.

We have some processes in ax which creates sales orders. One example could be creating a sales order from sales quotation when the quotation has been confirmed. You can take that logic as reference.

See

\Classes\SalesQuotationEditLinesForm_Sales_Confir\createSalesTable

\Classes\SalesQuotationEditLinesForm_Sales_Confir\createSalesLines

Hi Kranthi,

i write a job and i use “salesLine.createLine(true, true, true, true, true, true);” in my code…
when i am try to insert more then one line this code is not working…

plz help me…

why do you mean by that? Please explain.

i have to insert dimension by code in sales order…

can you show me your code?

static void Job3(Args _args)

{

SysExcelApplication application;

SysExcelWorkbooks workbooks;

SysExcelWorkbook workbook;

SysExcelWorksheets worksheets;

SysExcelWorksheet worksheet;

SysExcelCells cells;

COMVariantType type;

FileName filename;

SalesFormLetter formLetterObj;

NumberSeq numberSeq;

SalesTable salesTable;

SalesLine salesLine;

InventDim InventDim;

int row;

str _ItemId;

real _qty;

str _unit;

str _siteid

;

application = SysExcelApplication::construct();

workbooks = application.workbooks();

filename = “D:\New folder\Final.xlsx”;

try

{

workbooks.open(filename);

}

catch (Exception::Error)

{

throw error(“File cannot be opened.”);

}

workbook = workbooks.item(1);

worksheets = workbook.worksheets();

worksheet = worksheets.itemFromNum(1); //Here 3 is the worksheet Number

cells = worksheet.cells();

numberSeq = NumberSeq::newGetNum(SalesParameters::numRefSalesId());

numberSeq.used();

salesTable.SalesId = numberSeq.num();

salesTable.initValue();

salesTable.CustAccount = ‘1101’;

salesTable.initFromCustTable();

if (!salesTable.validateWrite())

{

throw Exception::Error;

}

salesTable.insert();

do

{

row++;

salesLine.clear();

_ItemId = cells.item(row,1).value().bStr();

_qty = any2int(cells.item(row, 2).value().toString());

_unit = cells.item(row, 3).value().bStr();

_siteid = cells.item(row, 2).value().bStr();

salesLine.SalesId = salesTable.SalesId;

salesLine.ItemId = _ItemId;

salesline.SalesQty = _qty;

salesline.SalesUnit = _unit;

InventDim.InventSiteId =_siteid;

salesLine.createLine(NoYes::Yes, NoYes::Yes, NoYes::Yes, NoYes::Yes, NoYes::No);

//salesLine.insert();

type = cells.item(row+1, 1).value().variantType();

}

while (type != COMVariantType::VT_EMPTY);

application.quit();

formLetterObj = SalesFormLetter::construct(DocumentStatus::Invoice);

formLetterObj.update(SalesTable::find(salesTable.SalesId));

info(strFmt(“Sales order ‘%1’ has been created”, salesTable.SalesId));

}

you have not used the inventDim buffer to get an inventDimId.

salesLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;

not working??

I did solve this issue already but i forget how to solved this. i took help from bemea.com. you can take help this resource, it could be helpful for you. hope your problem might be solved. [:)]

Hello kranthi

can u please give me the solution of this Problem.

What ever the dimensions you are setting are being overridden in createLine method

salesLine.createLine(NoYes::Yes, NoYes::Yes, NoYes::Yes, NoYes::Yes, NoYes::No);

The third parameter, is responsible to init the default dimensions from item. Try by setting it false.

Try to debug and see if you have any other issues.