Solved

Help with validations

Posted on 2004-08-24
12
253 Views
Last Modified: 2013-12-18
Hi

I have a form that has amix of validation formulas in Input Validations and also within a script

If I submit a document that passes al script validations but fails an Input validation the script continues and the doc refreshes and changes all the buttons

I would like to know if there is a way around this
I am reluctant to do script validations for all tha Input translationa as there are about thirty

I will post the script below


Regards

James
0
Comment
Question by:imjamesw
  • 4
  • 4
  • 2
  • +1
12 Comments
 

Author Comment

by:imjamesw
ID: 11883143
This script used to run in the QuerySave , I have since moved it to a button


    'Set the session and db variables
      Dim session As New NotesSession
     'Set the front-end workspace and uidoc
      Dim uiws As New NotesUIWorkspace
      Set db = session.CurrentDatabase
      Dim currentdb As NotesDatabase
      Set uidoc = uiws.CurrentDocument
      Set doc = uidoc.Document
      Dim maildoc As NotesDocument
      Dim rtitem As NotesRichTextItem
      Set currentdb = session.CurrentDatabase
     'Validations for Comments
      Valid = True
      'HR Action Forms Bypass
      If doc.CreateSrce(0) = "Int"  Then
            Goto CheckValid
      Else
            If doc.CreateSrce(0) = "Ext" & doc.hrcomments(0) <> "" Then
                  Goto SaveByPass
            Else
                  Msgbox "Warning .... You must either supply information in the HR Comments field or complete the Security Access Section. This is to be used only in cases where there may be no Security action required", 0+16+0+0, "Missing Information"
                  Valid = False
                  Exit Sub
            End If
      End If
CheckValid:
     'Validations for Security Item
      If uidoc.FieldGetText("ACX") = "No" And uidoc.FieldGetText("VR") = "No" And uidoc.FieldGetText("CICR") = "No" _
      And uidoc.FieldGetText("AMM") = "No" _
      And uidoc.FieldGetText("CORP") = "No" _
      And uidoc.FieldGetText("CCR") = "No" And uidoc.FieldGetText("DSR") = "No" _
      And uidoc.FieldGetText("EDISR") = "No" And uidoc.FieldGetText("INETR") = "No"  And uidoc.FieldGetText("IFSR") = "No"  _
      And uidoc.FieldGetText("FWALLR") = "No" And uidoc.FieldGetText("INFOPR") = "No" _
      And uidoc.FieldGetText("ISYSR") = "No" And uidoc.FieldGetText("LANR") = "No" And uidoc.FieldGetText("LDAPR") = "No" _
      And uidoc.FieldGetText("LNR") = "No" And uidoc.FieldGetText("ODR") = "No" And uidoc.FieldGetText("OR") = "No" _
      And uidoc.FieldGetText("PEDGRR") = "No" And uidoc.FieldGetText("PEO") = "No"  _
      And uidoc.FieldGetText("RAR") = "No" And uidoc.FieldGetText("REMINDR") = "No" And uidoc.FieldGetText("RFXR") = "No" _
      And uidoc.FieldGetText("SHARKR") = "No" And uidoc.FieldGetText("SON") = "No" _
      And uidoc.FieldGetText("SONORAR") = "No"  And uidoc.FieldGetText("STRATUSR") = "No" _
      And uidoc.FieldGetText("TELEC") = "No" _
      And uidoc.FieldGetText("TIV") = "No" And uidoc.FieldGetText("TSOR") = "No"  And uidoc.FieldGetText("TR") = "No"  _
      And uidoc.FieldGetText("UNIXR") = "No"  And uidoc.FieldGetText("WIN2000R") = "No"  And uidoc.FieldGetText("PKIR") = "No"  _
      Then
            Msgbox "Warning .... You must choose at least 1 item in the Security Access Selection Section", 0+16+0+0, "Missing Information"
            Call uidoc.GotoField("ACX")
            Valid = False
            Exit Sub
      End If
SaveByPass:
      If  (doc.CORP (0) ="Yes" ) And (doc.status(0) = "LOCKED") Then
            SendCORP
      End If
     'Validations for Approvers
      If uidoc.FieldGetText("approver1") = "" Then
            Msgbox "Warning.... You must have chosen an Approver before you can save this document", 0+16+0+0, "Missing Information"
            Valid = False
            Exit Sub
      End If
      
      If valid Then
            doc.Checksave = "Yes"
            doc.ApproverSent = "1"
            doc.SaveFlag = "1"
      Else
            Continue = Valid
      End If
      'Build the Email notification
      Set maildoc = New NotesDocument(currentdb)
      Set item = maildoc.AppendItemValue("SendTo",doc.Approver1)
      
      TheSubject = "Mail Notification: This will notify the approver that a signature is required for this document"
      Set rtitem = New NotesRichTextItem(maildoc, "Body")
      Call rtitem.AppendText( " Click link to open document" )
      Call rtitem.AddNewLine( 2 )
      Call rtitem.AppendDocLink(doc, "Link to document")
      Call rtitem.AddNewLine( 2 )
                  'Compute the computed fields and Send and Save
      maildoc.Form = "Memo"
      maildoc.Subject = TheSubject
      Call mailDoc.ComputeWithForm(False, False)
      Call maildoc.Send(False)
      
      Call uidoc.save
      Call uidoc.close
      
0
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 250 total points
ID: 11883341
Use @IsValid in evaluate function before querysave and test the result.. if it doesn't return true then there is an error..

Alternatively you can issue source.refresh to recalculate fields before save...

~Hemanth
0
 
LVL 15

Expert Comment

by:Bozzie4
ID: 11883632
Don't put your script outside the QuerySave, since
Continue=False
will not work !  

If you want the script execution in a button to stop, use 'end' or 'exit sub' so that it doesn't reaches the 'save' command.

cheers,

Tom
0
 

Author Comment

by:imjamesw
ID: 11883762
I have removed the continue = false and if you look you will see there is Exit sub for the validations that are in the script, The problem is with the validations on the form.

I was thinking that maybe I could either do what Hemanth suggested or use @IsValid in a button and the call the script if validations pass

something like

@If(@IsValid;@Do(Call script name);"")
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 11883948
James,

Don't you get tired looking at such code? Even if you don't today, tomorrow you will, or your successor will. I know, it doesn't solve your problem but I have a suggestion for you.

Writing your code in a 'Modular' way.

My suggestion will not immediately get you out of this situation, but it will help you not get into such scenarios. As for the code above, it isn't easy understanding that as it is. See, what you can do is, you can divide your code in smaller parts like this:




Sub SendNotification(doc As NotesDocument)
      Dim session As New NotesSession
      Dim currentdb As NotesDatabase
      Dim maildoc As NotesDocument
      Dim rtitem As NotesRichTextItem
    'Build the Email notification
      
      Set currentdb = session.CurrentDatabase            
      Set maildoc = New NotesDocument(currentdb)
      Set item = maildoc.AppendItemValue("SendTo",doc.Approver1)
      
      Set rtitem = New NotesRichTextItem(maildoc, "Body")
      Call rtitem.AppendText( " Click link to open document" )
      Call rtitem.AddNewLine( 2 )
      Call rtitem.AppendDocLink(doc, "Link to document")
      Call rtitem.AddNewLine( 2 )
      'Compute the computed fields and Send and Save
      maildoc.Form = "Memo"
      maildoc.Subject = "Mail Notification: This will notify the approver that a signature is required for this document"
      Call mailDoc.ComputeWithForm(False, False)
      Call maildoc.Send(False)      
End Sub







Function IsValueNo(Byval sFieldName) As Variant
      Dim WS As New NotesUIWorkspace
      Dim UIDoc As NotesUIDocument
      Set UIDoc = WS.CurrentDocument
      
      If Lcase(UIDoc.FieldGetText(sFieldName)) = "no" Then
            IsValueNo = True
      Else
            IsValueNo = False
      End If
End Function







   'Set the session and db variables
      Dim session As New NotesSession
    'Set the front-end workspace and uidoc
      Dim uiws As New NotesUIWorkspace
      Set db = session.CurrentDatabase
      Dim currentdb As NotesDatabase
      Set uidoc = uiws.CurrentDocument
      Set doc = uidoc.Document
      Dim maildoc As NotesDocument
      Dim rtitem As NotesRichTextItem
      Set currentdb = session.CurrentDatabase
    'Validations for Comments
      Valid = True
    'HR Action Forms Bypass
      If doc.CreateSrce(0) = "Int"  Then
          'Validations for Security Item
            If IsValueNo("ACX") _
            And IsValueNo("VR") _
            And IsValueNo("CICR") _  
            Then
                  Call uidoc.GotoField("ACX")
                  Valid = False
            End If
      Else
            If Not(doc.CreateSrce(0) = "Ext" & doc.hrcomments(0) <> "") Then
                  Msgbox "Warning .... You must either supply information in the HR Comments field or complete the Security Access Section. This is to be used only in cases where there may be no Security action required", 0+16+0+0, "Missing Information"
                  Valid = False
                  Exit Sub
            End If
      End If
      
      If  (doc.CORP (0) ="Yes" ) And (doc.status(0) = "LOCKED") Then
            SendCORP
      End If
    'Validations for Approvers
      If uidoc.FieldGetText("approver1") = "" Then
            Msgbox "Warning.... You must have chosen an Approver before you can save this document", 0+16+0+0, "Missing Information"
            Valid = False
            Exit Sub
      End If
      
      If valid Then
            doc.Checksave = "Yes"
            doc.ApproverSent = "1"
            doc.SaveFlag = "1"
      Else
            Continue = Valid
      End If
      
      Call SendNotification(doc)
      Call uidoc.save
      Call uidoc.close      






From another question you had posted, I remember that you had issues with the usage of Continue. So, going by that, your code above, no matter how perfect we make, will NOT work from the click of a button, because there is NO CONTINUE parameter there. Just put the code back in the Querysave. If you at all want to test the functionality, you may put the code in a function and make a call to the function in the QuesrySave like:

Continue = Your_Validation_Function_Name_Here()




0
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.

 
LVL 19

Expert Comment

by:RanjeetRain
ID: 11883968
I have eliminated some repetitive parts from your original code to make it smaller for me. You of course have to put them.
0
 

Author Comment

by:imjamesw
ID: 11884408
Also just for reference I did not write the above code

I am just trying to modify the code to include email

And also as I said getting the on form validations to validate
0
 
LVL 19

Accepted Solution

by:
RanjeetRain earned 250 total points
ID: 11884969
I see. So your best bet would be to clean the code whereever you need to.

On form validations? WHat are you referring to?
0
 

Author Comment

by:imjamesw
ID: 11885242
THe Input Validations


I have seemed to solved this

I used uidoc.refresh right after the Dim and Sets

It works
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11932774
James.. that is kind of sad...

check my first comment
>Alternatively you can issue source.refresh to recalculate fields before save...
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 11940849
Hi Hemantha,

Pls look here: http:/Q_21113505.html
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

14 Experts available now in Live!

Get 1:1 Help Now