How to Copy Records from Child form to parent form

How to Copy Records from Child form to parent form. when I close Form B (child form) The selected records should be updated in the lines of the Parent Table. what are the methods I should use???

Check the sales copying class in AOT… It is used in Sales form for copying actions of sales lines from different sale orders

Hi,

In child form datasource init method

public void init()

{

formobjectset _objset; //to refresh the parent datasource

;

_objset = element.args().record().datasource();

parenttabledatasource = element.args().record();

}

in the same child form datasource write method

{

select firstonly forupdate parenttabledatasource where parenttabledatasource.uniqueid == childtabledatasource.uniqueid;

ttsbegin;

parenttabledatasource.fields = childtabledatasource.fields;

parenttabledatasource.doupdate;

ttscommit;

}

and in the child form override close method

{

_objectset.research();

}

You can override the canClose() method of the child form and call the required business logic to insert the records.

Have a look at \Forms\SalesCopying\Methods\canClose

Hi,

I am able to copy the records by making use of temporary tables in a class , similar to Sales Copying class. I am unable to place the copied values to the parent form. what should i write in update method of my table. How to update the parent form with the values from temporary tables.

this is copyheader method code in my class

private void copyHeader()
{
//CustInvoiceTable fromCustInvoiceTable;
Parent fromParent;
ttsBegin;

while select forUpdate tmpFrmVirtualHeader
{
if (tmpFrmVirtualHeader.TableNum == tableNum(Parent))
{
fromParent= Parent::findRecId(tmpFrmVirtualHeader.RecordNo);

if (copyMarkup)
{
Markup::delete(Parent);
}
Parent.write();
if (Parent)
{
Parent.write();
}
else
{
Parent.reread();
throw error("@SYS18722");
}
tmpFrmVirtualHeader.delete();

if (copyMarkup)
{
Markup::copy(reverseSign, fromParent, Parent);
}

}
}

ttsCommit;
}

What actually are you trying to achieve?

Do you want to update records in Parent Form which users had modified in Child Form?

or

you are inserting records in Child form & want to add that new records to the parent form?

hi Mehul,

I need to replicate copy from all functionality in Sales Order → Functions–> Copy from all.

Thanks guys, i am able to get that functionality