Comparing field value

pts.
Tags:
Lotus Domino
I have 2 different forms that must be checked as an agent's condition. From the view, I need to check for the existance of form B. If there is no any, the requester name from Form A will be notified. The key field here is ReferenceNo. If there is form B created for form A, both will be using the same ReferenceNo. **Form B is NOT a response form for Form A.** Question how am I going to check for the Form B's existance that is created for Form A by using lotus script? I've done a view and some other approach to solve it.But, my lack of knowledge using the script made me blank at all. Really need assistance. Here is some code been written. Sub Initialize Const NotesMacro$ = "@Adjust((EndDate); 0; 0; 14; 0; 0; 0) < @Today" Dim session As New notessession Dim item As notesitem Dim coll As notesdocumentcollection Dim searchformula As String Dim FlagSend As Integer Dim result As Variant Dim tarec As String Dim doc2 As NotesDocument Set db=session.currentdatabase searchformula="(Form='travelAdvance' & choice2 ='Yes' & (Status !='Cancelled' | Status !='Withdrawn' | Status != 'Reporting manager rejected' | Status != 'Level 1 rejected'))" Set coll=db.search(searchformula,Nothing,0) Set doc=coll.getfirstdocument FlagSend% = True While Not doc Is Nothing tarec = doc.TaRefNo key = "cTARefNo" Set view = db.GetView ("OutStationClaim" ) Set doc2 = view.GetDocumentByKey (key) If tarec = doc2.key Then result = Evaluate ( NotesMacro$, doc) If result(0) <> 0 Then If doc.cEmpName = "CEO SendTo = doc.Secretary Else FlagSend = True Else FlagSend = False End If End If If FlagSend = True Then Escalate_Mail doc.save True,True Set doc=coll.getnextdocument(doc) Else Set doc=coll.getnextdocument(doc) End If Wend End Sub

Answer Wiki

Thanks. We'll let you know when a new response is added.

1) Create a view of doc B’s and make the first column sorted with the value of RefNo. Create a view for your form A’s as well.

2) I’m calling the views All_B and All_A and am using docA as the reference document variable.

Here is the script that will detect if you have any doc B’s. We will use a NotesViewEntryCollection to see if matches exist.

Good luck,
Mike

Dim s as new Notessession
Dim db as notesdatabase
Dim vA as NotesView
Dim vB as NotesView
Dim vec as NotesViewEntryCollection
Dim docA as NotesDocument
Dim tarec As String

Set db = s.CurrentDatabase
Set vA = db.GetView(“All_A”)
Set vB = db.GetView(“All_B”)

Set docA = vA.GetFirstDocument
tarec = docA.RefNo(0)
Set vec = vB.GetAllEntriesByKey(tarec, True)
if vec.Count > 0 then
Messagebox “We have ” & Str(vec.Count) & ” matches”
Else
Messagebox “No Match”
End if

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following