Hi sir
Martin Dráb,
I have gone through the post and your suggested answer which is "
I would rather design two contract classes in C# - one for the invoice header and one for lines. The header contract would hold a collection of line contracts in a property. In X++, I would have a method that initialize the line contract from CustInvoiceTrans record. The header contract could have a method like AddLine(), so you don't really have to deal with the collection in X++ at all".
I have tried to do something like that. Here is my code.
[DataContractAttribute]
public class InvoiceHeaderContract
{
public int POSID;
public str USIN;
[DataMemberAttribute('PSOID')]
public int parmPOSID(int _POSID = POSID)
{
POSID = _POSID;
return POSID;
}
[DataMemberAttribute('USIN')]
public str parmUSIN(str _USIN = USIN)
{
USIN = _USIN;
return USIN;
}
public void addInvoiceLine(str _itemCode, str _itemName, int _quantity)
{
InvoiceLineContract invoiceLine = new InvoiceLineContract();
invoiceLine.parmItemCode(_itemCode);
invoiceLine.parmItemName(_itemName);
invoiceLine.parmQuantity(_quantity);
}
}
and here is my InvoiceLineContract class code
[DataContractAttribute]
public class InvoiceLineContract
{
public str ItemCode;
public str ItemName;
public int Quantity;
[DataMemberAttribute('ItemCode')]
public str parmItemCode(str _ItemCode = ItemCode)
{
ItemCode = _ItemCode;
return ItemCode;
}
[DataMemberAttribute('ItemName')]
public str parmItemName(str _ItemName = ItemName)
{
ItemName = _ItemName;
return ItemName;
}
[DataMemberAttribute('Quantity')]
public int parmQuantity(int _Quantity = Quantity)
{
Quantity = _Quantity;
return Quantity;
}
}
And here is the main method code in the job where I am calling it.
public static void main(Args _args)
{
InvoiceHeaderContract invoiceHeader = new InvoiceHeaderContract();
InvoiceLineContract invoiceLine = new InvoiceLineContract();
invoiceHeader.parmPOSID(987155);
invoiceHeader.parmUSIN("USIN0");
invoiceHeader.addInvoiceLine("Item1", "TestItem", 2);
IntegrationWithFBRLibrary.SendRequest obj = new IntegrationWithFBRLibrary.SendRequest();
str message= obj.sendMethod(invoiceHeader, invoiceLine);
}
And here is the C# code of sendMethod
public string sendMethod(Object invoiceHeader, object invoiceLine)
{
// My logic
}
Now, still it is showing me the error of
Error Method 'sendMethod(System.Object, System.Object)' is not found on type 'IntegrationWithFBRLibrary.SendRequest'. IntegrationWithFBRProject
in the main method of my job where I am calling the obj.sendMethod(invoiceHeader, invoiceLine);
Please suggest me with your knowledge how can I do it.
Thanks in advance.
Regards,