can you point out what is wrong with my code?? i want to add sales item by clicking on my own button!


suppose, i have created item with number “1010” in invent table & created one button on sales order form & by clicking that button i should get that item 1010 should be inserted in selected sales order. i have write code as shown below.

void clicked()





salesLine.SalesId = salesTable.SalesId; // “00000044_050”; salesTable.SalesId; provide so number

item = InventTable::find(“1010”); //(_itemId); // here we have to give item no as string.

salesLine.ItemId = item.ItemId;

salesLine.Name = item.ItemName;


salesLine.initFromSalesTable(salesTable);// This is taking care of which SO is selected

salesLine.SalesPrice = salesLine.CostPrice; //_costPrice;

salesLine.SalesQty = salesLine.SalesQty; //_qty;


salesLine.CustGroup = salesTable.CustGroup; //“110”;

salesLine.ShippingDateRequested = mkdate(4,9,2010);

salesLine.CustAccount = salesTable.CustAccount; //“000011_030”;

salesLine.CurrencyCode = salesTable.CurrencyCode; //“EUR”;

SalesLine.SalesType = salesTable.SalesType;

salesLine.DlvMode = salesTable.DlvMode; //01;

salesLine.SalesQty = 1; //qty can give form here

salesLine.LineAmount = salesLine.calcLineAmount();

salesLine.LineNum = salesLine::lastLineNum( salesLine.SalesId) + 1;



but when after click on that button grid is show empty!!

so i have to do manually refresh!

can any one tell how to do refresh by code!! on this button event!?


to add salesLine i shoud use any other mehtod!!??

pls. comment asap


you can refresh the data source after the creation of the new line using:

salesLine_ds.research(true); // you can pass throw true or false if you want to maintain the cursor possition or not

for example. (also you can run .refresh() or .exequteQuery(), depending on the result expected).



ok Estevan,

I got the point for refresh but it is working for only first line to add in grid view.

but what should i do if i want to append another line on the grid…???



after your code;