Hi All
I have created a custom service to enable creation of Purchase Order using AIF. The service was created successfully but when I am trying to create Purchase Order with following code the ‘Exceptions’ form is showing a Warning that “Field ‘Group’ must be filled in.”. I have provided value for this field (VendGroup) available in PurchTable and PurchLine but still no success. I am producing below the code which I am using to create purchase order and will be grateful if anyone of you could let me know what is wrong in it:
Thanks in advance
Haroon
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CreatePurchOrderApp
{
class Program
{
static void Main(string[] args)
{
try
{
CreatePurchOrder.PurchaseOrderDocumentServiceClient service = new CreatePurchOrder.PurchaseOrderDocumentServiceClient();
CreatePurchOrder.CallContext context = new CreatePurchOrder.CallContext();
CreatePurchOrder.EntityKey[] result;
CreatePurchOrder.AxdPurchaseOrderDocument purchOrder = new CreatePurchOrder.AxdPurchaseOrderDocument();
CreatePurchOrder.AxdEntity_PurchTable[] purchTable = new CreatePurchOrder.AxdEntity_PurchTable[1];
CreatePurchOrder.AxdEntity_PurchLine[] purchLine = new CreatePurchOrder.AxdEntity_PurchLine[1];
CreatePurchOrder.AxdEntity_InventDim_1[] inventDim = new CreatePurchOrder.AxdEntity_InventDim_1[1];
purchTable[0] = new CreatePurchOrder.AxdEntity_PurchTable();
purchLine[0] = new CreatePurchOrder.AxdEntity_PurchLine();
inventDim[0] = new CreatePurchOrder.AxdEntity_InventDim_1();
//fill the context
context.Company = “USMF”;
context.Language = “EN-US”;
purchTable[0].PurchLine = new CreatePurchOrder.AxdEntity_PurchLine[1];
purchTable[0].PurchLine[0] = new CreatePurchOrder.AxdEntity_PurchLine();
//Fill purch table
purchTable[0].PurchId = “AIFPO00001”;
purchTable[0].OrderAccount = “VND000005”;
purchTable[0].InvoiceAccount = “VND000005”;
purchTable[0].CurrencyCode = “USD”;
purchTable[0].LanguageId = “EN-US”;
purchTable[0].VendGroup = “DEFAULT”;
//fill purch line
purchLine[0].PurchId = “AIFPO00001”;
purchLine[0].VendAccount = “VND000005”;
purchLine[0].CurrencyCode = “USD”;
purchLine[0].VendGroup = “DEFAULT”;
purchLine[0].ItemId = “ITM000001”;
purchLine[0].PurchQty = 1;
//inventDim[0].InventSiteId = “1”;
//inventDim[0].InventLocationId = “11”;
//purchLine[0].InventDim_1 = inventDim;
purchTable[0].PurchLine = purchLine;
purchOrder.PurchTable = purchTable;
result = service.create(context, purchOrder);
Console.WriteLine("Created Purchase order id is " + result[0].KeyData[0].Value);
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
}
}
}