cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate Stock Transfer - DI API

Former Member
0 Kudos

Good day experts,

I am developing an application that converts stock transfer requests to stock transfers, only I came across one detail: at the moment of making that conversion and generating the stock transfer, the inventory is already affected , but I require a way to duplicate that last move to only edit the source and destination warehouse, and create an exact copy but with different warehouse, without requiring to redefine all lines from the beginning, this to automate a warehouse process.

I searched the forum and the web, but I do not find any way to achieve this, could someone confirm me if it's possible? If yes, could you provide me with an example or resource that can consult to get it?

Thank you in advance for your support, best regards!

Accepted Solutions (1)

Accepted Solutions (1)

former_member185682
Active Contributor
0 Kudos

Hi Luis,

A full sample:

StockTransfer oStTransfer = null;
try
{
    //Set up your company object to work with xml import/export.
    oCompany.XmlExportType = BoXmlExportTypes.xet_ExportImportMode;
    oCompany.XMLAsString = true;
    string xmlStockTransfer = string.Empty;


    //Load your last stock transfer.
    oStTransfer = oCompany.GetBusinessObject(BoObjectTypes.oStockTransfer);
    if (oStTransfer.GetByKey(9980))
    {
        //Convert your strock transfer object in a xml
        xmlStockTransfer = oStTransfer.GetAsXML();
    }


    if (!string.IsNullOrEmpty(xmlStockTransfer))
    {
        //Intialize a new stock transfer through your xml
        oStTransfer = oCompany.GetBusinessObjectFromXML(xmlStockTransfer, 0);
        //Change the fields that you want.
        for (int i = 0; i < oStTransfer.Lines.Count; i++)
        {
            oStTransfer.Lines.SetCurrentLine(i);
            oStTransfer.Lines.FromWarehouseCode = "014.01";
            oStTransfer.Lines.WarehouseCode = "001.01";
        }
        //Add the new transfer.
        if (oStTransfer.Add() != 0)
        {
            MessageBox.Show(oCompany.GetLastErrorDescription());
        }
    }
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}

Hope it helps.

Kind Regards,

Diego Lother

Former Member

Hello Diego, I apologize for the delay, thank you very much for your example, was exactly what I need.

Thank you again and best regards.

- Luis

Answers (0)