JIRA SOAP in VBA how to get created issue key

keram December 5, 2012

Hi I created an Issue via SOAP using VBA,

(I used the code written By fabby chen https://answers.atlassian.com/questions/75585/create-jira-issues-using-vba-in-excel)

But unfortunately I don't know how to receive the created issue KEY.

Sub CreateJiraIssue()

Dim token As Variant
Dim newissue As Variant
Dim issuemap As Variant

Dim SoapClient
Set SoapClient = CreateObject("MSSOAP.SoapClient30")
SoapClient.mssoapinit ("https://jira_instance/rpc/soap/jirasoapservice-v2?wsdl")


token = SoapClient.LogIn("jirauser", "password")

If Err <> 0 Then
wscript.echo "initialization failed " + Err.description
End If

Dim new_xmlText, update_xmlText As String
 
new_xmlText = "<root>" & _
              "<assignee>" & "user" & "</assignee>" & _
              "<project>" & "PROJECT1" & "</project>" & _
              "<type>" & "1" & "</type>" & _
              "<summary>" & "TEST TICKET " & "</summary>" & _
            "<description>" & "this ticket was created remotely via SOAP using VBA code." & "</description>" & _
            "<customFieldValues>" & _
                    "<RemoteCustomFieldValue>" & _
                        "<customfieldId>customfield_10002</customfieldId>" & _
                        "<values><string>" & "XXX" & "</string></values>" & _
                    "</RemoteCustomFieldValue>" & _
                    "<RemoteCustomFieldValue>" & _
                        "<customfieldId>customfield_10001</customfieldId>" & _
                        "<values><string>" & "XXX" & "</string></values>" & _
                    "</RemoteCustomFieldValue>" & _
                 "</customFieldValues>" & _
          "</root>"
           
Dim new_xmlDoc As New MSXML2.DOMDocument30
 
new_xmlDoc.async = False
new_xmlDoc.LoadXml (new_xmlText)
If (new_xmlDoc.parseError.ErrorCode <> 0) Then
  Dim myErr
  Set myErr = new_xmlDoc.parseError
  MsgBox (myErr.reason)

End If

Dim new_XMLNodeList As MSXML2.IXMLDOMNodeList
Dim new_root As MSXML2.IXMLDOMElement
 
Set new_root = new_xmlDoc.DocumentElement
Set new_XMLNodeList = new_root.ChildNodes


Set newissue = SoapClient.createIssue(token, new_XMLNodeList)

End Sub

anyone knows how to get the Key of the issue created?

2 answers

1 accepted

0 votes
Answer accepted
keram December 19, 2012

Hi

I just figured it out:

Dim read_XMLNodeList As MSXML2.IXMLDOMNodeList
Dim issueKey As String

Set read_XMLNodeList = newissue
issueKey = read_XMLNodeList(15).Text

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2012

Doesn't this work: newissue.getKey() ?

keram December 6, 2012

No it doesn't.

It works that way in Java, but unfortunately not in VBA :/

keram December 6, 2012

newissue is declared as Variant,

when I declare it as RemoteIssue, program fails.

Suggest an answer

Log in or Sign up to answer