parsing XML via script

  • Thread starter Chad A. Gross [SBS MVP]
  • Start date
C

Chad A. Gross [SBS MVP]

Hi all -

I've got an InfoPath (SP1) form used for collecting product sample requests.
Currently, we need to generate an email to send to the vendor so that they
can fulfil the sample request, which we want to happen when the form is
submitted (to a Sharepoint form library). There are only a handful of
fields that we need in the body of the email - and I've put together a
vbscript to do this (thanks in no small part to Google :^). So far in
testing, it works
great with one exception - if I have 3 samples, the body of the email will
show the sample info for the first sample 3 times, instead of showing each
of the three samples once. For example, if I have the following data:
1(qty) Item_1
2 Item_2
3 Item_3

I want my email body to look like:

Qty 1
Item Item_1

Qty 2
Item Item_2

Qty 3
Item Item_3

But I get:

Qty 1
Item Item_1

Qty 1
Item Item_1

Qty 1
Item Item_1


I'm hoping there's something simple/obvious that I'm just not seeing. Any
assistance is greatly appreciated! Here's my script:

*************************************************************
Sub XDocument_OnSubmitRequest(eventObj)

Dim oSharepoint
Dim oEmail
Dim objApp
Dim objMail
Dim objXMLNodes
Dim objXMLNode
Dim oItem
Dim mailBody

'email
Set objApp = CreateObject("Outlook.Application")
Set objMail = objApp.CreateItem(olMailItem)
set objXMLNode = XDocument.DOM.selectSingleNode("/my:myFields/my:group14")
set objXMLNodes =
objXMLNode.selectNodes("/my:myFields/my:group14/my:LineItem")

mailBody = ""
If objXMLNodes.length > 0 Then
For Each oItem in objXMLNodes
mailBody = mailBody & "Qty: " &
oItem.selectSingleNode("//my:Qty").text & "<br>"
mailBody = mailBody & "Item: " &
oItem.selectSingleNode("//my:ItemNo").text & "<br>"
mailBody = mailBody & "<br>"
Next
End If

objMail.HTMLBody = mailBody
objMail.subject = "Sample Request"
objMail.Display()

set oSharepoint = XDocument.DataAdapters("Main submit")
oSharepoint.Submit

eventObj.ReturnStatus = True

End Sub

--

Chad A. Gross - SBS MVP
SBS ROCKS!

www.msmvps.com/cgross
www.gosbs.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top