[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Newsletter Not Showing Doc Title Name

Experts,

I have two small problems that I am sure someone can help me with quickly - I've had it today :(  and I need to finish this by today...ugh!!

1. I must be loosing it, tired, or just need to step away.  I have the following agent that runs okay except that the titles of my documents do not display.  The field name in the document is "Title" - and although the doc link appears, no title shows.  So, I use another field name, (DocCategory) and still the title column in the newsletter formatted email is blank.  So, I'm thinking something else is wrong.

2. I don't want to hard code a name in this agent, but I've looked everywhere and cannot find a way to sent the field in the Script, where it will pick up the name of whomever is in the NotifyGroup field.  When I replace

Call doc.Send (False, "First Name/XXX/My Companyl")

with

Call doc.Send(True, doc.NotifyGroup)

where NotifyGroup is the field in the document that holds the person(s) name, I get an error saying "No Names Found to Send Mail To"  But in the first example, by hard coding my name -- it works fine (without providing title of the document though)

-----------------------------------------------------------------

Sub Initialize
      
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim collection As NotesDocumentCollection
      Dim newsletter As NotesNewsletter
      Dim doc As NotesDocument
      Dim SearchFormula As String
      Set db = session.CurrentDatabase
      
      SearchFormula = {(Form = "frmDoc") & (whenAL  = @Yesterday)}
      Set collection = Db.Search ( SearchFormula, Nothing, 0 )
      
      If ( collection.Count > 0 ) Then
            Set newsletter = session.CreateNewsletter( collection )
            Set doc = newsletter.FormatMsgWithDoclinks( db )
            doc.DoScore = False           'if you don't want relevance score
            doc.DoSubject = True          'to be able to specify subject of each doc
            doc.SubjectItemName = "Title"     'name of the item in the doc which contains the subject
            doc.Form = "Memo"
            doc.Subject = "ALERT: File Attachment Changes in the Blank Database"
            Call doc.Send (False, "First Name/XXX/My Companyl")
      End If
      
End Sub

Thanks in advance,
AliciaVee
0
AliciaVee
Asked:
AliciaVee
  • 11
  • 9
  • 8
  • +1
1 Solution
 
SysExpertCommented:
First, try

doc.NotifyGroup(0)

I do not see either Title or DocCategory field defined or used anywhere !

I hope this helps !
0
 
AliciaVeeAuthor Commented:
SysExpert,

Title and DocCategory are fields in the document.  I believe when you use the NotesNewsletter object, you can use SubjectItemName to equal a field in your document that display -- in the title colum -- the subject or title of your document.  But -- it is not working with this piece of code, but I did have it working earlier with another code snippet I was using - which I can't find at this moment.

I did try in your other suggestion:

            Call doc.Send (True, doc.NotifyGroup(0))

But that didn't help either.  :(
0
 
marilyngCommented:
A few corrections, the formatmsgwithdoclinks must come after the doScore and DoSubject, and these are related to the newsletter object, not the doc object :)      

                 If ( collection.Count > 0 ) Then
            Set newsletter = session.CreateNewsletter( collection )
            Set  doc= New NotesDocument(db)
            newsletter.DoScore = False           'if you don't want relevance score
            newsletter.DoSubject = True          'to be able to specify subject of each doc
            newsletter.SubjectItemName = "Title"     'name of the item in the doc which contains the subject
            Set doc = newsletter.FormatMsgWithDoclinks( db )
            doc.Subject = "SUBJECT OF YOUR NEWSLETTER"
                                doc.Form = "Memo"                                    
            Call doc.Send (False, "YourEmailAddress")
      End If
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
AliciaVeeAuthor Commented:
marilyng,

Awesome!  I got my titles back -- yay!  Thanks!

Now -- is there a way to be able to use a field name instead of hard coding someone's email into the script?  Seems to me that it would be easier maintenance for future changes (like if I use a profile doc to populate a specific field called NotifyGroup).

Is this possible?
0
 
marilyngCommented:
Sure, just set the:
doc.sendTo =
doc.BlindCopyTo=
doc.~_ViewIcon = some nifty icon number
and adjust the doc.Send to just call doc.send(false)

Or you can put a fieldname into the call doc.send(false, thisfieldname)

0
 
AliciaVeeAuthor Commented:
marilyng,

Okay -- I will try that when I get in the office, but I really thought I did try the doc.sendTo = FieldName and that didn't work...and I also tried:

Call doc.Send(True, doc.NotifyGroup)

So, it looks like I need to put False instead of True?  Okay -- will try it and write back this morning.

Hopeful...

AliciaVee
0
 
Sjef BosmanGroupware ConsultantCommented:
Where is that NotifyGroup coming from? I suppose you have a second document in mind, with that field, and not the document to be mailed??
0
 
AliciaVeeAuthor Commented:
marilyng / sjef,

Okay, I've done all of the following:

            doc.SendTo = "NotifyGroup"
            Call doc.Send (False)
and
            doc.SendTo = NotifyGroup
            Call doc.Send (False)
and
            doc.SendTo = doc.NotifyGroup(0)
            Call doc.Send (False)
and
            Call doc.Send (False, NotifyGroup)
and
            Call doc.Send (False, "NotifyGroup")
and
            Call doc.Send (False, doc.NotifyGroup(0))

All give me about the same error message that no names found, no receipients found, etc.  NotifyGroup is a field in the document frmDoc that is the result of the search (the collection).  NotifyGroup is a Names field with an auto population of a specific user -- that I will change to read from a global variable provided from a profile doc, once I can get this agent to read the value of the field name -- or a field name.

Any other ideas to get this working?

AliciaVee


0
 
marilyngCommented:
Dim varSendTo as variant
if doc.hasItem("NotifyGroup") then
  if len(doc.getItemValue("NotifyGroup")(0))>0 then
       varSendTo=doc.getItemValue("NotifyGroup")
  else
         varSendTo = "ThisDefaultSendToNameThatYouKnowExists"
 end if

  Doc.SendTo = varSendTo
------------------------

>>Now it's not just a good idea to grab the value, because address books change, and if the group isn't listed (or is listed as ACL ONLY in the NAB) then the name won't resolve, and mail would not be sent.

So somewhere in your code you have to validate that the sendTo name is correct, else the email doesn't go.  So, you would need to construct a function that checks for the email address.

Something like:  

Function checkEmailAddress(theseNames as variant) as boolean
checkEmailAddress = False
' do your lookups to the nab, $USERS view - if the entry, or entries exist then return true.
'If the original agent does a large number of newsletters, then it is best to instantiate the NAB at the top of the
'agent and make sure it's open.  Else your agent will run very slow opening the nab for each name check.
end Function

Then go back to your original code:

Dim result as noolean
result = checkEmailAddress(varSendTo)
if result then
  doc.send(false, varSendTo)
else
  'whatever you want to do when the address is incorrect
end if
0
 
marilyngCommented:
Oops, missing "end if"

if doc.hasItem("NotifyGroup") then
  if len(doc.getItemValue("NotifyGroup")(0))>0 then
       varSendTo=doc.getItemValue("NotifyGroup")
  else
         varSendTo = "ThisDefaultSendToNameThatYouKnowExists"
 end if
end if '<< missing this one.
0
 
AliciaVeeAuthor Commented:
maryilng,

I've tried the first portion of your code:

Dim varSendTo as variant
if doc.hasItem("NotifyGroup") then
  if len(doc.getItemValue("NotifyGroup")(0))>0 then
       varSendTo=doc.getItemValue("NotifyGroup")
  else
         varSendTo = "ThisDefaultSendToNameThatYouKnowExists"
 end if

  Doc.SendTo = varSendTo

and put my name in the else part of varSendTo

The good news is that I don't get an error message -- but, the bad news is I don't get anything.  I go back to hard coding my name in and I am getting the right documents.  This is a real puzzle huh?

I don't think my database will pass our standards if I do a lookup to the address book via LotusScript (IT doesn't like that), so I will have to avoid that part -- and by using a profile document, it will help to keep the names correct, so the NotifyGroup will read the global variable from the profile document.

Anything else I can try?  Not sure IT will pass my database if I hard code the send name in the script, but I do have that route to take -- at least it is working.  What else can I try/test?

AliciaVee
0
 
Sjef BosmanGroupware ConsultantCommented:
> NotifyGroup is a field in the document frmDoc
Still don't see frmDoc anywhere in your code (looking at the Initialize in your question above). Can you give us the full code then?
0
 
marilyngCommented:
It's in the select statement, and returns the collection.  AH!  headlight.. thanx for the idea, sjef.

you have to select one document from the collection to get the value.

If ( collection.Count > 0 ) Then
  dim frmDoc as NotesDocument, varSendTo as variant
 'Present this to something you know exists
  varSendTo = "ThisDefaultSendToNameThatYouKnowExists"
  set frmDoc = collection.getFirstDocument
 if not frmDoc is nothing then
  if frm.hasItem("NotifyGroup") then
  if len(frmdoc.getItemValue("NotifyGroup")(0))>0 then
       varSendTo=frmDoc.getItemValue("NotifyGroup")
   end if
 end if
  set frmDoc = nothing
end if
 
 Doc.SendTo = varSendTo
0
 
AliciaVeeAuthor Commented:
okay,  I've got the following code, and had to change a few things -- thinking that frmdoc should have really been frmDoc and Doc.SendTo should have been doc.SendTo -- but now I'm not sure.  I get an "Object Variable Not Set".  I put the debugger on and it looks like NotifyGroup is grabbing the correct email from that field.  The debugger stops at the last line:

doc.SendTo = varSendTo

So, I'm not sure what is wrong here.  I can feel we are close....below is all of the code, can you spot something? I also think I removed a section, where I wasn't supposed to?  I don't see any of the following code in the new "If(collection).." code -- I didn't know what I was supposed to remove and/or add:


So, I removed this from the code that was working:

                 If ( collection.Count > 0 ) Then
          Set newsletter = session.CreateNewsletter( collection )
          Set  doc= New NotesDocument(db)
          newsletter.DoScore = False           'if you don't want relevance score
          newsletter.DoSubject = True          'to be able to specify subject of each doc
          newsletter.SubjectItemName = "Title"     'name of the item in the doc which contains the subject
          Set doc = newsletter.FormatMsgWithDoclinks( db )
          doc.Subject = "SUBJECT OF YOUR NEWSLETTER"
                                doc.Form = "Memo"                              
          Call doc.Send (False, "YourEmailAddress")
     End If

And now it looks like this:


===================================
Sub Initialize
      
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim collection As NotesDocumentCollection
      Dim newsletter As NotesNewsletter
      Dim doc As NotesDocument
      Dim SearchFormula As String
      Set db = session.CurrentDatabase
      
      SearchFormula = {(Form = "frmDoc") & (whenAL  = @Yesterday)}
      Set collection = db.Search ( SearchFormula, Nothing, 0 )
      
      If ( collection.Count > 0 ) Then
            Dim frmDoc As NotesDocument, varSendTo As Variant
             'Present this to something you know exists
            varSendTo = "My Name/XXX/My Company"
            Set frmDoc = collection.getFirstDocument
            If Not frmDoc Is Nothing Then
                  If frmDoc.hasItem("NotifyGroup") Then
                        If Len(frmDoc.getItemValue("NotifyGroup")(0))>0 Then
                              varSendTo=frmDoc.getItemValue("NotifyGroup")
                        End If
                  End If
                  Set frmDoc = Nothing
            End If
            frmDoc.SendTo = varSendTo
      End If
      
End Sub
0
 
marilyngCommented:
AliciaVee,

Well, now you removed your newsletter stuff :))

    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim collection As NotesDocumentCollection
    Dim newsletter As NotesNewsletter
    Dim doc As NotesDocument
    Dim SearchFormula As String
    Set db = session.CurrentDatabase
   
    SearchFormula = {(Form = "frmDoc") & (whenAL  = @Yesterday)}
    Set collection = db.Search ( SearchFormula, Nothing, 0 )
   
    If ( collection.Count > 0 ) Then
        Dim frmDoc As NotesDocument, varSendTo As Variant
           'Present this to something you know exists
        varSendTo = "My Name/XXX/My Company"
        Set frmDoc = collection.getFirstDocument
        If Not frmDoc Is Nothing Then
            If frmDoc.hasItem("NotifyGroup") Then
                If Len(frmDoc.getItemValue("NotifyGroup")(0))>0 Then
                    varSendTo=frmDoc.getItemValue("NotifyGroup")
                End If
            End If
            Set frmDoc = Nothing
        End If
        Set newsletter = session.CreateNewsletter( collection )
        Set  doc= New NotesDocument(db)
        newsletter.DoScore = False           'if you don't want relevance score
        newsletter.DoSubject = True          'to be able to specify subject of each doc
        newsletter.SubjectItemName = "Subject"     'name of the item in the doc which contains the subject
        Set doc = newsletter.FormatMsgWithDoclinks( db )
        doc.Form = "Memo"
        doc.Subject = "Testing Newsletter"        
        doc.sendTo = varSendTo
        Call doc.Send (False)
    End If
0
 
Sjef BosmanGroupware ConsultantCommented:
I feel we're stumbling around a little, we've got to step back a little further. Still beats me that EVERY document of the collection apparently contains a NotifyGroup. I sense that there is a serious flaw in the logic. Alicia, Could you please describe in words/pseudo-code what your code is supposed to do? If I'm not mistaken, you'll find out for yourself whether there is something wrong with the logic.
0
 
AliciaVeeAuthor Commented:
maryling,

Yeah -- I thought I wasn't supposed to do that -- but didn't know exactly where to put the new collection code.  I will try this when I get into the office (am doing my 30 mins cardio this early in NJ-- he he he)

sjef,
This is what I need.  NotifyGroup is a field in form Document (frmDoc) that is prepopluated with someones name.  I will be changing that to grab from a profile doc so that it can be changed if needed by the users.  This database holds inportant documents -- not a lot --max maybe 300.  If a file is changed in any of the documents, an alert should be sent to the one person, and for some documents, there might be two people listed.  NotifyGroup is a Names field with choice address book as list (but has one name as a default).

The search should be only documents that are created with frmDoc and I have a field that tracks when an attachment is added, removed, or edited and that is held in field whenAL.

0
 
Sjef BosmanGroupware ConsultantCommented:
You posted at 05:43 local time?? Wow...

> If a file is changed in any of the documents, an alert should be sent to the one person...
Is the message to be sent to the person(s) mentioned in THAT particular document??
0
 
AliciaVeeAuthor Commented:
maryling,

Yes -- it is beautiful.  Works great.  Thanks!

sjef -- yeah 05:43, but I had been up an hour before then (4:45am).  Am training for a mini-Triathalon, in between my spare time...ha ha ha.  

AliciaVee
0
 
marilyngCommented:
Now, not sure about the NotifyGroup.. so let's see if I can provide an analogy..

Your collection grabs a set of documents  using frmdoc and modified yesterday.. say 100.

If all of these notifyGroup values in all 100 documents are the same, then grabbing the group off the first document in the collection is OK.

If the first 10 have notifygroup="abc", and next 10 have "bbb", then you're gonna have to approach this differently, and sort the collection by notify group and recollect based on each group name.

In short, sjef's concern is correct.
0
 
AliciaVeeAuthor Commented:
Ah...I got it -- and yes, there is a possibility of having two names that may be different, but more than not, it will be just one name.  So long as I know this issue, I'll explain it to the person who will be handling and if needed, I'll have to update that code to allow for more than one name.

Will the edit for this requirement be complicated?  Should I post another question for the solution?  Would like to have it sooner rather than later...

let me know...

Thanks!!
0
 
Sjef BosmanGroupware ConsultantCommented:
You said somewhere before that you intended to use a profile form for this. That would be an excellent solution.
0
 
AliciaVeeAuthor Commented:
sjef,

yes, thanks -- I also thought so too.  But then I realized that the reason for the multiple names would be to allow some people to be notified only if key (or critical) documents file attachment changes.  So, unless I'm wrong, if I allow the profile document to store the value of what would be grabbed from the NotifyGroup field on the frmDoc form -- then it would replace a single user name, if the name(s) changed in the profile field?  Not sure here...but would love to hear your thoughts on how this could work?

AliciaVee
0
 
Sjef BosmanGroupware ConsultantCommented:
I understand your point of view. If I understand this correctly, you have the problem that you want to send different newsletters to different people. An example:
- document A contains NotifyGroup "standard"
- document B contains NotifyGroup "standard, John Doe"
- document C contains NotifyGroup "John Doe"

Which means that a newsletter with documents A and B should be sent to standard and a second newsletter for documents B and C should be sent to John Doe? Am I right? For this general problem, I wouldn't know a suitable solution immediately, minimizing the number of newsletters sent...

Maybe it's easier to create a categorized view, first column NotifyGroup, and prepare a newsletter per category?
0
 
marilyngCommented:
Yup, that's what I would do..
0
 
Sjef BosmanGroupware ConsultantCommented:
The challenge is how to find out that two people will receive exactly the same newsletter. Haven't found out how to do that yet... The amount of processing required might be huge compared to the gain you could have. If I really had to, I'd try with a List As Integer, then use a sorted concatenation of Note-ID's as key etc. The whole idea of the NotesNewsletter would be compromised, I think. So go on the easy side: generate a newsletter per person, and who cares about some additional mails.
0
 
AliciaVeeAuthor Commented:
sjef and marylng -- Wow!  Thanks for some very informative tips and techniques.  For now, what I have will work, and there will be some limitations, but the user is okay with that and 99% of the time, it will be only her that needs to know about the change in the file attchment.  Would be great if I can have more than one name, for "some" docs, but it will be so little it is not worth the extra work.

But thanks so much for keeping this thread going -- even after it has been closed!

Alicia
0
 
marilyngCommented:
You're welcome!
0
 
Sjef BosmanGroupware ConsultantCommented:
Theseus is my middle name... ;)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 11
  • 9
  • 8
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now