I had a working function call the Docusign SOAP API and now all of the sudden its not working. I get the error "The data could not be converted" when I call the CreateEnvelopeFromTemplatesAndForms method. Here is my code.
Dim _userName As String = ""
Dim _apiUrl As String = "https://demo.docusign.net/api/3.0/api.asmx"
Dim _accountId As String = "d90f6802-fa06-42b4-ac3b-5959c3905002"
Dim _password As String = "WWWxyz123"
Dim _email As String = "JGarland#etgroup.net"
Dim _integratorKey As String = "ETGX-1f61c95b-06bd-400b-9604-f247fda0238c"
Sub Main()
'GetSignatureSpot(Nothing)
'GetPDF()
'GetCertificate()
'Exit Sub
_userName = "[" + _integratorKey + "]"
_userName = _userName & _email
Dim _apiClient As DocuSign.DSAPIServiceSoapClient = New DocuSign.DSAPIServiceSoapClient("DSAPIServiceSoap", _apiUrl)
_apiClient.ClientCredentials.UserName.UserName = _userName
_apiClient.ClientCredentials.UserName.Password = _password
Dim envelopeInfo As DocuSign.EnvelopeInformation = New DocuSign.EnvelopeInformation()
envelopeInfo.AccountId = _accountId
envelopeInfo.EmailBlurb = "Please Sign Your Loan Documents"
envelopeInfo.Subject = "Please Sign Your Loan Documents"
'Recipients
Dim recipient1 As DocuSign.Recipient = New DocuSign.Recipient()
recipient1.UserName = "John Doe"
recipient1.Email = "Support#etgroup.net"
recipient1.Type = DocuSign.RecipientTypeCode.Signer
recipient1.RoutingOrder = 1
recipient1.RoutingOrderSpecified = True
recipient1.RoleName = "Borrower 1"
recipient1.ID = "1"
Dim recipient2 As DocuSign.Recipient = New DocuSign.Recipient()
recipient2.UserName = "Jane Doe"
recipient2.Email = "JGarland#etgroup.net"
recipient2.Type = DocuSign.RecipientTypeCode.Signer
recipient2.RoutingOrder = 2
recipient2.RoutingOrderSpecified = True
recipient2.RoleName = "Borrower 2"
recipient2.ID = "2"
Dim signers(1) As DocuSign.Recipient
signers(0) = recipient1
signers(1) = recipient2
'Create draft with all the composite template information
Dim status As DocuSign.EnvelopeStatus
Dim compositTemplate(1) As DocuSign.CompositeTemplate
Dim template As DocuSign.CompositeTemplate
Dim template2 As DocuSign.CompositeTemplate
'Template 1
template = CreateTemplate(1, "Attorney Selection Notice", "F364E20C-D0E6-4735-89E2-8891424BA364", signers, "AttorneySelection.pdf")
compositTemplate(0) = template
'Template 2
template2 = CreateTemplate(2, "Notice of No Oral", "F5A536C3-81AB-4C32-B56A-9F764624C3C4", signers, "NoticeOral.pdf")
compositTemplate(1) = template2
status = _apiClient.CreateEnvelopeFromTemplatesAndForms(envelopeInfo, compositTemplate, True)
End Sub
Private Function CreateTemplate(sequence As Integer, templateName As String, templateID As String, signers() As DocuSign.Recipient, docPath As String) As DocuSign.CompositeTemplate
Dim template As DocuSign.CompositeTemplate = New DocuSign.CompositeTemplate()
'Server Template
Dim serverTemplate As DocuSign.ServerTemplate = New DocuSign.ServerTemplate()
serverTemplate.Sequence = sequence
serverTemplate.TemplateID = templateID
Dim serverTemplates(0) As DocuSign.ServerTemplate
serverTemplates(0) = serverTemplate
template.ServerTemplates = serverTemplates
'Inline Template
Dim inlineTemplate As DocuSign.InlineTemplate = New DocuSign.InlineTemplate()
inlineTemplate.Sequence = "1"
inlineTemplate.Envelope = New DocuSign.Envelope()
inlineTemplate.Envelope.Recipients = signers
inlineTemplate.Envelope.AccountId = _accountId
Dim inlineTemplates(0) As DocuSign.InlineTemplate
inlineTemplates(0) = inlineTemplate
template.InlineTemplates = inlineTemplates
'Document.
template.Document = New DocuSign.Document()
template.Document.ID = "1"
template.Document.Name = ""
template.Document.PDFBytes = System.IO.File.ReadAllBytes(path:=docPath)
template.Document.FileExtension = "pdf"
Return template
End Function
It looks like there were issues with the DocuSign Demo environment (server) recently, according to the DocuSign Trust Center. This is most likely what was causing your issues.
These issues are currently resolved and your envelopes should be working again now. For reference, this is the DocuSign Trust Center with monitoring on the DEMO environment:
https://trust.docusign.com/system-status/demo
Related
I am attempting to pass values from an ADODB.Recordset into a Class Module and am receiving the Sub or Function Not Defined Error when I call Call PopulateJHAData(GeneralInfo.Range("genLoanProg"), CStr(nm)) from within the function to get the data from the recordset; I know i dont need Call in front of the sub; I was just seeing if it made any difference. I can already imagine that there are a host of other items that are wrong with this code since I am just now getting into how to use Class Modules.
'---Class Loan Info
Public LoanNumber As String
Public InterestRate As String
Public OriginalAmount As Double
Public OriginationDate As String
Public MaturityDate As Date
Public NextPaymentDate As Date
Public PaymentAmount As Double
Public Census As String
Public RateNumber As Long
Public Margin As String
Public RoundTo As String
Public RateCeiling As String
Public RateChangeDate As Date
Public ARMNotice As String
Public QualifiedMortgageCode As String
Public ln1098 As String
Public CallReportCode As String
Public CollateralCode As String
Public PurposeCode As String
Public HPML As String
Public LoanTypeCode As String
Public Flood As String
Public CLTV As String
Public Branch As Long
Public FHLBElig As String
Public RepToCB As String
Public Occupancy As String
Public tName As String
Public eNumber As Long
Public Sub PopulateJHAData(ByVal LoanProg As String, ByVal TableName As String, ByVal JHALoanInfo As ADODB.Recordset)
Select Case Left(LoanProg, 4)
Case Is = "FHLB", "Cons", "15yr"
InterestRate = Trim(JHALoanInfo.Fields("Rate").Value)
LoanAmount = Trim(JHALoanInfo.Fields("OrigAmnt").Value)
LoanDate = Trim(JHALoanInfo.Fields("OrigDate").Value)
MaturityDate = Trim(JHALoanInfo.Fields("MatDate").Value)
NextPaymentDate = Trim(JHALoanInfo.Fields("NextPmtDate").Value)
PaymentAmount = Trim(JHALoanInfo.Fields("PaymentAmt").Value)
Census = Trim(JHALoanInfo.Fields("Census").Value)
QualifiedMortgageCode = Trim(JHALoanInfo.Fields("QMCode").Value)
ln1098 = Trim(JHALoanInfo.Fields("ln1098").Value)
CallReportCode = Trim(JHALoanInfo.Fields("CallRep").Value)
CollateralCode = Trim(JHALoanInfo.Fields("ColCode").Value)
PurposeCode = Trim(JHALoanInfo.Fields("PurpCode").Value)
HPML = Trim(JHALoanInfo.Fields("HPML").Value)
LoanTypeCode = Trim(JHALoanInfo.Fields("LnTypeCode").Value)
Flood = Trim(JHALoanInfo.Fields("Flood").Value)
CLTV = Trim(JHALoanInfo.Fields("CombLTV").Value)
Branch = Trim(JHALoanInfo.Fields("Branch").Value)
FHLBElig = Trim(JHALoanInfo.Fields("EligFHLV").Value)
RepToCB = Trim(JHALoanInfo.Fields("RepCB").Value)
Occupancy = Trim(JHALoanInfo.Fields("Occupancy").Value)
Case Else
InterestRate = Trim(JHALoanInfo.Fields("Rate").Value)
LoanAmount = Trim(JHALoanInfo.Fields("OrigAmnt").Value)
LoanDate = Trim(JHALoanInfo.Fields("OrigDate").Value)
MaturityDate = Trim(JHALoanInfo.Fields("MatDate").Value)
NextPaymentDate = Trim(JHALoanInfo.Fields("NextPmtDate").Value)
PaymentAmount = Trim(JHALoanInfo.Fields("PaymentAmt").Value)
Census = Trim(JHALoanInfo.Fields("Census").Value)
RateNumber = Trim(JHALoanInfo.Fields("RateNum").Value)
Margin = Trim(JHALoanInfo.Fields("Margin").Value)
RoundTo = Trim(rs.Fields("RoundTo").Value)
RateCeiling = Trim(rs.Fields("RateCeiling").Value)
RateChangeDate = Trim(rs.Fields("RateChangeDate").Value)
ARMNotice = Trim(rs.Fields("ArmNot").Value)
QualifiedMortgageCode = Trim(JHALoanInfo.Fields("QMCode").Value)
ln1098 = Trim(JHALoanInfo.Fields("ln1098").Value)
CallReportCode = Trim(JHALoanInfo.Fields("CallRep").Value)
CollateralCode = Trim(JHALoanInfo.Fields("ColCode").Value)
PurposeCode = Trim(JHALoanInfo.Fields("PurpCode").Value)
HPML = Trim(JHALoanInfo.Fields("HPML").Value)
LoanTypeCode = Trim(JHALoanInfo.Fields("LnTypeCode").Value)
Flood = Trim(JHALoanInfo.Fields("Flood").Value)
CLTV = Trim(JHALoanInfo.Fields("CombLTV").Value)
Branch = Trim(JHALoanInfo.Fields("Branch").Value)
FHLBElig = Trim(JHALoanInfo.Fields("EligFHLV").Value)
RepToCB = Trim(JHALoanInfo.Fields("RepCB").Value)
Occupancy = Trim(JHALoanInfo.Fields("Occupancy").Value)
End Select
End Sub
Sub LoanInfoGrab()
uName = Environ("username")
empName = StrConv(Left(uName, Len(uName) - 1), vbProperCase)
Dim lnNum As String
lnNum = GeneralInfo.Range("genLoanNumber")
msgCap = "Hello " & empName & "," & vbCrLf & _
"The data for " & lnNum & " is not available, or unable to be retrieved." & _
"This loan will need to be manually checked."
Dim LoanRecordGrab As clsLoanInfo
'passing in all potential table names/sources in array
Set LoanRecordGrab = getLoanInfoRecord(Array(CNCTTP08, BHSCHLP8))
Dim nm
If LoanRecordGrab Is Nothing Then
MsgBox msgCap, vbExclamation, "Error Getting Data"
Else
rem not sure if this should be the sub from the class module or if it should be LoanRecordGrab.
'PopulateJHAData GeneralInfo.Range("genLoanProg"), CStr(nm) yet.
End If
JHACheckFormat
Dim lnData As Range, cData1 As Range, cData2 As Range
Set lnData = JHACheck.Range("H7:H32")
Set cData1 = JHACheck.Range("H35:H41")
Set cData2 = JHACheck.Range("K35:K41")
If loanData.Range("CIF_2") = vbNullString Then
CompareJHACheck lnData, cData1
Else
CompareJHACheck lnData, cData1, cData2
End If
End Sub
Function getLoanInfoRecord(arrNames) As clsLoanInfo
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SQL As String, nm, okSql As Boolean
Dim LoanRecordGrab As clsLoanInfo
Dim lNum As Range: Set lNum = GeneralInfo.Range("genLoanNumber")
conn.Open CONNSTR
'try each provided name: exit loop on successful query
For Each nm In arrNames
SQL = getLoanDBGrabSQL(CStr(nm), lNum)
On Error Resume Next
rs.Open SQL, conn 'try this name
If Err.Number = CONNECTIONERROR Then
okSql = False
Else
okSql = True
End If
On Error GoTo 0 'cancel on error resume next
If okSql Then
If rs.EOF Then
'rs.MoveFirst
Do While Not rs.EOF
Set LoanRecordGrab = New clsLoanInfo 'create an instance to populate
Call PopulateJHAData(GeneralInfo.Range("genLoanProg"), CStr(nm)) 'Sub or Function not Defined happens here
rs.MoveNext
Loop
End If
Exit For 'done trying names
End If
Next nm
If rs.State = adStateOpen Then rs.Close
If conn.State = adStateOpen Then conn.Close
Set getLoanInfoRecord = LoanRecordGrab
End Function
I am trying to find a phrase inside of a variable that contains html. I then want to replace it with a new phrase.
I tried InStr but the phrase is not found. I also tried using wildcards at tht beginning and end of the phrase. I also tried doing an if like also with and without wildcards.
The purpose is to allow a tester to do a batch change on expected results and/or test steps by entering a sentence or phrase they want changed.
The only problem I'm having is being able to programmatically find the sentence within the variable.
Problem area is in bold
Dim qcURL As String
Dim qcID As String
Dim qcPWD As String
Dim qcDomain As String
Dim qcProject As String
Dim preActVal As String
Dim postActVal As String
Dim FindSt As String
Dim currentString As String
Dim thisSheet As Worksheet
'Toggle debugging mode'
Dim isDebugOn As Boolean
isDebugOn = True 'set to true to turn off Active X
''On Error GoTo ErrHandler:
FOLDER_PATH = "BAT\PC2P - Claims - Med"
Set thisSheet = ThisWorkbook.Sheets("ShellUpdater")
TestID = thisSheet.Range("B1").Value
stField = thisSheet.Range("B2").Value
**FindSt = thisSheet.Range("B3").Value**
ReplaceSt = thisSheet.Range("B4").Value
testLocation = thisSheet.Range("B5").Value
'ActiveX Forms
If isDebugOn = False Then
'qcURL = GetOptionMetric("qcURL", 1, "Enter ALM URL") ''popup to get url from user
qcURL = "<<URL>>"
'qcDomain = GetOptionMetric("qcDomain", 1, "Enter your ALM Domain")
''popup to get domain from user
qcDomain = "<<DOMAIN>>"
'qcProject = GetOptionMetric("qcProject", 1, "Enter your ALM Project")
''popup to get project from user
qcProject = "<<PROJECT>>"
qcID = GetOptionMetric("qcID", 1, "Enter your ALM MSID")
qcPWD = GetOptionPassword("qcPWD", 1, "Enter your ALM Password")
Else
qcURL = "<<URL>>"
qcID = "<<USERNAME>>"
qcDomain = "<<DOMAIN>>"
qcProject = "<<PROJECT>>"
qcPWD = InputBox("THIS IS IN DEEBUG MODE")
If qcPWD = vbNullString Then Exit Sub
If qcPWD = "" Then Exit Sub
End If
'END ActiveX Forms
'Connect to ALM
Set tdConnection = CreateObject("TDApiOle80.TDConnection")
tdConnection.InitConnectionEx qcURL
tdConnection.Login qcID, qcPWD
tdConnection.Connect qcDomain, qcProject
''Check if batch updating or single case
Dim testObject As ITest
If InStr(TestID, "All") > 0 Then
Dim TestFact As testFactory
Set tMng = tdConnection.TreeManager
Set srcFolder = tMng.NodeByPath("Subject\" & testLocation)
Set tstFact = srcFolder.testFactory
Set tstList = tstFact.NewList("")
For Each shellTest In tstList
Set DSFact = shellTest.DesignStepFactory.NewList("")
For Each dStep In DSFact
Select Case stField
Case "StepExpectedResult"
**currentString = dStep.StepExpectedResult**
**stposition = InStr(currentString, FindSt)**
If stposition > 0 Then
dStep.StepExpectedResult = preActVal & Replace(currentString, FindSt, ReplaceSt) & postActVal
End If
Case "StepDescription"
currentString = dStep.StepDescription
stposition = InStr(currentString, FindSt)
If stposition > 0 Then
dStep.StepDescription = preActVal & Replace(currentString, FindSt, ReplaceSt) & postActVal
End If
End Select
dStep.Post
Next dStep
Next shellTest
Else
Dim myTest
'Find the Test in test plan
Set thisTest = GetTest(Trim(TestID), testLocation, "\")
Set myTest = tdConnection.testFactory.Item(TestID)
End If
Try this:
Sub replace_string()
FindSt = "but also need rendering provider first name"
ReplaceString = "I LIKE BANANAS"
currentString = "All fields populate from the correctly populated provider<<<\!Renderingproviderlastname>>>, but also need rendering provider first name"
stPosition = Replace(currentString, FindSt, ReplaceString)
MsgBox stPosition
End Sub
I need to split a string into several tokens just like the java code below:
StringTokenizer st = new StringTokenizer(mystring);
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
You can use the function Split(myString, " "), where the first parameter is your string and the second one the token delimiter.
Here's the solution:
Dim myString = myDocument.myField(0)
Dim myTokens = Split(myString, " ")
Dim fisrtToken = myTokens(0)
Dim secondToken = myTokens(1)
Here's the code I implemented from the answers around for IBM Lotus Notes 7:
Function isTokenInStr(tokenStr As String, strToSearch As String) As Boolean
isTokenInStr = True
Dim tokenArr As Variant
tokenArr = Split(tokenStr, " ")
Dim idxTokenArr As Integer
For idxTokenArr = LBound(tokenArr) To UBound(tokenArr)
Dim tokenElementStr As String
tokenElementStr = tokenArr(idxTokenArr)
If InStr(strToSearch, tokenElementStr) <= 0 Then
isTokenInStr = False
Exit For
End If
next
End Function
I have created a windows application using list.asmx (getlistitems method) to download documents from a document library which is on another server. I am able to access document names, url, etc. When I use following code to download a file, it is returning html of the login page as content of each file that I am trying to download.
Any thoughts?
Dim spAuthentication As New Authentication()
spAuthentication.Url = authenticationWSAddress
spAuthentication.CookieContainer = New CookieContainer()
Dim spLists As New Lists()
spLists.Url = listWSAddress
'Try to login to SharePoint site with Form based authentication
Dim loginResult As LoginResult = spAuthentication.Login(userName, password)
Dim cookie As New Cookie()
'If login is successfull
If loginResult.ErrorCode = LoginErrorCode.NoError Then
'Get the cookie collection from the authenticatin web service
Dim cookies As CookieCollection = spAuthentication.CookieContainer.GetCookies(New Uri(spAuthentication.Url))
'Get the specific cookie which contains the security token
cookie = cookies(loginResult.CookieName)
'Initialize the cookie container of the list web service
spLists.CookieContainer = New CookieContainer()
'set the cookie of list web service to the authenticatio cookie
spLists.CookieContainer.Add(cookie)
'Dim responseNode As XmlNode = spLists.GetListCollection()
'response = responseNode.InnerXml
Dim query As String = "<mylistitems><Query><Where><Eq><FieldRef Name='FileDirRef' /><Value Type='Url'>DocLib/Property Documents/BELASERA AT FULTON (lax10027)/Master Meter Invoices</Value></Eq></Where></Query><QueryOptions><ViewAttributes Scope='RecursiveAll' IncludeRootFolder='False' /><IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls><ViewFields><FieldRef Name='EncodedAbsUrl'/></ViewFields></QueryOptions></mylistitems>"
Dim doc As New XmlDocument()
doc.LoadXml(query)
Dim dt As DataTable = Nothing
Dim queryNode As XmlNode = doc.SelectSingleNode("//Query")
Dim viewNode As XmlNode = doc.SelectSingleNode("//ViewFields")
Dim optionNode As XmlNode = doc.SelectSingleNode("//QueryOptions")
Dim retNode As XmlNode = spLists.GetListItems("DocLib", String.Empty, queryNode, viewNode, String.Empty, optionNode, Nothing)
Dim ds As New DataSet()
Using sr As New StringReader(retNode.OuterXml)
ds.ReadXml(sr)
End Using
If ds.Tables("Row") IsNot Nothing AndAlso ds.Tables("Row").Rows.Count > 0 Then
dt = ds.Tables("Row").Copy()
For Each myrow As DataRow In dt.Rows
' myrow.Item(0) contains url of the document
If myrow.Item(0) IsNot Nothing AndAlso myrow.Item(0) <> "" Then
DownLoadAttachmentold(myrow.Item("ows_EncodedAbsUrl"), RemoveLookupID(myrow.Item("ows_FileLeafRef")))
End If
Next
End If
Public Shared Sub DownLoadAttachment(ByVal strURL As String, ByVal strFileName As String)
Dim myWebClient As New WebClient()
Dim DestinationFolder As String = "C:\\DownLoads\\"
Form2.RTBStatus.AppendText("Downloading File " + strFileName + " from " + strURL + " .......")
' The DownloadFile() method downloads the Web resource and saves it into the current file-system folder.
myWebClient.DownloadFile(strURL, DestinationFolder + strFileName)
'Form2.RTBStatus.AppendText("Successfully Downloaded file ""{0}"" from ""{1}""", "C:\\DownLoads\\" + strFileName, strURL)
Form2.RTBStatus.AppendText((ControlChars.Cr + "Downloaded file saved in the following file system folder:" + ControlChars.Cr + ControlChars.Tab + DestinationFolder))
End Sub
DownloadAttachment also needs to make (forms-based) authenticated HTTP requests.
An example in C# below:
request = (HttpWebRequest)WebRequest.Create(strURL);
request.Credentials = System.Net.CredentialCache.DefaultCredentials;//adapt for your FBA
request.AllowWriteStreamBuffering = false;
response = (HttpWebResponse)request.GetResponse();
Stream s = response.GetResponseStream();
FileStream fs = new FileStream(#"C:\DownLoads\"+strFileName, FileMode.Create);
I'm trying to call AlterTask on a newly created Sharepoint task to add extended properties to my task, and a NotSupportedException is thrown.
What's going on?
The newly created task is actually a SharePoint ListItem. ExtendedProperties is specifically a Workflow Task property.
As per the MSDN documentation:
The content type of the item passed to the task parameter is not derived from the WorkflowTask content type.
This means that Content Type of the SPListItem that represents your new Task must be set to "Workflow Task" before the AlterTask method can be called on it:
Dim selectedTaskList As SPList = web.Lists(taskListName)
' Create a new task item
Dim newTask As SPListItem = selectedTaskList.Items.Add()
' Turn the new task item into a Workflow Task
Dim newTaskContentType As Microsoft.SharePoint.SPContentType = web.AvailableContentTypes("Workflow Task")
newTask("ContentTypeId") = newTaskContentType.Id
' Now the AlterTask method will work. (assume you've alreade declared a hashtable of properties to set)
Microsoft.SharePoint.Workflow.SPWorkflowTask.AlterTask(newTask, myHashTable, True)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim IntItemID As Integer
Dim siteId As Guid = SPContext.Current.Site.ID
Dim webId As Guid = SPContext.Current.Web.ID
Using objSpSite As New SPSite(siteId)
Using objSpWeb As SPWeb = objSpSite.OpenWeb(webId)
If Not Page.Request.QueryString("ItemID") Is Nothing And Page.Request.QueryString("ItemID") <> "" Then
IntItemID = CInt(Page.Request.QueryString.Item("ItemID").ToString)
Panel1.Visible = False
txtID.Text = IntItemID.ToString
Dim objList As SPList = objSpWeb.Lists("RequestList")
Dim objListItem As SPListItem = objList.Items.GetItemById(IntItemID)
dtPermission.SelectedDate = objListItem("PermissionDate")
dtTimeFrom.SelectedDate = objListItem("PermissionFromTime")
dtTimeTo.SelectedDate = objListItem("PermissionToTime")
cmbType.SelectedValue = objListItem("PermissionType")
'dtCreated.SelectedDate = objListItem("")
Else
IntItemID = 0
txtID.Text = "New"
dtCreated.SelectedDate = Today
txtCreatedBy.Text = objSpWeb.CurrentUser.Name
Dim objServiceContext As SPServiceContext = SPServiceContext.GetContext(objSpSite)
Dim objUserProfileManager As New UserProfileManager(objServiceContext)
Dim objUserProfile As UserProfile
Dim strUserAccount As String
strUserAccount = objSpWeb.CurrentUser.LoginName.Replace("i:0#.w|", "")
If objUserProfileManager.UserExists(strUserAccount) Then
objUserProfile = objUserProfileManager.GetUserProfile(strUserAccount)
Try
txtManager.Text = objUserProfile.GetManager.AccountName
Catch ex As Exception
txtManager.Text = ex.Message
End Try
End If
Panel2.Visible = False
End If
End Using
End Using
End Sub
Protected Sub cmdSubmit_Click(sender As Object, e As EventArgs) Handles cmdSubmit.Click
Dim siteId As Guid = SPContext.Current.Site.ID
Dim webId As Guid = SPContext.Current.Web.ID
Using objSpSite As New SPSite(siteId)
Using objSpWeb As SPWeb = objSpSite.OpenWeb(webId)
objSpWeb.AllowUnsafeUpdates = True
Dim list As SPList = objSpWeb.Lists("RequestList")
Dim item As SPListItem = list.Items.Add()
item("PermissionDate") = dtPermission.SelectedDate
item("PermissionFromTime") = dtTimeFrom.SelectedDate
item("PermissionToTime") = dtTimeTo.SelectedDate
item("PermissionType") = cmbType.SelectedValue
item("PermissionApprover1") = txtManager.Text
item.Update()
list.Update()
objSpWeb.AllowUnsafeUpdates = False
End Using
End Using
End Sub
Protected Sub cmdApprove_Click(sender As Object, e As EventArgs) Handles cmdApprove.Click
Dim siteId As Guid = SPContext.Current.Site.ID
Dim webId As Guid = SPContext.Current.Web.ID
Using objSpSite As New SPSite(siteId)
Using objSpWeb As SPWeb = objSpSite.OpenWeb(webId)
Dim objList As SPList = objSpWeb.Lists("RequestList")
Dim objListItem As SPListItem = objList.Items.GetItemById(CInt(txtID.Text))
Dim objWFTask As SPWorkflowTask = objListItem.Tasks(0)
If objWFTask Is Nothing Then
' no matching task
Return
End If
' alter the task
Dim ht As New Hashtable()
ht("Status") = "Complete"
ht("PercentComplete") = 1.0F
SPWorkflowTask.AlterTask(TryCast(objWFTask, SPListItem), ht, True)
End Using
End Using