Scenario:
Sometime a requirement come that we need to copy multiple attachments from one form to another with the flow of data.
For example when purchase order creates from sales order then the attachments also need to be flow from sales order to purchase order
Solution:
First thing first -> Identify the relation between new and existing form(tables).
Then use the below code to achieve this.
I used the onInserted event ,you can use the same or whatever suitable for your scenario. Important thing is record should be created in new table then you can copy the attachment.
/// <summary>
///
/// </summary>
/// <param name=”sender”></param>
/// <param name=”e”></param>
[DataEventHandler(tableStr(PurchTable), DataEventType::Inserted)]
public static void PurchTable_onInserted(Common sender, DataEventArgs e)
{
DocuRef docuRef;
PurchTable purchTable = sender;
SalesTable salesTable = SalesTable::find(purchTable.InterCompanyOriginalSalesId);
while select docuRef
where docuRef.RefCompanyId== salesTable.DataAreaId
&& docuRef.RefTableId == salesTable.TableId
&& docuRef.RefRecID == salesTable.RecId
{
docuRef.RefTableId = purchTable.TableId;
docuRef.RefRecId = purchTable.RecId;
docuRef.insert();
}
}
//Leave your comments below if you have any query. I will try to help you to solve your problem
Like this:
Like Loading...
Related