Search results when searching for items not complete

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

dprothero
Posts: 44
Joined: Sun Mar 21, 2004 12:18 pm
Location: Stockton California
Contact:

Re: Search results when searching for items not complete

Post by dprothero » Thu May 05, 2011 1:21 pm

Beth-

Thanks for your help, I really appreciate it. I finally got everything working except grabbing the newItem.ID. I am unable to compile when I try to access this property.

FYI- My app was using the IDs assigned to project and user and things, so I had to alter the code to capture other data from the database rather than the IDs (projectName = sgdragenet.projects.name, Assignee = sgmasters.users.login, etc).

So do I need to write a query which grabs the ID from the database? I would prefer not to do that, but I can if it is unavailable from the API when I have a FortressItemExpanded.

dprothero
Posts: 44
Joined: Sun Mar 21, 2004 12:18 pm
Location: Stockton California
Contact:

Re: Search results when searching for items not complete

Post by dprothero » Fri May 06, 2011 11:43 am

Beth-

I got it all working... Had to use the MantisItem to update certain fields and grab some of the fields I needed. Here is my final code-

Public Function CreateNewProject( _
ByVal assigneeID As Integer, _
ByVal projectName As String, _
ByVal itemType As String, _
ByVal description As String, _
ByVal details As String, _
ByVal status As Integer, _
ByVal category As String, _
ByVal resolverID As Integer, _
ByVal priority As String, _
ByVal projectFrom As String, _
ByVal testers As String, _
Optional ByVal timeEstimate As String = Nothing, _
Optional ByVal deadline As DateTime = Nothing, _
Optional ByRef msgid As Integer = 0, _
Optional ByVal platform As String = "Database Changes", _
Optional ByVal useHtmlInDetails As Boolean = False _
) As Integer

Me.Login()

Dim newItem As FortressItemExpanded = New FortressItemExpanded

newItem.ProjectName = projectName
newItem.ItemType = itemType
newItem.Description = description
newItem.Details = details
'newItem.Status = status 'needs to be modified after added. Always defaults to Open.
newItem.Category = category
newItem.Platform = platform
newItem.Custom1 = projectFrom
newItem.Custom2 = testers
newItem.TimeEstimate = timeEstimate.ToString
newItem.Priority = priority
newItem.UseHtmlInDetails = useHtmlInDetails

'Call Validate after setting all your strings for your item and before you pass the item to a method
newItem.Validate()

'Need to store as a mantis Item because then I have access to other values.
Dim mi As MantisItem = newItem.GetMantisItem

'Storing the item initially.
Dim addedMi As MantisItem = ItemTrackingOperations.ProcessCommandAddFortressItem(mi)

'set your status and other variables on the newItem (now a mantisItem).
addedMi.StatusID = status
If resolverID <> Nothing AndAlso resolverID > 0 Then
addedMi.ResolverID = resolverID
End If

If assigneeID <> Nothing AndAlso assigneeID > 0 Then
addedMi.AssigneeID = assigneeID
End If

'Modifying item to update status and other variables.
ItemTrackingOperations.ProcessCommandModifyFortressItem(addedMi)

'Returning msgid (ByRef) up the chain. Required to add attachements.
msgid = addedMi.MsgID

'Returning ItemId
Return addedMi.ID
End Function

Thanks for the help, you led me in the correct direction.

-Doug

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: Search results when searching for items not complete

Post by Beth » Fri May 06, 2011 1:14 pm

Thank you for the update. This may help other users as well. I'm going to cross-post this topic in the part of our forum for API help.
Beth Kieler
SourceGear Technical Support

Post Reply