Solved

Formula Loop

Posted on 2004-03-29
19
351 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?
0
Comment
Question by:schmad01
  • 8
  • 7
  • 2
  • +1
19 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10708266
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
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 10708276
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.
0
 

Author Comment

by:schmad01
ID: 10708333
Heman,
Please clarify, let's say the field name is field1. Where do I plug that in?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10708424
That will be in the if condition

if doc.Field1(0) = "" then goto callDialog
0
 
LVL 15

Expert Comment

by:Bozzie4
ID: 10711360
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
0
 

Author Comment

by:schmad01
ID: 10713355
Variant does not contain an object
0
 

Author Comment

by:schmad01
ID: 10713465
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.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10713556
Are you using correct field name ??? If not it always says that if condition is true and keeps looping .. check the spelling too
0
 

Author Comment

by:schmad01
ID: 10713971
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.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 15

Expert Comment

by:Bozzie4
ID: 10713979
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
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 125 total points
ID: 10714227
The field name cannot contain space like Proj Num... Is it ProjNum ??

If so..

     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.ProjNum(0) = "" then goto callDialog


0
 

Author Comment

by:schmad01
ID: 10716428
Correct, the field name is actually proj_num.

Still getting error though.  Variant does not contain an object.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10716587
switch on debugger and see which line is giving that error.
0
 

Author Comment

by:schmad01
ID: 10724214
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.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10724554
Can you post your code here..Also did you replace the field name properly ??
0
 

Author Comment

by:schmad01
ID: 10725003
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
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10726275
Can u send me the sample databas that has this forms and script ??
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 10728179
Uh oh, EE violation.
0
 

Author Comment

by:schmad01
ID: 10759886
OK.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Lotus Notes 8.5 1 137
How do I delete a user in IBM Lotus Notes 2 199
Find and delete local contacts in names.nsf 5 163
lotus notes, exchange 7 105
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now