我正在尝试在运行vbscript时检索事件引用号。该脚本在代码中打开带有脚本票证值的票证,但它返回以下错误:错误:必要对象:'oWSResponseDoc.selectSingleNode(...)'
我正在使用的代码是
' 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
我知道这在过去有效,但今天却没有。我不知道发生了什么变化。完整的脚本可以在这里看到:
你能帮帮我吗?非常感谢!答案 0 :(得分: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!"