This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Jun 8, 2014, 8:37 PM
13 Posts
topic has been resolvedResolved

Query Close in mail template running twice

  • Category: Notes Client
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 3

I am adding a small script into query close in the standard Notes 9 mail template; that copies the sent mail into a CRM system that we are using. Note the code below.

The scrips always runs twice... how can I prevent it from running twice....

 

XXXX

 Dim session As New NotesSession
 Dim db As NotesDatabase
 Set db = session.CurrentDatabase
 Dim workspace As New NotesUIWorkspace
 
 Call workspace.DialogBox( "aCRMdialog", True, True, True, False, False, False, "Select project",,,, )
 
  If source.Document.fldAlert(0) = "Will not be saved in CRM" Then
  Print "Not copied to CRM"
  
 Else
  
  Set maildoc = db.GetDocumentByUNID(source.document.UniversalID)
  Dim INCRMdoc As NotesDocument    
  Dim CRMdoc As NotesDocument
  Dim CRMdb As New NotesDatabase( "", "" )
  Call CRMdb.Open( source.Document.serverinn(0), "databases\\crm.nsf" )
  If Not source.document.fldLookupCompContacts(0) = "" Then
 

 ' Copy email document to CRM and make response 
   Set CRMdoc = CRMdb.GetDocumentByUNID(source.document.gildiCompContact(0))
   Set INCRMdoc = maildoc.CopyToDatabase( CRMdb )
   Call INCRMdoc.MakeResponse( CRMdoc )
   Call INCRMdoc.Save (True, True)
  End If
  
  If Not source.document.fldLookupContacts(0) = "" Then
  ' Copy email document to CRM and make response 
   Set CRMdoc = CRMdb.GetDocumentByUNID(source.document.gildiContacts(0))
   Set INCRMdoc = maildoc.CopyToDatabase( CRMdb )
   Call INCRMdoc.MakeResponse( CRMdoc )
   Call INCRMdoc.Save (True, True)
  End If
 End If

 

Jun 10, 2014, 8:15 AM
2 Posts
Re: Query Close in mail template running twice
In current code
  • It looks like the code in QueryClose is getting executed only once. However the code contains two 'IF' loops from where the document can get saved.
  • It looks like there is possibility of a document satisfying both 'IF' conditions and hence the document is getting saved twice in the CRM database.
  • Secondly, as the code is kept in QueryClose event, it is getting executed for every QureyClose (irrespective of document is 'Saved as draft' or 'Sent'). If document is to be saved only after 'SENT' then there is need of flags to be set/reset appropriately from PostOpen, QuerySave event to avoid duplication of the document.
Jun 10, 2014, 4:04 PM
13 Posts
moved to postsend... still running twice...

I moved the script to postsend and simplified the code for debugin purposes... removed any save calls... I am still getting the workspace.DialogBox twice... can it have something to do with the workspace.DialogBox parameters?

 

 ' // Copy to CRM
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Set db = session.CurrentDatabase
 
 
 Dim workspace As New NotesUIWorkspace
 
 Call workspace.DialogBox( "aCRMdialog", True, True, True, False, False, False, "Select project",,,, )
 
Print "Not copied to CRM"
' // Copy to CRM ends

Jun 18, 2014, 2:50 PM
10 Posts
Double check the dialog-form
I've used that too and it works.... Have you checked that you are not calling also a dialogbox in the form "aCR= Mdialog"?

Additionally I would also put the code to 'PostSend' and why are you getting the maildoc by universalID? Just
set maildoc =3D source.document

should do it:


Sub PostSend(Source as Notesuidocument)=A8

      Dim workspace As New NotesUIWorkspace

      Dim session As New NotesSession

      Dim maildoc as NotesDocument

      Dim db As NotesDatabase

      Set db =3D session.CurrentDatabase


      Call workspace.DialogBox( "aCRMdialog", True, True, True, False, False, False, "Select project",,,, )


      Set maildoc =3D source.document
      If maildoc.fldAlert(0) =3D "Will not be saved in CRM" Then

              Print "Not copied to CRM"

      Else

              Dim INCRMdoc As NotesDocu= ment    

              Dim CRMdoc As NotesDocume= nt

              Dim CRMdb As New NotesDat= abase( "", "" )

              Call CRMdb.Open( maildoc.= serverinn(0), "databases\\crm.nsf" )

              If Not maildoc.fldLookupC= ompContacts(0) =3D "" Then
=
                       ' Copy email document to CRM and make response
                      Set CRMdoc =3D CRMdb.GetDocumentByUNID(maildoc.gildiCompContact(0))<= /font>

                      If not CRMdoc is nothing then
=
                              Set INCRMdoc =3D maildoc.CopyToDatabase( CRMdb )

                              Call INCRMdoc.MakeResponse( CRMdoc )

                              Call INCRMdoc.Save (True, True)

                              Print "Copied to CRM"

                      Else

                              Print "Not copied to CRM"

                      End if

              End If

       End If

End Sub

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal