We have succesfully run tests to elevate our user requests from our own user-tracking system to Dragnet using AddItemExternal in the web service. However, is there a way to return the new item ID once the item has been accepted? Am I missing something blindingly obvious (very likely)?
Would it be easier if we used AddItem instead? Can we then login through the web service, additem, and then get the last item id added? We could easily make it such that the only people who will be elevating the issues to Dragnet will be Dragnet users anyway, so this wouldn't be a problem for us with regard to user licenses.
Alternatively, should we be adapting our own web service to do this, using your dragnet libraries? Is this allowed by the Dragnet license? It would seem a shame to have to do this given that the Dragnet API seems so comprehensive, and this is the only thing I can't work out how to do (I did say it was quite likely I was missing something)!
Regards,
Andy
Returning Item ID after using AddItemExternal on Web Service
Moderator: SourceGear
Re: Returning Item ID after using AddItemExternal on Web Ser
Nope. Dragnet returns a 0 if the item was successfully added, any other value represents some sort of error. Like you, I would like to see the number assigned. Perhaps the Dragnet team could change the return values so that any negative number would represent a failure and any positive number would be the ID number for the item just added.AGBrown wrote:We have succesfully run tests to elevate our user requests from our own user-tracking system to Dragnet using AddItemExternal in the web service. However, is there a way to return the new item ID once the item has been accepted? Am I missing something blindingly obvious (very likely)?
In your case it sounds like you could just login to the webservice then use AddItem. After that you can query for the last item added by the logged in user.Would it be easier if we used AddItem instead? Can we then login through the web service, additem, and then get the last item id added? We could easily make it such that the only people who will be elevating the issues to Dragnet will be Dragnet users anyway, so this wouldn't be a problem for us with regard to user licenses.
Here is a very basic example (no error checking) for a query for the last item ID logged by a certain user:
Code: Select all
//The Date Search Areas
public const byte Added = 0x01;
public const byte Updated = 0x02;
public const byte Commented = 0x04;
public int GetLastItemID()
{
int ret = -1;
Dragnet.MantisItemQueryFilter qf = new DragnetWebServiceTests.Dragnet.MantisItemQueryFilter();
Dragnet.MantisItemExpanded[] o = null;
qf.ProjectLevelFilterID = 0; //project id shouldn't matter if you just want the last item by a certain user
qf.DateTo = DateTime.Now;
//get the items added in the past minute
//you can change this whatever timespan you want
//or leave qf.DateFrom unspecified to return all items the user has logged
qf.DateFrom = DateTime.Now.Subtract(new TimeSpan(0,1,0));
qf.DateItemAreas =Added; //to search for more DateItemAreas or them together "Added | Updated"
qf.Reporters = new int[] { 1 }; //ID of the user who reported the issue
//set to true if you want the item details field filled out for the returned items
ret = _dragnetService.QueryItems(qf, false, out o);
//currenlty all queries from the webservice are returned in ascending order
//so get the last item in the list just encase more than one item is returned
int last = o[o.Length - 1].ID;
return last;
}
I have logged a request for the web service AddItem and AddItemExternal to indicate the item id after the add.
Mary Jo Skrobul
SourceGear
SourceGear
Thank you
That looks like it would work. Thanks for logging the request - it would be nice if we could do:
Login
AddItem
GetLastItemIDAddedByMe
Logout
and maybe a similar process for AddItemExternal, though i can see that this would be harder.
Login
AddItem
GetLastItemIDAddedByMe
Logout
and maybe a similar process for AddItemExternal, though i can see that this would be harder.