Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Short explanation is i'm trying to create a method for us to import items from our very old ERP to Vault Items. I have create a test function to work from and i finally go to at least report success, but no item is getting created in Vault. Can anyone point out what exactly we're missing here? Thanks
private void TestCreateSingleItem(Connection connection)
{
try
{
Cat[] categories = connection.WebServiceManager.CategoryService.GetCategoriesByEntityClassId("ITEM", true);
long catId = -1;
foreach (Cat category in categories)
{
if (category.SysName == "Assembly")
catId = category.Id;
}
var categoryId = GetDefaultItemCategoryId(connection);
MessageBox.Show($"Found category ID: {catId}");
// Step 1: Find available numbering schemes
long numschid = -1;
NumSchm[] schemes = connection.WebServiceManager.NumberingService.GetNumberingSchemes("ITEM", NumSchmType.Activated);
foreach (NumSchm scheme in schemes)
{
if (scheme.Name.Contains("Item"))
{
numschid = scheme.SchmID;
}
}
try
{
// create the item
var newItem = connection.WebServiceManager.ItemService.AddItemRevision(catId);
MessageBox.Show($"Item created with ID: {newItem.Id}, MasterID: {newItem.MasterId}");
// Step 2:
var fieldInputs = new StringArray[1];
var sarray = new StringArray
{
Items = new string[] { "TEST-001" }
};
fieldInputs[0] = sarray;
// Try with numbering scheme ID = 1 (might not exist, but let's see the error)
var itemNums = connection.WebServiceManager.ItemService.AddItemNumbers(
new long[] { newItem.MasterId },
new long[] { numschid },
fieldInputs,
out ProductRestric[] restrictions);
MessageBox.Show($"AddItemNumbers succeeded! Got item number: {itemNums[0].ItemNum1}");
}
catch (Exception ex)
{
MessageBox.Show($"Error with AddItemNumbers: {ex.Message}");
// The error might tell us what numbering scheme IDs are available
}
}
catch (Exception ex)
{
MessageBox.Show($"Error: {ex.Message}");
}
}
Solved! Go to Solution.