2017-08-11 92 views
-2

我試圖在運行vbscript時檢索到事件參考號。該腳本打開與代碼中的腳本票值的車票,但它返回以下錯誤:錯誤:必需的對象:「oWSResponseDoc.selectSingleNode(...)」當我運行vbscript時沒有收到事件參考號

我使用的代碼是

' 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 

我知道這在過去的工作,但今天它沒有。我不知道發生了什麼變化。完整的腳本可以在這裏看到:

https://servicenowsoap.wordpress.com/2013/10/26/vb-script/

你能幫幫我嗎?非常感謝!

+0

有沒有你正試圖解決的特定情況?避免vbscript可能會更好。 – Kirk

+0

我試圖解決的具體情況實際上就是這一個,cap kirk!我喜歡很多vbscript。 – Malbordio

回答

0

在插入事件之前,您需要使用SetMethod函數。這用於確定進行Web通話時要執行的操作。

我在一個演示實例上測試了它,並創建了事件並返回了一個數字。

' Specify the ticket values 
Dim wsInsertIncident : Set wsInsertIncident = New ServiceNowDirectWS 
wsInsertIncident.SetMethod "incident", "insert" 
wsInsertIncident.SetValue "short_description", "Demo WS Incident" 
wsInsertIncident.SetValue "description", "Demo WS Incident" 
wsInsertIncident.SetValue "caller_id", "Abel Tuter" 
wsInsertIncident.SetValue "category", "hardware" 
wsInsertIncident.SetValue "subcategory", "mouse" 

' 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 

Dim objShell : Set objShell = Wscript.CreateObject("Wscript.Shell") 
objShell.Popup "Inserted: " & strIncidentNumber,, "ServiceNow ticket!" 
+0

感謝您的幫助。我知道這個事件已經創建,但是你有沒有彈出的窗口號碼?我沒有得到這一點。我直接運行的VBScript。你有沒有通過使用PowerShell的? – Malbordio

+0

是的,只是從powershell。沒有彈出窗口,只是在控制檯的輸出中。如果你直接運行它,你需要一個彈出窗口。我已經添加了幾行來做一個彈出如果有幫助 – Kirk

+0

對不起,仍然是相同的錯誤,仍然沒有彈出。 你試圖在你已經有回聲的同時包含一個彈出窗口,是嗎? 感謝您的幫助! – Malbordio