Click here to Skip to main content
15,889,403 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionlistItem to show text box Pin
byka20-Oct-14 7:04
byka20-Oct-14 7:04 
GeneralSort methodes idees wanted Pin
JR21220-Oct-14 1:09
JR21220-Oct-14 1:09 
GeneralRe: Sort methodes idees wanted Pin
Richard Deeming20-Oct-14 1:58
mveRichard Deeming20-Oct-14 1:58 
GeneralRe: Sort methodes idees wanted Pin
Eddy Vluggen20-Oct-14 1:59
professionalEddy Vluggen20-Oct-14 1:59 
AnswerRe: Sort methodes idees wanted Pin
Manfred Rudolf Bihy20-Oct-14 2:24
professionalManfred Rudolf Bihy20-Oct-14 2:24 
GeneralRe: Sort methodes idees wanted Pin
JR21221-Oct-14 0:29
JR21221-Oct-14 0:29 
GeneralRe: Sort methodes idees wanted Pin
Manfred Rudolf Bihy21-Oct-14 0:52
professionalManfred Rudolf Bihy21-Oct-14 0:52 
QuestionHelp needed creating a form based on a vbscript Pin
Malbordio19-Oct-14 6:25
Malbordio19-Oct-14 6:25 
I have a vbscript that creates automatically a incident in ServiceNow. Tested and it works.
But I wish to make it more practical and funcional. I am looking for a form based on this vbscript in order to create the incident.
Can you guys help me compiling a form based on the vbscript I am posting bellow? Many thanks.

Option Explicit

Const gServiceNowUser = "username"
Const gServiceNowPass = "password"
Const gServiceNowURL = "https://domain.service-now.com/"
Class ServiceNowDirectWS
' Use this class to call ServiceNow Direct Web Services functions
' For documentation on the Direct WS API see:
' http://wiki.servicenow.com/index.php?title=Direct_Web_Service_API_Functions

Dim sEndpointURL, sTableName, sMethod, sResponsePath
Dim oWSRequest, oWSRequestDoc, oWSResponseDoc
Dim oWSRequestEnvelope, oWSRequestBody, oWSRequestOperation

Public Sub SetMethod (tableName, method)
' This function must be called BEFORE Post to initialize the class
' method must be "insert", "update", "getKeys", "get" or "getRecords"
sTableName = tableName
sMethod = method
sResponsePath = "/soap:Envelope/soap:Body/" & sMethod & "Response/"
sEndpointURL = gServiceNowURL & sTableName & ".do?SOAP"
If (sMethod = "get" Or sMethod = "getRecords") Then
sEndpointURL = sEndpointURL & "&displayvalue=all"
End If
Set oWSRequest = CreateObject("MSXML2.XMLHTTP")
Set oWSRequestDoc = CreateObject("MSXML2.DOMDocument")
Set oWSRequestEnvelope = oWSRequestDoc.createElement("soap:Envelope")
oWSRequestEnvelope.setAttribute "xmlns:soap", _
"http://schemas.xmlsoap.org/soap/envelope/"
Set oWSRequestBody = oWSRequestDoc.createElement("soap:Body")
Set oWSRequestOperation = oWSRequestDoc.createElement("tns:" & sMethod)
oWSRequestOperation.setAttribute "xmlns:tns", _
"http://www.service-now.com/" & sTableName
oWSRequestDoc.appendChild oWSRequestEnvelope
oWSRequestEnvelope.appendChild oWSRequestBody
oWSRequestBody.appendChild oWSRequestOperation
End Sub

Public Function Post
' This function does the actual Web Services call
' It returns True if the call is successful and False if there is an error
oWSRequest.open "POST", sEndpointURL, False, gServiceNowUser, gServiceNowPass
oWSRequest.setRequestHeader "Content-Type", "text/xml"
oWSRequest.send oWSRequestDoc.xml
If oWSRequest.status = 200 Then
Set oWSResponseDoc = CreateObject("MSXML2.DOMDocument")
oWSResponseDoc.loadXML oWSRequest.responseText
oWSResponseDoc.setProperty "SelectionLanguage", "XPath"
oWSResponseDoc.setProperty "SelectionNamespaces", _
"xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"
Post = True
Else
Set oWSResponseDoc = Nothing
Post = False
End if
End Function

Public Function Status
' If Post returns False then call this function to obtain the HTTP status code
Status = oWSRequest.status
End Function

Public Function StatusText
' If Post returns False then call this function for the error text
StatusText = oWSRequest.statusText
End Function

Public Sub SetValue(fieldname, fieldvalue)
' This function must be called BEFORE Post
Dim oChild
Set oChild = oWSRequestDoc.createElement(fieldname)
oChild.appendChild(oWSRequestDoc.createTextNode(fieldvalue))
oWSRequestOperation.appendChild(oChild)
End Sub

Public Function GetValue(fieldname)
' This function must be called AFTER Post
' If method is "insert" then it can be used to obtain the sys_id of the inserted record
' If method is "get" then it can be used to obtain any field from the record
GetValue = oWSResponseDoc.selectSingleNode(sResponsePath & fieldname).text
End Function

Public Function GetRowCount
' This function may be called after Post if the method is "getRecords"
' It returns the number of records in the result set
Dim sResultsPath, oNodeset
sResultsPath = sResponsePath & "getRecordsResult"
Set oNodeSet = oWSResponseDoc.selectNodes(sResultsPath)
getRowCount = oNodeSet.length
End Function

Public Function GetRowValue(rownum, fieldname)
' This function may be called after Post if the method is "getRecords"
' It returns a single field from a single record
Dim sRowPath, sFieldPath
sRowPath = sResponsePath & "getRecordsResult[" & rownum & "]/"
sFieldPath = sRowPath & fieldname
GetRowValue = oWSResponseDoc.selectSingleNode(sFieldPath).text
End Function

End Class

' Specify the ticket values
Dim wsInsertIncident : Set wsInsertIncident = New ServiceNowDirectWS
wsInsertIncident.SetMethod "incident", "insert"
wsInsertIncident.SetValue "short_description", "Incident Test"
wsInsertIncident.SetValue "description", "Incident Test"
wsInsertIncident.SetValue "caller_id", "My Username"
wsInsertIncident.SetValue "u_category", "Category Name"
wsInsertIncident.SetValue "u_subcategory", "Sub Category Name"
wsInsertIncident.SetValue "u_masiva", "Massive"

' Perform the insert and check the status
If Not wsInsertIncident.Post Then
WScript.Echo "Error=" & wsInsertIncident.Status
WScript.Echo wsInsertIncident.StatusText
WScript.Quit
End If

Dim strIncidentSysId, strIncidentNumber
strIncidentSysId = wsInsertIncident.GetValue("sys_id")
strIncidentNumber = wsInsertIncident.GetValue("number")
WScript.Echo "Inserted: " & strIncidentNumber
AnswerRe: Help needed creating a form based on a vbscript Pin
Dave Kreskowiak23-Oct-14 10:00
mveDave Kreskowiak23-Oct-14 10:00 
Questionhow to open password protected .pdf file in vb 6.0 Pin
kirtitripathy17-Oct-14 21:25
kirtitripathy17-Oct-14 21:25 
AnswerRe: how to open password protected .pdf file in vb 6.0 Pin
Dave Kreskowiak18-Oct-14 4:34
mveDave Kreskowiak18-Oct-14 4:34 
QuestionHow to search in a List (of structure) Pin
dilkonika14-Oct-14 4:52
dilkonika14-Oct-14 4:52 
AnswerRe: How to search in a List (of structure) Pin
Eddy Vluggen14-Oct-14 5:39
professionalEddy Vluggen14-Oct-14 5:39 
QuestionVBScript Connect to Database across Internet Pin
JM7613-Oct-14 4:22
JM7613-Oct-14 4:22 
AnswerRe: VBScript Connect to Database across Internet Pin
Eddy Vluggen13-Oct-14 7:34
professionalEddy Vluggen13-Oct-14 7:34 
GeneralRe: VBScript Connect to Database across Internet Pin
JM7613-Oct-14 7:39
JM7613-Oct-14 7:39 
GeneralRe: VBScript Connect to Database across Internet Pin
Eddy Vluggen13-Oct-14 8:23
professionalEddy Vluggen13-Oct-14 8:23 
GeneralRe: VBScript Connect to Database across Internet Pin
JM7613-Oct-14 9:12
JM7613-Oct-14 9:12 
GeneralRe: VBScript Connect to Database across Internet Pin
Eddy Vluggen13-Oct-14 10:42
professionalEddy Vluggen13-Oct-14 10:42 
AnswerRe: VBScript Connect to Database across Internet Pin
Bernhard Hiller19-Oct-14 22:42
Bernhard Hiller19-Oct-14 22:42 
GeneralRe: VBScript Connect to Database across Internet Pin
JM7620-Oct-14 6:09
JM7620-Oct-14 6:09 
QuestionBind a listbox to a list of structure Pin
dilkonika11-Oct-14 8:40
dilkonika11-Oct-14 8:40 
AnswerRe: Bind a listbox to a list of structure Pin
Mycroft Holmes11-Oct-14 15:33
professionalMycroft Holmes11-Oct-14 15:33 
QuestionAdd Open with functionality to vb6.0 application Pin
Otekpo Emmanuel10-Oct-14 6:49
Otekpo Emmanuel10-Oct-14 6:49 
AnswerRe: Add Open with functionality to vb6.0 application Pin
CHill6010-Oct-14 6:55
mveCHill6010-Oct-14 6:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.