Showing posts with label salesorder. Show all posts
Showing posts with label salesorder. Show all posts

21 Jul 2015

Increment Linenum field + AX 2012


 Step::1 Drag LineNum EDT to the fields node of your table.




Step::2  Create an index on your table and drag the LineNum field to this index


Step::3 While defining the datasource on your form,
  1. Set Table to your table
  2. Set Index to the index you created which contains the LineNum field
  3. Set CounterField to LineNum

Step::4 Override the create() method on your form’s datasource and set the default value of append parameter to be False.




That's it....now you can check Output.

28 Mar 2013

How to create sales order through X++

creating sales order in a book and I was able to compile a code for posting sales order invoice. I thought I should share on my blog. It might be useful for some one.

Code for creating Sales order

SalesTableType and SalesLinetype. Insert() should be called for creating the sales order. Example is as follows. I am currently looking for code that can contains example code of creating invoice from scratch. I will send you the code in an hour.

static void createSalesTable(CustAccount _custAccount)
{
SalesTable salesTable;
NumberSeq NumberSeq;
;

NumberSeq =NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().numberSequence);
salesTable.SalesId = NumberSeq.num();
salesTable.initValue();
salesTable.CustAccount = _custAccount;
salesTable.initFromCustTable();
salesTable.insert();
}

Example: Create a Sales Line

static void createSalesLine(SalesId _salesId, ItemId _itemId)
{
SalesLine salesLine;
;
salesLine.clear();
salesLine.SalesId = _salesId;
salesLine.ItemId = _itemId;
salesLine.createLine(NoYes::Yes, // Validate
NoYes::Yes, //initFromSalesTable
NoYes::Yes, //initFromInventTable
NoYes::Yes, // calcInventQty
NoYes::Yes, // searchMarkup
NoYes::Yes); // searchPrice
}

Code for posting Sales order Invoice

static void createSalesOrder(Args _args)
{
SalesFormLetter formLetterObj;
formLetterObj = SalesFormLetter::construct(DocumentStatus::Invoice);
formLetterObj.update(SalesTable::find(“SO-101248″));
}

How to Copy Sales Quote in AX 2009

The default functionality of Microsoft Dynamics Ax 2009 does not allow to copy a quote when a quote's status is either Lost, Sent, Confirmed, or Canceled.

Today I was asked to allow the users to copy a quote when its status is Sent or Lost.

To copy a quote go to Sales Quotation Details, choose a record and then go to the header level buttons and click Function > CopyFromAll

The following are the steps to accomplish this very quick:

1- Go to the SalesQuotationTable Form > Designs > Design GroupTable> ButtonGroup:ButtonHeader> MenuButton:ButtonHeaderFunction>method>clicked:

You will see the following code:

void clicked()
{
;
// Set price simulation buttons

salesQuotationPriceSimHeader.enabled(!salesQuotationTable.isTemplate());

salesQuotationTableForm.enableFunctionButtons(salesQuotationTable,
buttonConvert2Customer,
buttonAlternativeQuotations,
buttonCopyAllHeader,
salesQuotationChangeReasonCode);

smmDocuments.enabled(!salesQuotationTable.isTemplate());
super();
}

2- Go to the definition of enableFunctionButtons method (right click > Go To Definition.

Look for the following line of code:


enableCopyAllHeaderButton = salesQuotationTableType.mayQuotationBeCopied();


3- Go to the definition of the salesQuotationTableType.mayQuotationBeCopied() method, and then make the following changes:

ok = (//salesQuotationTable.QuotationStatus != SalesQuotationStatus::Sent &&
salesQuotationTable.QuotationStatus != SalesQuotationStatus::Confirmed &&
//salesQuotationTable.QuotationStatus != SalesQuotationStatus::Lost &&
salesQuotationTable.QuotationStatus != SalesQuotationStatus::Cancelled);

Create number sequence in D365 FO

Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...