1. In VS create console application project.
2. copy the below code in Program.cs
3. Run this code and test in Ax tables.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Add a using statement for the service reference.
using FTI.FTIServiceRef;
using System.Collections;
namespace FTI
{
class Program
{
static void Main(string[] args)
{
// Instantiate an instance of the service client class.
FreeTextInvoiceServiceClient proxy = new FreeTextInvoiceServiceClient();
// Create an instance of the document class.
AxdFreeTextInvoice freetextInvoice = new AxdFreeTextInvoice();
CallContext context = new CallContext();
context.Language = "en-us";
context.Company = "gsec";
// Create instances of the entities that are used in the service and
// set the needed fields on those entities.
AxdEntity_CustInvoiceTable custInvoiceTable = new AxdEntity_CustInvoiceTable();
custInvoiceTable.OrderAccount = "Cus-000001";
custInvoiceTable.LanguageId = "en-us";
custInvoiceTable.PurchOrderFormNum = "Test";
custInvoiceTable.CustomerRef = "Test1";
AxdEntity_CustInvoiceLine custInvoiceLine = new AxdEntity_CustInvoiceLine();
custInvoiceLine.Description = "Test Description";
custInvoiceLine.InvoiceTxt = "Test Invoice Txt";
custInvoiceLine.AmountCur = 120;
custInvoiceLine.AmountCurSpecified = true;
//custInvoiceLine.LedgerDimension = 5637152076; //for main account 10100000
AxdType_DefaultAccount account = new AxdType_DefaultAccount();
account.MainAccount = "10100000";
custInvoiceLine.LedgerDimension = account;
custInvoiceLine.DefaultDimension = new AxdType_DimensionAttributeValueSet();
AxdType_DimensionAttributeValue dimValue1 = new AxdType_DimensionAttributeValue();
dimValue1.Name = "BusinessUnit";
dimValue1.Value = "100";
AxdType_DimensionAttributeValue dimValue2 = new AxdType_DimensionAttributeValue();
dimValue2.Name = "Department";
dimValue2.Value = "1000";
AxdType_DimensionAttributeValue dimValue3 = new AxdType_DimensionAttributeValue();
dimValue3.Name = "CostCenter";
dimValue3.Value = "10000";
custInvoiceLine.DefaultDimension.Values = new AxdType_DimensionAttributeValue[3] { dimValue1, dimValue2, dimValue3 };
/*custInvoiceLine.DefaultDimension.Values = new AxdType_DimensionAttributeValue[3];
custInvoiceLine.DefaultDimension.Values[0] = dimValue1;
custInvoiceLine.DefaultDimension.Values[1] = dimValue2;
custInvoiceLine.DefaultDimension.Values[2] = dimValue3;*/
//account.Values = new AxdType_DimensionAttributeValue[3] { dimValue1, dimValue2, dimValue3 };
//AxdEntity_InventDim inventDim = new AxdEntity_InventDim();
//inventDim.InventSiteId = "MUS";
/*inventDim.configId = "HD";
inventDim.InventColorId = "01";
inventDim.InventSizeId = "42";*/
// Add the sub-entity instances to their parent entities as an array
// of the sub-entity type.
//salesLine.InventDim = new AxdEntity_InventDim[1] { inventDim };
custInvoiceTable.CustInvoiceLine = new AxdEntity_CustInvoiceLine[1] { custInvoiceLine };
freetextInvoice.CustInvoiceTable = new AxdEntity_CustInvoiceTable[1] { custInvoiceTable };
try
{
// Call the create method on the service passing in the document.
EntityKey[] returnedFTIEntityKey = proxy.create(context, freetextInvoice);
// The create method returns an EntityKey which contains the ID of the sales order.
EntityKey returnedFTI = (EntityKey)returnedFTIEntityKey.GetValue(0);
Console.WriteLine("The free text invoice created has a ID of " + returnedFTI.KeyData[0].Value);
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.ReadLine();
}
}
}
}
2. copy the below code in Program.cs
3. Run this code and test in Ax tables.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Add a using statement for the service reference.
using FTI.FTIServiceRef;
using System.Collections;
namespace FTI
{
class Program
{
static void Main(string[] args)
{
// Instantiate an instance of the service client class.
FreeTextInvoiceServiceClient proxy = new FreeTextInvoiceServiceClient();
// Create an instance of the document class.
AxdFreeTextInvoice freetextInvoice = new AxdFreeTextInvoice();
CallContext context = new CallContext();
context.Language = "en-us";
context.Company = "gsec";
// Create instances of the entities that are used in the service and
// set the needed fields on those entities.
AxdEntity_CustInvoiceTable custInvoiceTable = new AxdEntity_CustInvoiceTable();
custInvoiceTable.OrderAccount = "Cus-000001";
custInvoiceTable.LanguageId = "en-us";
custInvoiceTable.PurchOrderFormNum = "Test";
custInvoiceTable.CustomerRef = "Test1";
AxdEntity_CustInvoiceLine custInvoiceLine = new AxdEntity_CustInvoiceLine();
custInvoiceLine.Description = "Test Description";
custInvoiceLine.InvoiceTxt = "Test Invoice Txt";
custInvoiceLine.AmountCur = 120;
custInvoiceLine.AmountCurSpecified = true;
//custInvoiceLine.LedgerDimension = 5637152076; //for main account 10100000
AxdType_DefaultAccount account = new AxdType_DefaultAccount();
account.MainAccount = "10100000";
custInvoiceLine.LedgerDimension = account;
custInvoiceLine.DefaultDimension = new AxdType_DimensionAttributeValueSet();
AxdType_DimensionAttributeValue dimValue1 = new AxdType_DimensionAttributeValue();
dimValue1.Name = "BusinessUnit";
dimValue1.Value = "100";
AxdType_DimensionAttributeValue dimValue2 = new AxdType_DimensionAttributeValue();
dimValue2.Name = "Department";
dimValue2.Value = "1000";
AxdType_DimensionAttributeValue dimValue3 = new AxdType_DimensionAttributeValue();
dimValue3.Name = "CostCenter";
dimValue3.Value = "10000";
custInvoiceLine.DefaultDimension.Values = new AxdType_DimensionAttributeValue[3] { dimValue1, dimValue2, dimValue3 };
/*custInvoiceLine.DefaultDimension.Values = new AxdType_DimensionAttributeValue[3];
custInvoiceLine.DefaultDimension.Values[0] = dimValue1;
custInvoiceLine.DefaultDimension.Values[1] = dimValue2;
custInvoiceLine.DefaultDimension.Values[2] = dimValue3;*/
//account.Values = new AxdType_DimensionAttributeValue[3] { dimValue1, dimValue2, dimValue3 };
//AxdEntity_InventDim inventDim = new AxdEntity_InventDim();
//inventDim.InventSiteId = "MUS";
/*inventDim.configId = "HD";
inventDim.InventColorId = "01";
inventDim.InventSizeId = "42";*/
// Add the sub-entity instances to their parent entities as an array
// of the sub-entity type.
//salesLine.InventDim = new AxdEntity_InventDim[1] { inventDim };
custInvoiceTable.CustInvoiceLine = new AxdEntity_CustInvoiceLine[1] { custInvoiceLine };
freetextInvoice.CustInvoiceTable = new AxdEntity_CustInvoiceTable[1] { custInvoiceTable };
try
{
// Call the create method on the service passing in the document.
EntityKey[] returnedFTIEntityKey = proxy.create(context, freetextInvoice);
// The create method returns an EntityKey which contains the ID of the sales order.
EntityKey returnedFTI = (EntityKey)returnedFTIEntityKey.GetValue(0);
Console.WriteLine("The free text invoice created has a ID of " + returnedFTI.KeyData[0].Value);
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.ReadLine();
}
}
}
}
No comments:
Post a Comment