Using Web Service for Dynamics GP 2013 and Creating Sales Invoice by following code:
CompanyKey companyKey;
Context context;
SalesInvoice salesInvoice;
SalesDocumentTypeKey salesInvoiceType;
CustomerKey customerKey;
BatchKey batchKey;
SalesInvoiceLine salesInvoiceLine;
ItemKey invoiceItem;
Quantity invoiceCount;
Policy salesInvoiceCreatePolicy;
MoneyAmount unitPrice;
DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();
context = new Context();
companyKey = new CompanyKey();
companyKey.Id = (-1);
context.OrganizationKey = (OrganizationKey)companyKey;
salesInvoice = new SalesInvoice();
salesInvoice.Key = new SalesDocumentKey();
salesInvoice.Key.Id = this.CreateId(); //"XX555";
salesInvoiceType = new SalesDocumentTypeKey();
salesInvoiceType.Type = SalesDocumentType.Invoice;
salesInvoice.DocumentTypeKey = salesInvoiceType;
customerKey = new CustomerKey();
customerKey.Id = "ADAMPARK0001";
salesInvoice.CustomerKey = customerKey;
batchKey = new BatchKey();
batchKey.Id = "SALES INVOICES";
salesInvoice.BatchKey = batchKey;
salesInvoice.Comment = "Test invoice master comments.";
IList<SalesInvoiceLine> salesInvoiceLines = new List<SalesInvoiceLine>();
string[] itemId = { "ACCS-HDS-1EAR", "32X IDE" };
for (int i = 0; i < itemId.Count(); i++)
{
salesInvoiceLine = new SalesInvoiceLine();
invoiceItem = new ItemKey();
invoiceItem.Id = itemId[i];
salesInvoiceLine.ItemKey = invoiceItem;
unitPrice = new MoneyAmount();
unitPrice.Currency = "USD";
unitPrice.DecimalDigits = 2;
unitPrice.Value = 1.00M;
salesInvoiceLine.UnitPrice = unitPrice;
invoiceCount = new Quantity();
invoiceCount.Value = 1 + i;
salesInvoiceLine.Quantity = invoiceCount;
salesInvoiceLine.ItemDescription = "test Item Description q1 " + i;
salesInvoiceLine.Comment = "test Item comment q1 " + i;
salesInvoiceLines.Add(salesInvoiceLine);
}
SalesInvoiceLine[] invoiceLines = salesInvoiceLines.ToArray();
salesInvoice.Lines = invoiceLines;
salesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesInvoice", context);
wsDynamicsGP.CreateSalesInvoice(salesInvoice, context, salesInvoiceCreatePolicy);
if (wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
This code little bit changed from this example
Invoice created and data inserted into table:
Created invoice doesn't visible or show at anywhere of GP font end. How and Where will found it?
*This post is locked for comments