Manage Learn to apply best practices and optimize your operations.

Update the uidoc from a dialog box without closing the dialog

Did you need to update the uidoc from a dialogbox and want to see the update if it is suitable, then repeat the changes without closing and opening the dialogbox?

I designed Letter and Fax forms and I need to update the format of these forms such as the space between the logo and the letter body. So I made some computed-for-display fields and I used a dialogbox with two buttons (Update) and (Close) and the required editable fields that contain the data to be changed on the source uidoc.

I made a channel connection between the uidoc and the dialogbox by defining the current uidoc in the globals initialize event of the dialog because this object is still available at the dialog initialization.

Code: '##########
'1. use the following script to open the dialog
'##########
Sub UIUpdateDialog
	Const dlgTitle$ = "Message Format Options"
	Const dlgForm$ = "dlgFormatOptions"

	dim s as new notessession
	dim w as new notesuiworkspace
	dim db as notesdatabase
	Dim dialog As notesdocument

	w.currentdocument.EditMode = True

	set db = s.currentdatabase
	Set dialog = New notesdocument ( db )

	Call w.DialogBox( dlgForm, True, True, True, True, False, False, dlgTitle, dialog, True, True)

End Sub

'##########
'3. In the dialogbox put the following script in the Globals section.
'##########
' In Global declarations:
const ub% = 6 ' say the number if items you want to update
dim w as new notesUIworkspace
dim dlguidoc as notesuidocument
dim dlgdoc as notesdocument
dim baseuidoc as notesuidocument
dim basedoc as notesdocument
Dim uiItems (0 To ub) as string
Dim dlgItems (0 To ub) as string
Dim x as integer

' In the Global Initialize:
Sub Initialize
	set baseuidoc = w.currentdocument
	set basedoc = baseuidoc.document
	' this will define the open uidoc and its doc as globals to the dialogbox
End Sub

'##########
'4. In the dialogbox form postopen event:
'##########
Sub Postopen(Source As Notesuidocument)
	Set dlguidoc = Source
	Set dlgdoc = Source.Document
	
	' define the items on both the baseuidoc and dlguidoc
	uiItems(0) = "ui0"
	uiItems(1) = "ui1"
	uiItems(2) = "ui2"
	uiItems(3) = "ui3"
	uiItems(4) = "ui4"
	uiItems(5) = "ui5"

	dlgItems(0) = "dlg0"
	dlgItems(1) = "dlg1"
	dlgItems(2) = "dlg2"
	dlgItems(3) = "dlg3"
	dlgItems(4) = "dlg4"
	dlgItems(5) = "dlg5"

	For x = 0 To ub
		Call dlgdoc.ReplaceItemValue (dlgItem(x), basedoc.GetItemValue(uiItem(x)) )
	Next
	
	Call Source.Reload
End sub

'##########
'5. in dalogbox Globals create the following sub
'##########
Sub UpdateUIdoc
	'Transfer dlgdoc values to baseuidoc
	For x = 0 To ub
		Call basedoc.ReplaceItemValue (uiItem(x), dlgdoc.GetItemValue(dlgItem(x)) )
	Next
	
	Call baseuidoc.Reload
	Call baseuidoc.Refresh
	
End Sub

'##########
'6. In "Update" button call the UpdateUIdoc sub
'##########
Sub Click(Source As Button)
	Call UpdateUIdoc
End Sub

'##########
'7. In the Close Button as well:
'##########
Sub Click(Source As Button)
	call UpdateUIdoc
	Call dlguidoc.Close
End Sub
'##########
'When you call this dialogbox, change any values inside it;
'the changes will get transferred to the baseuidoc by clicking the
'Update Button or the Close Button.
'##########


Dig Deeper on Domino Resources

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close