This agent scans through the document and creates a report based on the id searched on. I have many lines in the document ( ex part1, part2, part3, desc1, desc2, desc3…) but some of the fields only appear once no matter how many lines are in the document ( company name, sales engineer…those are only once per document). I’m having a problem showing values in the document. Those don’t have the +i in the script. Could someone let me know what it wrong here? Thanks!
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument, doc2 As NotesDocument
Set db = session.CurrentDatabase
Dim collection As NotesDocumentCollection
Dim part(300) As String,cuspart(300) As String,partdesc(300) As String,company_name(300) As String
Dim visualcustomerid(300) As String,sales_engineer(300) As String,sprice(300) As String,um(300) As String
Dim slocation(300) As String,minv(300) As String,maxv(300) As String,leadtime(300) As String
Dim agreeid(300) As String,searchstat(300) As String,acceptedsearchdate(300) As String
x = 0
searchString$ = Inputbox("Enter ID to Search For")
Set collection = db.FTSearch(searchString$, 0)
If collection.Count > 0 Then
Set doc2 = db.CreateDocument
doc2.form = "Part Report"
doc2.partid = searchString$
Set doc = collection.GetFirstDocument
Do Until doc Is Nothing
For i = 1 To 40
partid = doc.GetItemValue("part"+i)
If partid(0) = searchString$ Then
temp1 = doc.GetItemValue("agreeid")
agreeid(x) = temp1(0)
temp2 = doc.GetItemValue("company_name")
company_name(x) = temp2(0)
temp3 = doc.GetItemValue("partdesc"+i)
partdesc(x) = temp3(0)
temp4 = doc.GetItemValue("cuspart"+i)
cuspart(x) = temp4(0)
temp5 = doc.GetItemValue("visualcustomerid")
visualcustomerid(x) = temp5(0)
temp6 = doc.GetItemValue("sales_engineer")
sales_engineer(x) = temp6(0)
temp7 = doc.GetItemValue("searchstat")
searchstat(x) = temp7(0)
temp8 = doc.GetItemValue("acceptedsearchdate")
acceptedsearchdate(x) = temp8(0)
temp9 = doc.GetItemValue("slocation"+i)
slocation(x) = temp9(0)
temp10 = doc.GetItemValue("um"+i)
um(x) = temp10(0)
temp11 = doc.GetItemValue("sprice"+i)
sprice(x) = temp11(0)
temp12 = doc.GetItemValue("maxv"+i)
maxv(x) = temp12(0)
temp13 = doc.GetItemValue("minv"+i)
minv(x) = temp13(0)
temp14 = doc.GetItemValue("leadtime"+i)
leadtime(x) = temp14(0)
x = x + 1
doc2.agreeid = Fulltrim(agreeid)
doc2.company_name = Fulltrim(company_name)
doc2.partdesc = Fulltrim(partdesc)
doc2.cuspart = Fulltrim(cusPart)
doc2.visualcustomerid = Fulltrim(visualcustomerid)
doc2.sales_engineer = Fulltrim(sales_engineer)
doc2.searchstat = Fulltrim(searchstat)
doc2.acceptedsearchdate = Fulltrim(acceptedsearchdate)
doc2.slocation = Fulltrim(slocation)
doc2.um = Fulltrim(um)
doc2.sprice = Fulltrim(sprice)
doc2.maxv = Fulltrim(maxv)
doc2.minv = Fulltrim(minv)
doc2.leadtime = Fulltrim(leadtime)
End If
Next
Set doc = collection.GetNextDocument(doc)
Loop
End If
End Sub