Sales Details Form

Hello Team,

I have developed a Form in AX 2009 for Sales Details. I have written a code at CustInvoiceTrans table in insert method. I am not able to get Customer Name, Customer Account Number, Tax Amount posted against each line present against a Sales Invoice. I am refering TaxTrans Table, TaxTrans_IN Table, CustInvoiceTrans Table and CustInvoiceJour Table.
I tried to fetch differenet fields from different tables so that if anyone clicks i get all the details from Same Table. Code written in CustInvoiceTrans table is also below:

public void insert()
{
SalesDetails SalesDetails;
CustInvoiceJour custInvoiceJour;
CustTable CustTable;
super();
//UCC SY Sales Details Form
SalesDetails.initValue();
SalesDetails.CustAccount = this.CustomerAccount();
SalesDetails.CustName = this.CustName();
SalesDetails.InvoiceId = this.InvoiceId;
SalesDetails.InvoiceDate = this.InvoiceDate;
SalesDetails.ItemId = this.ItemId;
SalesDetails.Qty = this.Qty;
SalesDetails.SalesPrice = this.SalesPrice;
SalesDetails.LineAmount = this.LineAmount;
SalesDetails.TaxAmount = this.SalesTaxAmount();
SalesDetails.TaxCode = this.TaxItemGroup;
SalesDetails.InvoiceAmount = this.LineAmount + this.SalesTaxAmount();
//SalesDetails.DlvMode = custInvoiceJour.DlvMode;
//SalesDetails.DlvTerm = custInvoiceJour.DlvTerm;
//SalesDetails.CustName = this.Name;
SalesDetails.write();
}

public Real SalesTaxAmount()
{
TaxTrans taxtrans;
Real val_gst;
Select TaxAmount from TaxTrans
where TaxTrans.TaxCode like ‘GST
//&& TaxTrans.InventTransId== this.InventTransId
&& taxtrans.Voucher == this.InvoiceId;
val_gst=taxtrans.TaxAmount;
return -(val_gst);
}

public String30 CustomerAccount()
{
CustInvoiceJour custinv;
String30 cusAcc;
Select OrderAccount from custinv
where custinv.InvoiceId == this.InvoiceId;
cusAcc = custinv.OrderAccount;
return cusAcc;
}

public Str CustName()
{
TaxTrans_IN taxtrans_1;
Str custname;
Select CustomerName from taxtrans_1
where taxTrans_1.InvoiceId == this.InvoiceId
&& taxtrans_1.ItemId == this.ItemId ;
custname =taxtrans_1.CustomerName;
return custname;
}

Can you please let me know, where i am going wrong. Thank You.

What about something like this?

custTable = this.custInvoiceJour().custTable_InvoiceAccount(); // or custTable_OrderAccount()
salesDetails.CustAccount = custTable.AccountNum;
salesDetails.CustName = custTable.Name;

I hope that these methods exist in AX 2009; I’m looking into D365FO.

Hello Martin,

Thanks for your prompt reply. I tried the above mentioned code, it is not being fetched in the Sales Details Form. Could you please let me know any other scenario to fetch the details.

Thank You.

Please elaborate your answer. “It us not being fetched” doesn’t tell me anything about what happened. Please use the debugger and find out where things don’t behave as expected.

You can’t fix an unknown problem. You must find it first.

Hello Martin,

I mean to say, the fields are not being displayed on the form.

custTable = this.custInvoiceJour().custTable_InvoiceAccount(); // or custTable_OrderAccount()
salesDetails.CustAccount = custTable.AccountNum;
salesDetails.CustName = custTable.Name;

These have blank values and value NULL is passed to the Sales Details Form. Attached screenshot for your perusal.

Thank You.

OK, but you don’t know why, that’s why you must debug the code. Is the code called at all? Is custTable populated? If so, do you save salesDetails? If not, why not? Does “this” contain the right values? Does custInvoiceJour() return the journal? And so on…