Sending text from Excel VBA to ServiceNow Text Area

Farcal
Kilo Explorer
 

Hello Everyone!

I'm trying to fill out text area in ServiceNow using VBA

So far I've been successfully using this method and this exact (excluding site's tittle and text area ID) code to fill out text area in different ticketing tool, however in ServiceNow it's not doing anything for some reason.

it does seem to hook into the page just fine, as I can get the return value on the tittle (opening new IE instance with VBA and hooking to it also haven't helped), but while trying to set a value of text area (description field, or any other for that matter) it doesn't send any text over + it also doesn't return any value for any of the other ID's on the web page.

I've tried doing it in few different ways like using .innerHTML, .Value and .text but none seem to either send or return any value, setting it as an object, sending it with pure IE.document.getElementById("incident.comments").value = "test" but to no anvil.

Any pointers on what I might be doing wrong would be greatly appreciated.

Sub Test()

    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")



    marker = 0
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For X = 0 To (IE_count - 1)
    On Error Resume Next
    my_url = objShell.Windows(X).document.Location
    my_title = objShell.Windows(X).document.Title

    If my_title Like "INC0010005" & "*" Then
        Set IE = objShell.Windows(X)
        marker = 1
        Exit For
    Else
    End If
Next


If marker = 0 Then
    MsgBox ("Website not found")
    Exit Sub
End If


'trying to send "test" text into the field, nothing comes up
   Set notesObj = IE.document.getElementById("incident.comments")
   notesObj.Value = "test"

   tests = IE.document.getElementById("incident.comments").innerHTML

'testing for return value (comes up as empty message box each time)
   MsgBox (tests)


Set evt = IE.document.createEvent("keyboardevent")
evt.initEvent "change", True, False
    notesObj.dispatchEvent evt

End Sub
3 REPLIES 3

vkachineni
Kilo Sage
Kilo Sage

Personal opinion: I would recommend using webservices to communicate with ServiceNow.

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Hello vkachineni, could you please point me to how could I go about that?

(preferably just about putting a text into the text area, that's literally the only thing I need at the moment)

 

Thanks in advance

Not a VBA expert but may be this link would point in the right direction. https://social.msdn.microsoft.com/Forums/expression/en-US/bc445ec5-6514-4da3-9101-7ef1a3c3fbd6/how-to-do-crud-operations-using-rest-api-from-excel-vba-?forum=sharepointdevelopment
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022