I have one form with two fields called "Field 1" and "Field 2" and one action button called "check". On click of that action button, i want to open dialog box with three fields which should get auto populate based on Field 2 value. How to achieve it?
Appreciate if anyone helps me.
Yes, it is possible. There's a document parameter for NotesUIWorkspace.DialogBox(). Use this document to pass parameters to your dialog.
UPDATE
Assume you have a form with name "MyDialogForm" to represent your dialog.
It looks like that and contains 3 fields:
And you have a form with two fields and "Check" button:
Put the following code to the "Click" event handler of your "Check" button:
Sub Click(Source As Button)
Const DIALOG_FORM_NAME = "MyDialogForm"
Dim ws As New NotesUIWorkspace
Dim dialogBoxAccepted As Boolean
Dim dialogParamDoc As NotesDocument
Dim currentDocument As NotesDocument
Dim field2Value As String
Set currentDocument = ws.CurrentDocument.Document
field2Value = currentDocument.GetItemValue("Field2")(0)
'document created in-memory, but should not be saved
Set dialogParamDoc = New NotesDocument(currentDocument.ParentDatabase)
'populating dialog box fields
Call dialogParamDoc.ReplaceItemValue("DialogField1", "dialogField1 with: " + field2Value)
Call dialogParamDoc.ReplaceItemValue("DialogField2", "dialogField2 with: " + field2Value)
Call dialogParamDoc.ReplaceItemValue("DialogField3", "dialogField3 with: " + field2Value)
dialogBoxAccepted = ws.DialogBox(DIALOG_FORM_NAME,True , True, False, False , False , False, "My Dialog Title", dialogParamDoc, True)
If dialogBoxAccepted Then
'displaying values, entered/changed in dialog box
Msgbox dialogParamDoc.getItemValue("DialogField1")(0),,"DialogField1"
Msgbox dialogParamDoc.getItemValue("DialogField2")(0),,"DialogField2"
Msgbox dialogParamDoc.getItemValue("DialogField3")(0),,"DialogField3"
End If
End Sub
This code reads "Field2" and populates dialog fields based on its value. Then it shows the dialog where you can change these values.
If you pressed OK in your dialog (dialog accepted), the code will show the values you have altered in dialog box.
Related
Before this I have post a question regarding my problem but still no answer. I will try again to post question about my problem in here. I will update new code and explaination about it. Before this I have done with dialog box, but I have been asked to change it, just use form in view.
My process start with open a form in view to set a new batch info. the form name is PCBatchInfo. In this form, I have 4 field which is BBatchNo, BInspector, BStart, and BEnd. Then in this form I have a button. When I click this button, it will do three process which is:
Create new batch info and save. This is current open document. I call this "dialogDoc".
Then, create a copy of Computer document. In this copy, it will replace BBatchNo as I created just now. I call this copy document as "newdoc" and original document as "doc"
After that, I create new report document and copy value from Computer document. Then I will get value from set batch no which is BInspector, BStart, and BEnd and insert into this report I call this "repdoc".
Below here my lotusscript in my button
Set db = session.CurrentDatabase
Set uidoc = ws.CurrentDocument
Set dialogDoc = uidoc.Document
Set view = db.GetView("Computer")
Set doc = view.GetFirstDocument
If doc.PStatus(0) = "Lock" Then
Msgbox "Complete PC Inspection first!"
Exit Sub
Else
'--set new batch info--'
dialogDoc.Form = "PCBatchInfo"
Call uidoc.FieldSetText("SaveOptions", "1")
Call uidoc.Save
answer% = Messagebox("Please confirm", 4,"Batch Number")
If answer% = 6 Then
While Not (doc Is Nothing)
If doc.PStatus(0) = "Active" Then
'--create new copy document--'
Set newdoc = doc.CopyToDatabase (db)
newdoc.DocumentId = doc.UniversalID
newdoc.PBatchNo = dialogDoc.BBatchNo(0)
Call newdoc.Save(True, False)
'-- set new acceptance form --'
Set repdoc = New NotesDocument (db)
repdoc.Form = "EmpPCSpec"
repdoc.ABatchNo = doc.PBatchNo(0)
repdoc.AStatus = doc.PStatus(0)
repdoc.ATagNo = doc.PTagNo(0)
repdoc.AFStatus = doc.PFStatus(0)
repdoc.AInspector = dialogDoc.BInspector(0)
repdoc.AStart = dialogDoc.BStart(0)
repdoc.AEnd = dialogDoc.Bend(0)
Call repdoc.ReplaceItemValue("AStatus", "Incomplete")
Call repdoc.ComputeWithForm(False,False)
Call repdoc.save(True,False)
doc.PStatus = "Lock"
Call doc.ComputeWithForm(False,False)
Call doc.save(True,False)
End If
Set doc = view.GetNextDocument(doc)
Wend
End If
End If
All this process I run on one button. So when I run this button, I have success to create new batch info, I can create copy of document, and I can create report document.
But the problem now are in copy document, it did not display BBatchNo. And in report document, it did not display BInspector, BStart, and BEnd that I want to get from PCBatchInfo form. The field left empty. I hope my explaination is clear about my problem. Any help from you guys I appreciated. Thanks!
Update Question
For all information save for new batch info using PCBatchInfo, the view is on (PCBatch). How can I get the value in this view? I only get value from "Computer" where it save Computer document.
I think your problem is right here
Set dialogDoc = New NotesDocument(db)
You carefully got the document object from the current UIDoc and then overwrote it with a new (blank) document.
I need to change the name and formula of columns of a embedded view in a lotus notes dialog box.I need to change this column name and formula when a combo box value in dialog box changes.i added the lotus script to change the column name and formula on combo box value change and added code to reopen the dialog box.
Dim w As New NotesUIWorkspace
Dim view As NotesView
Dim col As NotesViewColumn
Set view = db.GetView("Test")
For j= 0 To UBound(SboxColName)
Set col=view.Columns(j)
col.Title=SboxColName(j)
col.Formula=SboxColFormula(j)
Next
Call w.Viewrefresh()
But the view column not get updated in next open, it gets updated only when i open the view in designer and save the view. when i open this view in designer i can see that the column is updated in the design.
Is there any way to get this embedded view column updated in runtime
In past I used this code in server agent, has worked fine.
I changed DateTime value in column for coloring rows (copy column and change formula).
After that i had send command to rebuild view in db.
Set view = db.Getview(*viewName*)
Set clm = view.Columns(3)
Set Newclm = view.Copycolumn(clm, 5)
Call view.Refresh()
Newclm.Formula = {#If( [} & Today & {] > #Date(DTContol); 255:0:0;-1 : -1 : -1 : -1 : -1 : -1)}
Call view.Removecolumn(4)
CommandText = {load updall } & db.Filepath & { -t } & view.Name & { -r}
Call session.Sendconsolecommand(db.Server, CommandText)
On Client: Maybe Call ws.Viewrefresh() will be sufficient
I have an image in Domino Designer on a form, I want to + 1 to a field elsewhere on the same form when the image is clicked. Is this possible?
To add an action without creating a button, right click the image and select 'Add action default'. If you want only part of the image to be clickable, select 'Add action rectangle' (or circle or polygon) and draw the clickable region.
If you need it to work without being in edit mode, you need to use LotusScript instead of formula. (There is the old-fashioned option of having the button run an agent, but that's really not a good idea; it will cause lots of distracting UI flashes).
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Dim doc As NotesDocument
Set doc = uidoc.Document
value = doc.GetItemValue("counterField")
Call doc.ReplaceItemValue("counterField",value(0)+1)
Call doc.Save(True,False,False)
Call uidoc.Refresh
End Sub
Note that the above applies to Notes client applications only. The LotusScript hotspot won't work in a browser.
If I understand, it look like a course exercice...
Add a field name plusOne (or what ever) type number, computed, value:
#If(#Text(#ThisValue)="" ; 0 ; #ThisValue)
Select the picture and add an action hotspot
Formula for this hotspot:
#If(#IsDocBeingEdited ; "life is easy ;-)" ; #Command([EditDocument]) );
FIELD PlusOne:=PlusOne+1
At first, there's a rich text field in the form that has a text inputted already (for this scenario - "hello world"). I have placed the cursor just after the letter "o" from "hello". I have a button that will open up a dialog box with one text field and I was wondering how would you be able to insert the text from that field from the dialog box at the current position of the cursor in the rich text field.
So far the code I have is:
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.currentdatabase
Dim docFill As New notesdocument(db)
Call workspace.DialogBox _
( "Test", True, True, False, False, _
False, False, "Test Insert text at current position in rich text field", docFill, True, False, True )
Dim string1 As String
string1 = docFill.sampleText1(0)
Dim rts As NotesRichTextStyle
Set rts = s.CreateRichTextStyle
End Subs
End Sub
Let's say I entered "stackoverflow" in sampleText1 text field. After clicking ok then it will be inserted at the position of the cursor in the rich text field. So the result will be "hellostackoverflow world".
Also just an additional question. Let's say I also wanted the text to be in color red or a different font so I would be using notesrichtextstyle class etc to design it. How would you be able to insert the rich text at the position of the cursor in the rich text fiel if that would be the case?
You can insert text at current cursor position with the help of the clipboard. Just let the user insert text in a dialog box, select the text after clicking "OK", copy it and then paste it at the current cursor position in RichText field back in your form.
To accomplish that, create an action "Insert text" in your form's action bar with the LotusScript code
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
If workspace.DialogBox _
("Dlg", True, True, False, True, _
True, False, "Test insert text", doc, True, False, True ) Then
uidoc.Paste
End If
End Sub
Actions in action bars have the advantage that they don't change the cursor position in document on click event. So, the cursor still remains on current position e.g in RichText field clicking on an action button.
Then, create a form "Dlg" for DialogBox with a Text or RichText field "Text". Add the following formula code to form's Postrecalc event (it's executed on "OK" button click):
#Command([EditGotoField]; "Text");
#Command([EditSelectAll]);
#Command([EditCopy])
You have a lot of options with the copy-paste-approach to put content into clipboard:
Create a text in backend and put it direct into clipboard
Create a RichText item in a temp document with all content and style options you can think of, open the document in UI, copy the RichText item content to clipboard and close document without saving
Let users create their text snippet in documents. Let them choose one of it clicking on "Insert text" button - just open the selected document, copy the content to clipboard and close it.
The first problem is that when you click the action button, you will lose focus of the rich text field, and therefor there is no way to know where the cursor was.
I would also suggest that you don't use the extended notation like this:
string1 = docFill.sampleText1(0)
Use the GetItemValue method of the NotesDocument class instead (for several reasons, including performance and future-proofing your code.
If you just want to have the user enter some text, why not use the InputBox function?
Finally, there is not an easy way to insert text in the middle of a rich text. It is much easier to perform a replace of a specific text string in a rich text field. I once created a Lotusscript class to perform mailmerge (create letters based on a template and a form letter with field names and commands), you can find it here: http://blog.texasswede.com/code-mail-mergeform-letters-in-lotuscript/
Perhaps that can help you some. But it has to be done in the backend, you can't do much rich text work in the frontend, unless you use Midas LSX frpn Ben Langhinrichs (http://www.geniisoft.com). I think he got some UI functionality.
But your biggest issue will be the first problem, how to trigger the code without losing focus of the rich text field. I don't see a good solution there. You may want to rethink your design/approach.
If you use a button in the Action Bar then the focus will remain with the rich text field. You can then use uidoc.InsertText("") to insert the text at the current position of the cursor.
You could use...
call uidoc.InsertText( docFill.sampleText1(0) )
Something like this:
Private Sub opt01_Click()
If opt01.Value = True Then
opt01.Value = False
Else
opt01.Value = True
End If
It would be suitable for my formDesign, instead of looking for and importing some similar small picture.
Because an OptionButton's value is always true when the Click event runs, you will need to store its desired value in a variable. Here is an example using a Form Control Option Button within a sheet named Option Button 1 on sheet 1. This method is stored in a module.
Private optionClicked As Boolean
Sub OptionButton1_Click()
Dim o As OptionButton
Set o = Sheets(1).Shapes("Option Button 1").OLEFormat.Object
o.Value = Not optionClicked
optionClicked = Not optionClicked
End Sub
Note however, that using this method, that clicking on any option button will make all other option buttons false. So to use multiple option buttons as check boxes, you will need to store the correct value of the option buttons (probably in an array)... and correct the values every time any option button is clicked.
Are you sure you can't use check boxes?