I have crated table "sales order" which having relation with sales table
ie salesorder.RefRecid == salestable .Recid
i have created another table that is "salesorderLines" having relation with sales line
salesorderlines.RefRecid == salesLines.Recid
when i create new Sales order some records is inserted in table "sales order" and
like "buyer" , "Exporter" , "RefRecId" , "InvoiceId" and "InvoiceDate"
when sales order is invoiced ,here "InvoiceId" and "InvoiceDate" will be blank till sales order is invoice
and here table "salesorderLine" contain HSN code which will get inserted if lines are added in line tab of salesOrder.
so these tables populate same as if records are inserted in salestable and salesline as per relation.
but in my when sales order is created a row is inserted in table "salesorder" and when salesorder is invoiced another row is inserted in table "salesorder" .so i am getting 2 records for one sales order that must not happen. can anyone suggest how can solve this issue.
hi martin,
thanks for reply ,
i have written code for insert and update
insert is working as expected but when i add line in my sales order and
i want to hsn code should get into my "SalesOrderEximLines" table as i am having relation of "SalesOrderEximLines" with table "salesline" but its not happening can you suggest anything about it
the code is below
[ExtensionOf(tableStr(SalesTable))] final class EximSalesTable_Extension { public void insert(boolean _skipMarkup ) { SalesOrderExim salesOrderExim; SalesOrderEximLines salesOrderEximLines; CustInvoiceJour custInvoiceJour; SalesLine salesline; TaxInformationLegalEntity_IN taxInformationLegalEntity_IN; TaxInformation_IN taxInformation_IN; str IECNUMBER; select * from salesOrderExim where salesOrderExim.RefrenceRecId == this.RecId; select PANNumber from taxInformationLegalEntity_IN where taxInformationLegalEntity_IN.LegalEntity == companyInfo::find().RecId; taxInformation_IN = TaxInformation_IN::findDefaultbyLocation(LogisticsPostalAddress::findByLocation(companyInfo::find().PrimaryAddressLocation).Location); IECNUMBER = TaxRegistrationNumbers_IN::find(taxInformation_IN.IECRegistrationNumberTable).RegistrationNumber; ttsbegin; if(custInvoiceJour.InvoiceId) { select InvoiceId,InvoiceDate from custInvoiceJour where custInvoiceJour.SalesId == this.SalesId; salesOrderExim.InvoiceId = custInvoiceJour.InvoiceId; salesOrderExim.FromDate = custInvoiceJour.InvoiceDate; salesOrderExim.insert(); } else { salesOrderExim.Buyer = this.SalesName; salesOrderExim.Exporter = companyinfo::find().Name; salesOrderExim.PANNumber = taxInformationLegalEntity_IN.PANNumber; salesOrderExim.IECNumber = IECNUMBER; salesOrderExim.State = companyInfo::find().postalAddress().State; salesOrderExim.Payment = this.Payment; salesOrderExim.TermsOfDelivery = this.DlvTerm; salesOrderExim.InvoiceId = ""; salesOrderExim.FromDate = dateNull(); salesOrderExim.insert(); } ttscommit; next insert(_skipMarkup); } public void update() { SalesOrderExim salesOrderExim; SalesOrderEximLines salesOrderEximLines; CustInvoiceJour custInvoiceJour; SalesLine salesline; TaxInformationLegalEntity_IN taxInformationLegalEntity_IN; TaxInformation_IN taxInformation_IN; str IECNUMBER; select PANNumber from taxInformationLegalEntity_IN where taxInformationLegalEntity_IN.LegalEntity == companyInfo::find().RecId; taxInformation_IN = TaxInformation_IN::findDefaultbyLocation(LogisticsPostalAddress::findByLocation(companyInfo::find().PrimaryAddressLocation).Location); IECNUMBER = TaxRegistrationNumbers_IN::find(taxInformation_IN.IECRegistrationNumberTable).RegistrationNumber; select forupdate salesOrderExim where salesOrderExim.RefrenceRecId == this.RecId; ttsbegin; if(this.SalesStatus==SalesStatus::Invoiced && salesOrderExim.InvoiceId == "") { select InvoiceId,InvoiceDate from custInvoiceJour where custInvoiceJour.SalesId == this.SalesId; salesOrderExim.InvoiceId = custInvoiceJour.InvoiceId; salesOrderExim.FromDate = custInvoiceJour.InvoiceDate; salesOrderExim.Buyer = this.SalesName; salesOrderExim.Exporter = companyinfo::find().Name; salesOrderExim.PANNumber = taxInformationLegalEntity_IN.PANNumber; salesOrderExim.IECNumber = IECNUMBER; salesOrderExim.State = companyInfo::find().postalAddress().State; salesOrderExim.Payment = this.Payment; salesOrderExim.TermsOfDelivery = this.DlvTerm; salesOrderExim.update(); } ttscommit; while select forupdate salesOrderEximLines join salesline where salesline.RecId == salesOrderEximLines.RefRecId && salesline.SalesId == this.SalesId { ttsbegin; if(salesline.ItemId != "" ) { salesOrderEximLines.HSNCode = HSNCodeTable_IN::find(InventTable::find(salesLine.ItemId).HSNCodeTable_IN).Code; salesOrderEximLines.update(); } else { salesOrderEximLines.HSNCode = ""; salesOrderEximLines.update(); } ttscommit; } next update(); } } }
It seems that you have a problem with code that should update your table when the order is invoiced, but we can't point out to the bug, because you've told us nothing about your code.
If you have no idea about what's going on in your code, put a breakpoint to insert() method of salesorder and debug the process. It'll tell you what creates the extra record.
By the way, do you realize that a single order may have several invoices? You want to have just a single salesorder for SalesTable, therefore you'll be able to track invoice ID and date just for one of the several invoices.
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156