Passing new value to another form

What I am trying to do

  1. enter a customer account number on a form - DONE

  2. lookup in a view to see if the number exists - DONE

  3. if it does get the customer name - DONE

  4. if it doesnt, load the customer add form - DONE

  5. Add customer using form - DONE

  6. Pass customer name back to other form - IM STUCK!

I just need to know how to pass this customer name field back to the other form (which is loaded). Not sure I can.

Here is the subroutine i have created in a script library. I try to call this again when I select the next field on the form or re-exit the field which originally calls the script but this doesnt work. I change the account number to another existing value. This works. Then I set the account number back to the newly added account number and this also works. But I want this to update as soon as the add customer window closes.


Sub getCustomerName

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace



Set db = session.CurrentDatabase	

Set curDoc = ws.CurrentDocument

Set luView1= db.GetView("(Customers)")





If curDoc.FieldGetText("AccountNo") = "" Then

	Messagebox("Please specify an account number")

	Call curDoc.FieldSetText("CustomerName","")

Else		

	AccNumber = curDoc.FieldGetText("AccountNo")		

	Set Doc = luView1.GetDocumentByKey(AccNumber)	

	If Doc Is Nothing Then

		Call curDoc.FieldSetText("CustomerName","")

		If Messagebox("An customer name does not exist for the account number entered. Click OK to enter the customer name", 	MB_ICONEXCLAIMATION+MB_YESNO, db.title & " - Add new customer") Then

			Set newdoc = db.Createdocument()

			newdoc.Form="Customer"

			newdoc.AccountNo = AccNumber

			Set notesuidocument = ws.EditDocument(True, newdoc, False)						

		End If	

	Else		

		CustomerName = doc.ColumnValues(1)

		Call curDoc.FieldSetText ("CustomerName",CustomerName)		

	End If

End If

End Sub

Subject: Passing new value to another form

I can see 2 ways of doing this:

  1. Get the user to create the new customer in a dialog box and get the values needed from that

  2. When creating a new customer save & close the current form, put the UNID of that form in the new customer form. In the ‘submit new customer’ button (basically force a save & close from a button), get the original doc via it’s UNID, append the relevant details and open

Dan

Subject: RE: Passing new value to another form

But if the customer has been added from my script, should it not show the next time I run my subroutine? Is this a caching issue?

Subject: RE: Passing new value to another form

You could add a view.refresh after getting the view as it may not have updated, but you still have the problem of updating as the user closes the new customer form, which leaves you with the options I gave you (and potentially others of course if anyone else has brighter ideas)

Subject: Passing new value to another form

You need to pick up the reference to the new field - either the UI document or backend value…

Sub getCustomerName

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Set db = session.CurrentDatabase

Set curDoc = ws.CurrentDocument

Set luView1= db.GetView(“(Customers)”)

If curDoc.FieldGetText(“AccountNo”) = “” Then

Messagebox("Please specify an account number")

Call curDoc.FieldSetText("CustomerName","")

Else

AccNumber = curDoc.FieldGetText("AccountNo")

Set Doc = luView1.GetDocumentByKey(AccNumber)

If Doc Is Nothing Then

	Call curDoc.FieldSetText("CustomerName","")

	If Messagebox("An customer name does not exist for the account number entered. Click OK to enter the customer name", MB_ICONEXCLAIMATION+MB_YESNO, db.title & " - Add new customer") Then

		Set newdoc = db.Createdocument()

		newdoc.Form="Customer"

		newdoc.AccountNo = AccNumber

		Set notesuidocument = ws.EditDocument(True, newdoc, False)

		' reference the now saved "Customer" doc (either the UI or backend doc)

		CustomerName = newdoc.ColumnValues(1) or notesuidocument.fieldgettext(<fieldname>)

		Call curDoc.FieldSetText ("CustomerName",CustomerName)		

	End If

Else

	CustomerName = doc.ColumnValues(1)

	Call curDoc.FieldSetText ("CustomerName",CustomerName)

End If

End If

End Sub