Cannot save with LotusScript - please see code here

The code below is supposed to update the Portal_Doc values that match the Import_Doc values. It check all the matching docs, based on MID_CCE_Commerce_ID field matching. This code works for 2 other forms, and sets of views. But with this form, it does not. This form has Formulas Inherit Field Values From Selected Documents set, which is different from the other forms that work. The problem is the Call Portal_Doc.Save(False,True) does not seem to save the updates. It never saves, unless I am missing something else. Any feedback is very welcome. Thanks

Sub Initialize

’ Dim newvalue As Variant

Set Session = New NotesSession



Set db = Session.CurrentDatabase

Set Import_View = db.GetView("CCE Data For Edit Imports")

Set Import_Doc = Import_View.GetFirstDocument

If Import_Doc Is Nothing Then 

	Msgbox ("CCE Data For Edit Imports view unavailable.")

	End

End If



Set Customer_View = db.GetView("CCE Data - Cat")

Set Portal_Doc = Customer_View.GetFirstDocument

If Portal_Doc Is Nothing Then 

	Msgbox ("CCE Data - Cat view unavailable.")

	End

End If



Do Until Portal_Doc Is Nothing

	Customer_ID_Hold = Portal_Doc.MID_CCE_Commerce_ID(0)			

	Set Import_Doc = Import_View.GetDocumentByKey(Customer_ID_Hold)	

ProcessThisID:

	If Not Import_Doc Is Nothing Then			

		If Customer_ID_Hold = Import_Doc.MID_CCE_Commerce_ID(0) Then		

			

	'	If Portal_ID_Hold = Import_Doc.MID_CCE_Commerce_ID(0) Then

	'		Print "Updating: "+ Portal_ID_Hold

			If Import_Doc.CCE_Hosting_Geo(0)  <> ""  Then newvalue1=  Import_Doc.CCE_Hosting_Geo(0)  

			If Import_Doc.CCE_Hosting_Geo(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( CCE_Hosting_Geo ,newvalue1)

			

			If Import_Doc.CCE_Geo(0)  <> "" Then newvalue2 =  Import_Doc.CCE_Geo(0) 

			If Import_Doc.CCE_Geo(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( CCE_Geo ,newvalue2)

	'[		If Import_Doc.CCE_Geo(0)  <> "" Then Print "CCE Geo Set" +newvalue2

			If Import_Doc.CCE_Country(0)  <> "" Then newvalue3 =  Import_Doc.CCE_Country(0) 

			If Import_Doc.CCE_Country(0)  <> ""   Then Set notesitem = Portal_Doc.ReplaceItemValue( CCE_Country ,newvalue3)

			'numeric

			If Import_Doc.CCEStoreID(0)  > 0 Then  newvalue4 =  Import_Doc.CCEStoreID(0)  

			If Import_Doc.CCEStoreID(0)  > 0  Then Set notesitem = Portal_Doc.ReplaceItemValue( CCEStoreID ,newvalue4)

			If Import_Doc.CommerceID(0)  <> "" Then newvalue5 =  Import_Doc.CommerceID(0) 				

			If Import_Doc.CommerceID(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( CommerceID ,newvalue5)

			If Import_Doc.LiveDate(0)  <> "" Then newvalue6 =  Import_Doc.LiveDate(0) 

			If Import_Doc.LiveDate(0)  <> "" Then Set notesitem = Portal_Doc.ReplaceItemValue( LiveDate ,newvalue6)

			

			If Import_Doc.IGS(0)  <> "" Then newvalue7 =  Import_Doc.IGS(0)  

			If Import_Doc.IGS(0)  <> ""   Then Set notesitem = Portal_Doc.ReplaceItemValue( IGS ,newvalue7)

			If Import_Doc.SWG(0)  <> "" Then  newvalue8 =  Import_Doc.SWG(0)  

			If Import_Doc.SWG(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( SWG ,newvalue8)

			If Import_Doc.PWS(0)  <>  "" Then newvalue9 =  Import_Doc.PWS(0)  

			If Import_Doc.PWS(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( PWS ,newvalue9)

			If Import_Doc.pSeries(0)  <> "" Then  newvalue10 =  Import_Doc.pSeries(0)  

			If Import_Doc.pSeries(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( pSeries ,newvalue10)

			If Import_Doc.xSeries(0)  <> "" Then newvalue11=  Import_Doc.xSeries(0)  

			If Import_Doc.xSeries(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( xSeries ,newvalue11)

			If Import_Doc.PCD(0)  <> ""  Then newvalue12 =  Import_Doc.PCD(0)  

			If Import_Doc.PCD(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( PCD ,newvalue12)

			If Import_Doc.Description(0)  <> "" Then  newvalue13 =  Import_Doc.Description(0)  

			If Import_Doc.Description(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( Description ,newvalue13)

			If Import_Doc.Description(0)  <> "" Then Print "should update : "+ newvalue13

			If Portal_Doc.Description(0) = "old" Then Messagebox "Check it out"

			If Import_Doc.SiteBranding(0)  <> "" Then  newvalue14 =  Import_Doc.SiteBranding(0) 

			If Import_Doc.SiteBranding(0)  <> "" Then Set notesitem = Portal_Doc.ReplaceItemValue( SiteBranding ,newvalue14)

			

			' do not edit Mid_CCE_Commerce_ID(0)

		'	If Import_Doc.MID_CCE_Commerce_ID(0)  > 0 Then newvalue15 =  Import_Doc.MID_CCE_Commerce_ID(0) 

		'	If Import_Doc.MID_CCE_Commerce_ID(0)  > 0 Then Set notesitem = Portal_Doc.ReplaceItemValue(MID_CCE_Commerce_ID ,newvalue15)

			

		'	Do not edit MIDPortalID				

		'	If Import_Doc.MIDPortalID(0)  <> "" Then  newvalue16 =  Import_Doc.MIDPortalID(0) 

		'	If Import_Doc.MIDPortalID(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( MIDPortalID ,newvalue16)

			

			If Import_Doc.SiteName(0)  <> "" Then newvalue17 = Import_Doc.SiteName(0)

			If Import_Doc.SiteName(0)  <> ""  Then Set notesitem = Portal_Doc.ReplaceItemValue( SiteName ,newvalue17)				

’ RICHTEXT FIELDS - NOT INCLUDED ***************

			Call Portal_Doc.Save(False,True)

’ End If ’ Walks thru docs

			Set Import_Doc = Import_View.GetNextDocument(Import_Doc) 

			

			If Not Import_doc Is Nothing Then ' Verifies that we found a matching Import document 

				If Customer_ID_Hold = Import_Doc.MID_CCE_Commerce_ID(0) Then

					Goto ProcessThisID

				End If

			End If

		End If   

	End If

'	Print "Processing: "+Portal_Doc.MID_CCE_Commerce_ID(0)

	

	

	Set Portal_Doc = Customer_View.GetNextDocument(Portal_Doc)		

	

	

	

	If Portal_Doc Is Nothing Then 

		Messagebox " Finished Import Edits "

		End

	End If

	

	Loop ' Walks Customer view to get next Customer ID doc

End Sub

Subject: cannot save with LotusScript - please see code here

Hi Scott,I don’t know whether the below code helps you or not. But give a try.

Copy the below code and paste it where ever you want:

Dim Session As NotesSession

Dim db As NotesDatabase

Dim vwCustomer As NotesView

Dim vwImport As NotesView

Dim CollImports As NotesDocumentCollection

Dim docImport As NotesDocument

Dim docPortal As NotesDocument	

Dim Key As String



On Error Goto ErrorHandle

Set Session 		= 	New NotesSession

Set db 				= 	Session.CurrentDatabase



Set vwImport		= 	db.GetView("CCE Data For Edit Imports")

Set vwCustomer	= db.GetView("CCE Data - Cat")

If vwImport Is Nothing Then Error 1000, "Unable to locate CCE Data For Edit Imports View"

If vwCustomer Is Nothing Then Error 1001, "Unable to locate CCE Data - Cat View "



Set docImport 	= 	vwImport.GetFirstDocument

Set docPortal		= 	vwCustomer.GetFirstDocument

If docImport Is Nothing Then Error 1002, "No documents Found in CCE Data For Edit Imports View"	

If docPortal Is Nothing Then Error 1003, "No documents found in CCE Data - Cat View"



Do Until docPortal Is Nothing

	Key = docPortal.MID_CCE_Commerce_ID(0) 

	Set CollImports = vwImport.GetAllDocumentsByKey(Key)

	If CollImports.Count = 0 Then 

		Msgbox "No Documents Found in CCE Data For Edit Imports view based on Key " & Key

	Else	

		Set docImport = CollImports.GetFirstDocument

		Do Until docImport Is Nothing

			With docImport

				If .CCE_Hosting_Geo(0) <> "" Then 		docPortal.CCE_Hosting_Geo	= .CCE_Hosting_Geo(0) 

				If .CCE_Geo(0) <> "" Then 					docPortal.CCE_Geo				= .CCE_Geo(0) 

				If .CCE_Country(0) <> "" Then 				docPortal.CCE_Country 			= .CCE_Country(0) 

				If .CCEStoreID(0) > 0 Then 					docPortal.CCEStoreID 			= .CCEStoreID(0) 

				If .CommerceID(0) <> "" Then 				docPortal.CommerceID 			= .CommerceID(0) 

				If .LiveDate(0) <> "" Then 					docPortal.LiveDate 				= .LiveDate(0) 

				If .IGS(0) <> "" Then 							docPortal.IGS 						= .IGS(0) 

				If .SWG(0) <> "" Then 							docPortal.SWG 						= .SWG(0) 

				If .PWS(0) <> "" Then 							docPortal.PWS 						= .PWS(0) 

				If .pSeries(0) <> "" Then 						docPortal.pSeries 					= .pSeries(0) 

				If .xSeries(0) <> "" Then 						docPortal.xSeries					= .xSeries(0) 

				If .PCD(0) <> "" Then 							docPortal.PCD 						= .PCD(0) 

				If .Description(0) <> "" Then 				docPortal.Description 			= .Description(0) 

				If .SiteBranding(0) <> "" Then  				docPortal.SiteBranding 			= .SiteBranding(0) 

				If .SiteName(0) <> "" Then 					docPortal.SiteName 				= .SiteName(0)

				Call docPortal.Save(False,True)

			End With

			Set docImport = CollImports.GetNextDocument(docImport) 

		Loop

	End If

	Set docPortal = vwCustomer.GetNextDocument(docPortal) 

Loop 



Messagebox " Finished Import Edits "

Exit Sub

ErrorHandle:

Messagebox  "libwebDevCR : MailSend, line: " & Erl & ": " & Error$ & " (" & Err & ")", 48, "Error"

Exit Sub

Subject: RE: cannot save with LotusScript - please see code here

Thanks for the code cleanup, it needed it! Unfortunately The updates do not take effect. Any other ideas out there?

Thanks,

Scott

Subject: Fixed, it was a syntax oversight…

Import_Doc.CCE_Hosting_Geo(0) If Import_Doc.CCE_Hosting_Geo(0) <> “” Then Set notesitem = Portal_Doc.ReplaceItemValue( CCE_Hosting_Geo ,newvalue1)

Should have been with quotes in ReplaceItemValue(“item”)

Import_Doc.CCE_Hosting_Geo(0)

If Import_Doc.CCE_Hosting_Geo(0) <> “” Then Set notesitem = Portal_Doc.ReplaceItemValue( “CCE_Hosting_Geo” ,newvalue1)

Works now!