Code that worked in Vault Professional 2014, no longer works with 2015.
Neither the "ItemEditor" solution in the SDK or the example in the help file works.
The ItemEditor produces an error 1306. The help file sample actually accesses a method (which I used in my 2014 code) that doesn't even exist.
Both examples do the following.
Item item = ItemService.AddItemRevision(catID);
item.Title = "test item";
item.Detail = test item";
Here is where they differ.
ItemEditor: ItemService.UpdateAndCommitItems(new Item[] { item }); // Produces error 1306
SDK Help example: ItemService.UpdateAndCommitItem(item, 0, false, null, null, null, null, null, null, 0);
The second method is the one I used previously, but it does not actually exist. So someone obviously missed this change and never updated the help.
So .. what now? My user is an Administrator so there should be no issues with restrictions.
Solved! Go to Solution.
Solved by desidubajic. Go to Solution.
Solved by desidubajic. Go to Solution.
Take a look in the server vlog. It should include a stack trace and an inner exception which may help determine the root cause of the problem.
-Dave
Thanks Dave. I checked the logs, and it appears that the issue is my numbering scheme. Although this is a brand new "empy" database, I had set the default numbering scheme for items to "mapped". I confirmed this was the issue by changing the default to sequential and managed to create items without error.
Below is the code I was using "up till now" that worked.
item = WSM.ItemService.AddItemRevision(catId);
ItemNum number = WSM.ItemService.AddItemNumber(item.MasterId, GetNumSchm("Mapped"), new string[] { itemNumber });
// set the data
item.ItemNum = number.ItemNum1;
item.Title = title;
item.Detail = description;
item.UnitId = unitId;
item.Units = units;
// commit the item, which finalizes the object
WSM.ItemService.UpdateAndCommitItems(new Item[] { item });
Unfortunately ..AddItemNumber.. is now ..AddItemNumbers.. and the syntax has changed which is confusing me.
I'm not sure how to create a StringArray, let alone an array of StringArrays to fulfill the paramaters required by this new method.
ProductRestric[] restrictions;
ItemNum[] numbers = WSM.ItemService.AddItemNumbers(new long[] { item.MasterId }, new long[] { GetNumSchm("Mapped") },
.. At this point I would have added a new String containing the desired item number ..
I tried a string array new string[] { itemNumber } but that isn't a StringArray
A StringArray has items, but there appears to be no way to "Add" items, or define the scope of the Array ...
An example of how this method is implimented would be of great value.
Thanks
Use the button ... the search button that is. I found a post where someone had a different issue, but provided code that showed how the StringArray was properly formatted. Items are now created without error.
Item item = itemSvc.AddItemRevision(CategoryId);
StringArray[] fieldInputs = new StringArray[1];
StringArray sarray = new StringArray();
sarray.Items = new string[] { itemNumber };
fieldInputs[0] = sarray;
ProductRestric[] restrictions;
ItemNum[] itemNum = itemSvc.AddItemNumbers(new long[] { item.MasterId }, new long[] { SchemeId}, fieldInputs, out restrictions);
item.ItemNum = itemNum[0].ItemNum1;
item.Title = title;
....
itemSvc.UpdateAndCommitItems(new Item[] { item });