Listbox and choice?

I have a listbox with the names of employees displaying. Now I need that when one or more of the employees are selected an e-mail agent can be kicked off.

How best can I tell which employee name was selected?

Thanks,

Subject: Listbox and choice?

Assuming formula language: type the name of the field.

Subject: RE: Listbox and choice?

I’m not sure what you mean? I’m trying something similar to the code below. The agent isn’t triggering. Any ideas? Thanks!

@If(lkpNon = 1;@Command([ToolsRunMacro];“Manual”);“”);

Subject: RE: Listbox and choice?

Web or notes?agent triggered on saving doc, after saving doc? or immediately?

wot do you want the agent to do?

(fire off an email to that person?)

More details!!!

Subject: RE: Listbox and choice?

I’ve got the agent running but it wasn’t picking up the employee name in the field called “Test”.

I’ve made changes to try and better capture the name and I’m getting an error message in debugger of: Variant does not contain an object.

It seems to be having problems with my setting of the sourceDoc. Sorry, my script is poor.

'This agent is used to capture the electronic signature of the user and compose acknowledgment.

Sub Initialize

Dim s As New NotesSession

Dim targetDb As NotesDatabase

Dim targetDoc As NotesDocument

Dim sourceDoc As NotesDocument

Dim dateTime As NotesDateTime







Set targetDb = s.CurrentDatabase

Set targetDoc = targetDb.CreateDocument

Set sourceDoc = source.CurrentDocument

targetDoc.Form = "Acknowledgment"

targetDoc.empName = sourceDoc.test	

Set dateTime = New NotesDateTime(Format$(Now,"Long Date"))

Call targetDoc.ReplaceItemValue("Date", dateTime)

Call targetDoc.Save( False, False )

End Sub

Subject: RE: Listbox and choice?

Your erro is coming from the line where you set the sorceDoc because source has never been set before. So, it does not contain any object.

Subject: RE: Listbox and choice?

Can you advise how best to fix my code? Thanks!

Subject: RE: Listbox and choice?

(In my first post I assumed too much; namely that you’d be firing off the email from formula language code written in the form.)

As Leo posted, we need to know what fires this agent. WebQuerySave? New/Modified trigger? Notes client? Web client? There’s no way to tell you how to write it correctly without knowing these things.

If it’s a webquerysave agent, for example, you’d use db.documentcontext, while a modified-triggered agent would likely use db.unprocesseddocuments.

Subject: RE: Listbox and choice?

This agent is triggered via a button on the Notes client. I have a field on the form called “Test” which captures the value of the listbox when an employee name is selected.

Thanks,

Subject: RE: Listbox and choice?

Dim s As New NotesSessiondim ws as New NotesUIWorkspace

dim uidoc as NotesUIdocument

set uidoc=ws.CurrentDocument

Dim targetDb As NotesDatabase

Dim targetDoc As NotesDocument

Dim sourceDoc As NotesDocument

set sourcedoc=iodoc.document

Dim dateTime As NotesDateTime

Set targetDb = s.CurrentDatabase

Set targetDoc = targetDb.CreateDocument

Set sourceDoc = source.CurrentDocument

targetDoc.Form = “Acknowledgment”

targetDoc.empName = sourceDoc.test(0)

Set dateTime = New NotesDateTime(Format$(Now,“Long Date”))

Call targetDoc.ReplaceItemValue(“Date”, dateTime)

Call targetDoc.Save( False, False )

Subject: File Save - How do I handle an array?

Thanks, File Save!I’ve replaced my code with yours but I’m still erroring out with a variant does not contain an object message. My field named “Test” contains multiple employee names.

I’ve been researching and found that its because it see the contents of that field as an array? Its a list of employee names. How do I handle an array? I’ve never worked with one before.

Subject: RE: File Save - How do I handle an array?

This goes back to the code i posted back when for you. It is all covered in there.

Subject: File Save - Hmmm?

I’m sorry, I don’t follow you. You mean this code or that in another thread somewhere? This is the code that I’d placed in my form butI continue to get the error message variant does not contain an object.

Can I get you to share with me your thinking on the “set sourcedoc=iodoc.document” line of code? What does the iodoc mean? Thanks!

Dim s As New NotesSession

dim ws as New NotesUIWorkspace

dim uidoc as NotesUIdocument

set uidoc=ws.CurrentDocument

Dim targetDb As NotesDatabase

Dim targetDoc As NotesDocument

Dim sourceDoc As NotesDocument

set sourcedoc=iodoc.document

Dim dateTime As NotesDateTime

Set targetDb = s.CurrentDatabase

Set targetDoc = targetDb.CreateDocument

Set sourceDoc = source.CurrentDocument

targetDoc.Form = “Acknowledgment”

targetDoc.empName = sourceDoc.test(0)

Set dateTime = New NotesDateTime(Format$(Now,“Long Date”))

Call targetDoc.ReplaceItemValue(“Date”, dateTime)

Call targetDoc.Save( False, False )

Subject: Its a typo. Try: set sourcedoc = uidoc.document

Subject: Corrected typo but still same error

Thanks, I’ve made the correction but now I’m receiving the error message on the following line of code.

Set sourceDoc = source.CurrentDocument

Full Code is shown below:

Sub Initialize

Dim s As New NotesSession

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIdocument

Set uidoc=ws.CurrentDocument

Dim targetDb As NotesDatabase

Dim targetDoc As NotesDocument

Dim sourceDoc As NotesDocument

Set sourcedoc=uidoc.document



Dim dateTime As NotesDateTime







Set targetDb = s.CurrentDatabase

Set targetDoc = targetDb.CreateDocument

Set sourceDoc = source.CurrentDocument

targetDoc.Form = "Acknowledgment"

targetDoc.empName = sourceDoc.test(0) 

Set dateTime = New NotesDateTime(Format$(Now,"Long Date"))

Call targetDoc.ReplaceItemValue("Date", dateTime)

Call targetDoc.Save( False, False ) 

End Sub

Subject: RE: Corrected typo but still same error

Remove the line – you already have sourcedoc set to uidoc.Document.

Subject: Thanks everyone!

Never mind! I found this problem and now the agent is kicking off successfully!

Thanks to everyone!

Subject: Urghhhhhhhh

Subject: RE: Listbox and choice?

Angie tends to add details piecemeal (sorry Angie, but that has been my experience).

Subject: RE: Listbox and choice?

Sorry guys,I guess I tend to think these are simple tasks for everyone but me. I’ll try and be more detailed in the future.