I have created one table name "salesorderexim" which is linked to "salesline" table using Recid of salesline table , i am trying to insert record in "salesorderexim" using oninserting table event handler when i do entry in salesline , but i am getting 2 lines on my salesorderexim table . like oninserting code is creating another line its not insering record in same line .how can i insert without creating another line in my child table any suggestions plz. my code is below
[DataEventHandler(tableStr(SalesLine), DataEventType::Inserting)] public static void SalesOrderEximLines_onInserting(Common sender, DataEventArgs e) { SalesLine salesLine = sender as salesLine; SalesOrderEximLines salesOrderEximLines; ttsbegin; salesOrderEximLines.RefRecId = salesLine.RecId; salesOrderEximLines.HSNCode = HSNCodeTable_IN::find(InventTable::find(salesLine.ItemId).HSNCodeTable_IN).Code; salesOrderEximLines.insert(); ttscommit; }
when i was yousing delayed join i was getting desired output but in front end the entries wont shows properly in form but they are getting inserted in table.
hi,
is it possible if i use form event handler to get these record populated in table when new line is created in salesline
as you said one record is inserted from form thats why i am asking.
No, OnModified won't help.
First of all, think about whether using an InnerJoin is a good idea. It means that no existing order line will be displayed, unless you generate records in your table for all existing order lines. You'd also had to be careful about data consistency. If the insert of SalesLine and your table wasn't in a transaction, users could create order lines that won't show in the form.
hi ,
as you suggest one record is inserted from the form and one record is inserted from my insert event handler so what if i used onmodified event handler will it make change to the record which i need .
thanks for reply ,
when i debug the code i am not getting the "Recid" value of newly created sales line in debugger so the SALESORDEREXIMLINES.Refrecid field is getting blank and the a new line is getting created when HSNCODE IS inserted.
If those fields are getting blank means, as Martin suggested try debugging the code.
Also if you insert, it won't update the record rather it will create a new record.
when I try not to use any code to populate the record it will make the field HSNCODE & RefrenceRecid blank in table so thats why i am trying to insert method,
i need these fields to be populated (field HSNCODE & RefrenceRecid) because the data from these field will reflect in my report.
The best approach would be populating field values before the record is inserted by the sysytem. It would be straightforward and you wouldn't need extra database queries to load the record again and update it.
yes i have SalesOrderEximLines data source joined to SalesLine in the form,
so if code is creating another record how can i insert values in the record which is created by form .
do i have to use update method for this instead of oninserting event handler
thanks ,
regards dinesh
If you have no idea about what is inserting the record, use the debugger to find it out. Put a breakpoint to insert() method, attach the debugger and test the process.
Don't you have SalesOrderEximLines data source joined to SalesLine in the form? If so, one record is created by the form and the other by your code.
André Arnaud de Cal...
291,969
Super User 2025 Season 1
Martin Dráb
230,842
Most Valuable Professional
nmaenpaa
101,156