We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Formula Loop

schmad01
schmad01 asked
on
Medium Priority
400 Views
Last Modified: 2013-12-18
In the postopen event of a form, I have a dialogbox pop up to fill in a field. Now, what I want is, for that box to keep popping up until the field is filled in just in case someone might just click on the x and close the dialog box window.  How do I do it?
Comment
Watch Question

Here is a example

     Dim db As NotesDatabase
     Dim s As New NotesSession
     Dim workspace As New NotesUIWorkspace
     Dim view As NotesView
     Dim doc As NotesDocument
     Set db = s.CurrentDatabase
     Set doc = db.CreateDocument
callDialog:
' Call the dialog box with doc as paremeter
Call workspace.DialogBox _
        ("Dialog Box", True, True, False, False, False,  _
     False, "Dialog Box", doc)

if doc.FieldRequired(0) = "" then goto callDialog

~Hemanth

Commented:
Can't really do it directly in R5.  R6 has @formula looping mechanisms.

What you can do is set a flag field that indicates when the formula has reached completion, put @If(flag_set; @Return(COMPLETE); @PostedCommand([ViewRefreshFields])) at the top, and put a copy of the formula in PostRecalc, if it isn't already occupied.  That will cause the formula to exit immediately if it ever completed, but otherwise, force a recalc before it even starts.  Effectively, the formula keeps looping, because the reccalc does the same thing, forcing itself to run again immediately after it completes.

Author

Commented:
Heman,
Please clarify, let's say the field name is field1. Where do I plug that in?
That will be in the if condition

if doc.Field1(0) = "" then goto callDialog
Bozzie4IT Architect

Commented:
You'll need to use the 'source' uidocument, instead of creating a new document.
Put this in the postopen event :

Dim db As NotesDatabase
     Dim s As New NotesSession
     Dim view As NotesView
     dim returnValue as integer
    if source.isNewDoc then
Do While source.document.Field1(0) = "" 
returnValue = workspace.DialogBox _
        ("Dialog Box", True, True, False, False, False,  _
     False, "Dialog Box", doc)
if not returnValue then
' stop it here
' close the document if cancelled
source.document.saveoptions = "0" 'you may need to add a text field, saveoptions, editable, value "1", to the form
call source.close()
end if
end if
Loop


Here, the user can cancel too, and the document will close ...

cheers,

Tom

Author

Commented:
Variant does not contain an object

Author

Commented:
Sorry guys, getting problems or errors on both scripts as follows.

Heman's: The loop never stops. Dialog box won't go away, even when filled in.


Bozz : Unexpected Endif Expected Loop.
Are you using correct field name ??? If not it always says that if condition is true and keeps looping .. check the spelling too

Author

Commented:
Heman repost the correct code with these plugged in so I will know if I did it right.
The name of the field is proj num.  The name of the form with the layout region is projnum.

Thanks.
Bozzie4IT Architect

Commented:
Dim db As NotesDatabase
     Dim s As New NotesSession
     Dim view As NotesView
     dim returnValue as integer
    if source.isNewDoc then
Do While source.document.Field1(0) = "" 
returnValue = workspace.DialogBox _
        ("Dialog Box", True, True, False, False, False,  _
     False, "Dialog Box", doc)
if not returnValue then
' stop it here
' close the document if cancelled
source.document.saveoptions = "0" 'you may need to add a text field, saveoptions, editable, value "1", to the form
call source.close()
end if

Loop

end if
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Correct, the field name is actually proj_num.

Still getting error though.  Variant does not contain an object.
switch on debugger and see which line is giving that error.

Author

Commented:
I think it is this one.  if doc.ProjNum(0) = "" then goto callDialog

The dialog box pops up, I enter my value and then I can't get it to disappear.  I have to end task to close notes and then reboot.
Can you post your code here..Also did you replace the field name properly ??

Author

Commented:
Yep, I think I did. Here is the code:

Dim db As NotesDatabase
      Dim s As New NotesSession
      Dim workspace As New NotesUIWorkspace
      Dim view As NotesView
      Dim doc As NotesDocument
      Set db = s.CurrentDatabase
      Set doc = db.CreateDocument
callDialog:
' Call the dialog box with doc as paremeter
      Call workspace.DialogBox _
      ("projnum", True, True, False, False, False,  _
      False, "Assign Project Number", doc)
      
      If doc.proj_num(0) = "" Then Goto callDialog
Can u send me the sample databas that has this forms and script ??

Commented:
Uh oh, EE violation.

Author

Commented:
OK.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.