Solved

Sending mail from a form designed on Lotus hosted in Web

Posted on 2006-07-07
15
279 Views
Last Modified: 2013-12-18
Hi

Could you Please help me urgently.

I am basically an Lotus Domino Administrator and had been asked to develop small application on Lotus which is Requestor will submit his request through web and the same application will be accessed by approvers through lotus client and approve their requests.

In this scenario, there is a submit request button. Once the requestor fills the relevant details and clicks the submit button on web, immediately a mail should be sent to the approver about the new request for his action.
The approver is available in a field. All are internal users on the same server, but the requestors will access this form over web.

I had used a agent with send a mail in webquerysave. But its not working. When I used @mailsend in webquerysave, it sends mail when the requestor submits his request. But it goes with the server name and also I need a popup on the browser, once the requestor clicks the submit request button. I was trying to get the solution for the last 14 hours.
Nothing is working for me. Could anyone help me urgently on this?

I need bring it to online by tomorrow nite(deadly timeline)

Thanking You
0
Comment
Question by:deivakumar
  • 8
  • 7
15 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Seems right to me. What's the code you use in the WebQuerySave agent?

Ehm, we don't like threats about deadlines and so... ;) but we'll try to help!
0
 

Author Comment

by:deivakumar
Comment Utility
Sorry my friend! if the deadline hurts........................ Looking for your help thanks

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

Please find the agent (SendMail) which is in agent with the following settings.

Shared
Trigger - on event
Runtime - Action Menu Selection
Target - All new and modified Documents
------------------------------
The following code is available in agent - intialize

Dim session As New NotesSession
      Set db = session.CurrentDatabase
      Set maildoc = db.CreateDocument
      Dim doc As notesDocument
      Dim rtitem As NotesRichTextItem
      Dim Body As NotesRichTextItem
      
      Set doc = session.DocumentContext
      tmpreqname=doc.Txt_Author
      tmpcontact=doc.ID
      
      maildoc.Form = "memo"
      maildoc.SendTo = doc.Analyst
      maildoc.Subject = "You have a new request from "+tmpreqcomp
      Set Body=New NotesRichTextItem(maildoc,"Body")
      Set rtitem = New NotesRichTextItem( maildoc, "Body" )
      message="Please review new request from "+ tmpreqname+" from "+tmpreqcomp+"."
      Call rtitem.AppendText(message)
      Call Body.AddNewLine(2)
      message1="Click here to open the form=========>>"
      Call Body.AppendText(message1)
      Call Body.AppendDocLink(doc,"Please Click this Link to open the Document")
      Call maildoc.send(False)

In this code, Txt_Author is a computed field having formula ( @Name([CN];@UserName) ) and ID is an another computed field ( which is generating a request id based on time and date) and  Analyst is the field, where the approvers mail Id are stored will be selected by another field based on their respective region.

I dont' want to send any text or anything on body of the mail. Just to send a mail in the subject saying that a request with ID no from the field - ID is waiting for your approval.

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

The following formula had been available at webquerysave

@Command([RunAgent];MailSend)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Probably the agent never ran. The target is wrong, it has to be None.

From the Designer Help db:
Using the Agent Properties box, do the following:
- Check the "Shared" option when you create the agent.
- Set the agent trigger to "On event" and either "Agent list selection" or "Action menu selection."
- Set the agent target to "None" for agents that work on the current document such as those launched from WebQueryOpen or WebQueryClose, or a form action or hotspot that works on fields in the current document.

Otherwise, I think you would have seen errors in the log.nsf database. Also, creating two richtext items with the name Body is impossible.

Dim session As New NotesSession
     Set db = session.CurrentDatabase
     Set maildoc = db.CreateDocument
     Dim doc As notesDocument
     Dim rtitem As NotesRichTextItem
     Dim Body As NotesRichTextItem
     
     Set doc = session.DocumentContext
     tmpreqname=doc.Txt_Author(0) ' <---
     tmpcontact=doc.ID(0) ' <---
     
     maildoc.Form = "memo"
     maildoc.SendTo = doc.Analyst(0) ' <---
     maildoc.Subject = "You have a new request from "+tmpreqcomp
     Set Body=New NotesRichTextItem(maildoc,"Body")
'     Set rtitem = New NotesRichTextItem( maildoc, "Body" ) ' <---
     message="Please review new request from "+ tmpreqname+" from "+tmpreqcomp+"."
     Call Body.AppendText(message) ' <---
     Call Body.AddNewLine(2)
     message1="Click here to open the form=========>>"
     Call Body.AppendText(message1)
     Call Body.AppendDocLink(doc,"Please Click this Link to open the Document")
     Call maildoc.send(False)
0
 

Author Comment

by:deivakumar
Comment Utility
I had done the following changes. Could you please review and advise?

Shared
Trigger on event
Runtime - Action Menu Selection
Target - None.

----------------------------------------------------------------------
Dim session As New NotesSession
      Set db = session.CurrentDatabase
      Set maildoc = db.CreateDocument
      Dim doc As notesDocument
      Dim rtitem As NotesRichTextItem
      Dim Body As NotesRichTextItem
      
      Set doc = session.DocumentContext
      tmpreqname=doc.Txt_Author
      tmpcontact=doc.ID
      
      maildoc.Form = "memo"
      maildoc.SendTo = doc.Analyst
      maildoc.Subject = "You have a new request from "+tmpreqname
      Set Body=New NotesRichTextItem(maildoc,"Body")
      message="Please review new request from "+ tmpreqname+" from "+tmpcontact+"."
      Call maildoc.send(True)

------------------------------------------------------------------------------------
If I run this agent from designer then it gives an error saying that " object variable not set "

At end, there is no mail has been sent to the requestor
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
You can't run the agent from the Designer, because there is no current document, hence doc is Nothing, so the code will stop at the first line where the object doc is used. You have to run it as a web agent.

Secondly, the message isn't put into the mail. The following is allowed:
    Call Body.AppendText("Please review new request from "+ tmpreqname+" from "+tmpcontact+".")

Thirdly, you didn't copy all the code I changed above. It is maybe strange, but a reference to a field in a document yields an array. In the Notes object system, ALL NotesItems are potentially multi-value. So, if there is only one value, you still have to get the first value of the array. E.g. with Txt_Author:
    tmprequname= doc.Txt_Author
will stop execution right there, because you try to assign an array to a String variable... ah, now I see, tmpreqname isn't declared, therefore a Variant by default, and the statement is permitted. It will set the value of tmpreqname to an array. What you need is the first value of the aray:
    tmprequname= doc.Txt_Author(0)

And make it a good habit to declare ALL variables before you use them. To assist you, set Option Declare in the option section of the module. In the Programmer's Pane Properties, 2nd tab, you can set "Automatically add 'Option Declare' ".

If you want to follow the execution of a web agent, you can add some MsgBox calls. The output is sent to log.nsf and not to a screen. Like this:

     Dim session As New NotesSession
     Set db = session.CurrentDatabase
     Set maildoc = db.CreateDocument
     Dim doc As notesDocument
     Dim Body As NotesRichTextItem
     Dim tmpreqname As String
     Dim tmpcontact As String
     
     Set doc = session.DocumentContext
     tmpreqname=doc.Txt_Author(0)
     tmpcontact=doc.ID(0)
     
     maildoc.Form = "Memo"
     maildoc.SendTo = doc.Analyst(0)
     maildoc.Subject = "You have a new request from "+tmpreqname
     Set Body=New NotesRichTextItem(maildoc,"Body")
     Call Body.AppendText(Please review new request from "+ tmpreqname+" from "+tmpcontact+".")
     Call Body.AddNewLine(2)
     Call Body.AppendText("Click here to open the form=========>>")
     Call Body.AppendDocLink(doc,"Please Click this Link to open the Document")
     Call maildoc.send(False)
0
 

Author Comment

by:deivakumar
Comment Utility
hi it looks like working but the doc.Analyst should be selected based on the other field.
ex. If the field Region is populated with " Tunis " by user, then the mail should be sent to approver " User1"
If the field Region is populated with "Congo" by user, then the mail should be sent to approver "User2"

Now all the approvers listed in a field "Analyst" which was manually selected by the requestors. I want to hide the approvers name from the requestors. The requestors should select only regions and mails should be sent to respective approvers.

Sorry for bothering you much........... Since Im just few steps away from hosting this apps, request your help on this.

thanks
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Several ways to do that, this is the simplest.

field Region, Dialog list, editable, with all regions.

field Analyst, computed, formula:
    regions:= "Tunis":"Congo":"Anywhere":....;
    approvers:= "User1/ACME":"User2/ACME":"User1/ACME":...;
    @Replace(Region; regions; approvers)

These two lists have to be of the same length.

The next step could be that you remove names and regions from the source code of the form, and you develop a simple form with Analyst and Region, and a view, so you can do a @DbLookup.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:deivakumar
Comment Utility
thanks, its working for region with one approver.

here i hv another problem. for few regions, there are two approvers, both must be notifed on the same request.

how we can achieve this? appreciate ur kind help.thanks
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
That's your 3rd question... ;)

field Analyst, computed, formula:
    regions:= "Tunis":"Congo":"Anywhere":....;
    approvers:= "User1/ACME":"User2/ACME;User4/ACME":"User1/ACME":...;
    @Explode(@Replace(Region; regions; approvers); ";")

In one entry in the approvers list, put two names, separated by a ";"
0
 

Author Comment

by:deivakumar
Comment Utility
Thanks friend! Can I add one more request.

How can you have unique request IDs for all the requestors? Pls. help. Thanks
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 500 total points
Comment Utility
Yes, my friend, you can add one more question, but I won't answer it here :)

Better create a new question, because it has nothing to do with the original subject.
0
 

Author Comment

by:deivakumar
Comment Utility
OK. Will do the same.Thanks for your continuous support.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Ah, you gave a B. Which means you're not fully satisfied? I even answered THREE questions! Could you please reconsider? Do read
    "How to grade" http://www.experts-exchange.com/help.jsp#hi73
0
 

Author Comment

by:deivakumar
Comment Utility
No probs! my dear friend! can be esclated to A!
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Smashing! If you would be so kind to post a (free) question in the Community Support TA?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
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.
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

6 Experts available now in Live!

Get 1:1 Help Now