Save document

Hi,

I’m trying to save records from excel as document in the database. The problem is with saving it under different documents. For eg in excel I have no as 123XX and in the database suppose already there are documents like 12304, 12306 and 12308, then while saving I set variable doc to contain data from excel. Other variable doc1 to contain first document 12304 and doc is made response of doc1. After saving this doc.save I loop into next value from database 12306. But in lotus script the doc gets overwritten and when I checked the documents found the excel records in last document only - 12308.

How to solve this problem any help its urgent.

Subject: Save document

Post your code

Subject: RE: Save document

My code is as follows

				For p=0 To 10

					If ClaimNo <> "" Then claim=ClaimNo

					Set doc1=GetParentClaim(claim,item1.Text)

					If Not doc1 Is Nothing Then

						Set claimitem = doc1.GetFirstItem("insured")

						Call doc.ReplaceItemValue("insured", claimitem.Text)

						If item.Text <> ClaimNo Then

							Call doc.ReplaceItemValue("leadclaim", ClaimNo)

						End If

						Call doc.MakeResponse( doc1 )	

						Call doc.Save(True, True)

					End If

				Next

In function GetparentClaim I get the doc1 for that claim. Like I said in earlier mail if I have 3 records in database, then the data from excel should be saved in all three.

Hope now it makes sense.

Subject: RE: Save document

OK, I’m not quite sure what you are trying to achieve but I don’t see you setting doc to anything in your code - I can only assume that it is set in some code further up that you have not posted. But in any case, when you say:

Call doc.MakeResponse( doc1 )

doc1 will become the parent of doc. Since doc is never set to anything new within the code you’ve shown, and doc1 changes (perhaps?) within the For…Next loop, you are changing the parent of doc to a new doc1. Recall that there is no such thing as multiple inheritance when it comes to parent-child doc relationships.

Subject: RE: Save document

Here is the code and now it should be clear

            'Create a new doc

			Set doc = db.CreateDocument

			doc.Form = formname

			

			For i = 1 To cols

				If fd(i) = "Leadclaim" Then

					classclaim=xlsSheet.Cells(row, i).Text

					claim = xlsSheet.Cells(row, i).Text

					Set item = doc.ReplaceItemValue(fd(i), claim)

					Set item1 = item

				Elseif fd(i) = "Subject" Then

					Select Case Cstr(xlsSheet.Cells(row, i).Text)

					Case "000" Or "00"

						sSubject = "All"

					Case "010" Or "10"

						sSubject = "Coverage"

					Case "020" Or "20"

						sSubject = "Contact"

					Case "030" Or "30"

						sSubject = "Investigation"

					Case "040" Or "40"

						sSubject = "Negotiation"

					Case "050" Or "50"

						sSubject = "Litigation"

					Case "060" Or "60"

						sSubject = "Supervisory"

					Case "070" Or "70"

						sSubject = "Medical Info"

					Case "080" Or "80"

						sSubject = "Reinsurance"

					Case "090" Or "90"

						sSubject = "Subrogation"

					Case "110"

						sSubject = "Reserves"

					Case "500"

						sSubject = "Reports"

					Case "120"

						sSubject = "Disability"

					Case "100"

						sSubject = "Other"

					End Select

					Set item = doc.ReplaceItemValue(fd(i), sSubject)

				Elseif fd(i) = "Note_Date" Then

					ndate = Format(xlsSheet.Cells(row, i).Text, "mm/dd/yyyy")

					Set item = doc.ReplaceItemValue(fd(i), Cdat(ndate))

				Else

					Set item = doc.ReplaceItemValue(fd(i), xlsSheet.Cells(row, i).Value)

					If item.Text="" Then

						If row=3858 Or row=7869 Or row=10078 Or row=10660 Or row=11406 Or row=16125 Or row=16538 Or row=19324 Or row=22181 Or row=22358 Or row=22371 Or row=22444 Or row=22458 Or row=24631 Or row=24867 Or row=25120 Or row=25122 Then

							Set item = doc.ReplaceItemValue(fd(i), GetNoteFromText(Mid(claim,1,10),row))

						End If

					End If

				End If

			Next

			

			'Set From_Class field to Yes

			Call doc.ReplaceItemValue("FROM_CLASS", "YES")

			suffix=Mid(classclaim, 11)

			Call doc.ReplaceItemValue("CLASS_ClaimNumber", classclaim)

			Call doc.ReplaceItemValue("CLASS_Suffix", suffix)

			

			Dim vew As NotesView

			Dim dc As NotesDocumentCollection

			Dim doc1 As NotesDocument

			Set view = db.getview("UniqueView")

			Set dc = view.GetAllDocumentsByKey(item1.Text, False)

			Set doc1 = dc.GetFirstDocument()

			If dc.Count > 0 Then

				Set claimitem = doc1.GetFirstItem("insured")

				Call doc.ReplaceItemValue("insured", claimitem.Text)

				If item.Text <> claim Then

					Call doc.ReplaceItemValue("leadclaim", claim)

				End If

				Call doc.MakeResponse( doc1 )

				Call doc.Save(True, True)					

			Else

				laststr=Mid(claim,11)

				If laststr <> "AL" And laststr <> "XX" And laststr <> "00" Then Goto NextClaim

				For p=0 To 10

					If ClaimNo <> "" Then claim=ClaimNo

					Set doc1=GetParentClaim(claim,item1.Text)

					If Not doc1 Is Nothing Then

						Set claimitem = doc1.GetFirstItem("insured")

						Call doc.ReplaceItemValue("insured", claimitem.Text)

						If item.Text <> ClaimNo Then

							Call doc.ReplaceItemValue("leadclaim", ClaimNo)

						End If

						Call doc.MakeResponse( doc1 )	

						Call doc.Save(True, True)

					End If

				Next

			End If

			

		End If

Subject: RE: Save document

“and now it should be clear”

Hmmm - not really, but anyway…

What is the problem? Are you trying to have multiple values stored in the field of doc and these values are coming from multiple cells in the Excel file? If so, then you should not use ReplaceItemValue because that is going to do precisely what the method name implies - it will replace whatever value is in the item currently with the new value.

And I continue to have doubts about using

Call doc.MakeResponse( doc1 )

within a For…Next Loop where doc1 has the potential to change (can’t tell from your code whether it actually does) and where doc never changes. Certainly the only thing that will ever achieve is that doc will become the child of the last doc1 that was set within the For…Next Loop - are you sure that is what you intend to do?

Subject: RE: Save document

I want doc to be child of every doc1 that is listed in the database. I don’t want it to be child of last doc1.

Subject: RE: Save document

Please read what I had previously posted in this response:

http://www-10.lotus.com/ldd/nd6forum.nsf/DateAllFlatweb/0f616ed8cd91548d852573920078acaf?OpenDocument

"Recall that there is no such thing as multiple inheritance when it comes to parent-child doc relationships. "

Or in other words, a document can have at most one parent.