on 09-04-2017 9:34 PM - last edited on 02-04-2024 2:34 AM by postmig_api_4
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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
88 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.