Page 2 of 2

Re: Search results when searching for items not complete

Posted: Thu May 05, 2011 1:21 pm
by dprothero
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.

Re: Search results when searching for items not complete

Posted: Fri May 06, 2011 11:43 am
by dprothero
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

Re: Search results when searching for items not complete

Posted: Fri May 06, 2011 1:14 pm
by Beth
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.