Can someone check my .NET code that I have in an InfoPath button to see what the heck I am doing wrong? I am trying to publish my InfoPath form to SharePoint 2007.
The custom code for the button (clicked) is not being executed. TDAPIOLEib is COM component for Quality Center that is added as a reference. I have also tried putting the code in the form submission and that does not work either.
Many thanks in advance and I will give you as many rep points as I can.
Imports Microsoft.Office.InfoPath
Imports System
Imports System.Xml
Imports System.Xml.XPath
Imports TDAPIOLELib
Imports System.Security.AllowPartiallyTrustedCallersAttribute
Namespace InfoPath_QC_Submit_4
Public Class FormCode
' Member variables are not supported in browser-enabled forms.
' Instead, write and read these values from the FormState
' dictionary using code such as the following:
'
' Private Property _memberVariable() As Object
' Get
' _memberVariable = FormState("_memberVariable")
' End Get
' Set
' FormState("_memberVariable") = value
' End Set
' End Property
' NOTE: The following procedure is required by Microsoft Office InfoPath.
' It can be modified using Microsoft Office InfoPath.
Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
AddHandler DirectCast(EventManager.ControlEvents("btnSubmit"), ButtonEvent).Clicked, AddressOf btnSubmit_Clicked
End Sub
Public Sub btnSubmit_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
Try
Dim qcconn As New TDAPIOLELib.TDConnection
Dim qcserver As String
qcserver = "http://qualitycenterurl/qcbin/"
qcconn.InitConnectionEx(qcserver)
qcconn.Login("username", "password")
qcconn.Connect("Domain", "Project")
Dim BugF As TDAPIOLELib.BugFactory
Dim bug1 As TDAPIOLELib.Bug
BugF = qcconn.BugFactory
bug1 = BugF.AddItem(DBNull.Value)
Dim xnDoc As XPathNavigator = Me.MainDataSource.CreateNavigator()
bug1.Field("BG_Summary") = xnDoc.Select("/my:myFields/Issue_Summary")
bug1.Field("bg_Description") = xnDoc.Select("/my:myFields/Issue_Description")
bug1.Field("bg_Priority") = xnDoc.Select("/my:myFields/Priority")
bug1.Field("bg_detection_date") = xnDoc.Select("/my:myFields/Reported_Date")
bug1.Field("bg_user_57") = xnDoc.Select("/my:myFields/Requestor")
bug1.Field("bg_user_64") = "Incident"
bug1.Field("bg_severity") = "Low"
bug1.Field("bg_user_55") = "N"
bug1.Field("bg_detected_by") = "SharePoint"
bug1.Field("bg_user_31") = "Other"
bug1.Post()
If qcconn.Connected Then
qcconn.Disconnect()
End If
If qcconn.LoggedIn Then
qcconn.Logout()
End If
Catch ex As Exception
End Try
End Sub
End Class
End Namespace
(InfoPath 2007): Tools --> Form Options --> Security and Trust (category) --> Uncheck 'Automatically determine security level' --> Manually check 'Full Trust' --> click 'Ok' when you are done.
(InfoPath 2007): Tools --> Form Options --> Security and Trust (category) --> Check 'Sign this form template' --> Click 'Select Certificate' --> click 'Ok' when you are done.
*Note for #2: You may have to google search 'Add InfoPath Certificate' or start by using this link: MSDN - Deploying Signed Infopath Form Templates