06-04-2013 04:53 AM
Hi
I am trying to programatically create documents using WriteOther from within a plugin, but using a contact other than the ApplicationState.CurrentContact. I have passed the actApp to the plugin, so have access to all I would have as my current logged in user. delContact is the new delivery Contact (different to the current contact).
MsgBox(actApp.ApplicationState.CurrentContact.FullName) 'Mr. Smith actApp.ApplicationState.CurrentContact = delContact 'delContact = Mr. Jones MsgBox(actApp.ApplicationState.CurrentContact.FullName) 'Mr. Jones Dim UIcm As UICorrespondenceManager = actApp.UICorrespondenceManager UIcm.WriteOther("templateDocumentName") UIcm.Dispose()
This reports the initial CurrentContact.FullName (Mr. Smith), and after the assignment reports the newly assigned CurrentContact.FullName (Mr. Jones).
However the document still mailmerges with the original contact details for Mr. Smith.
What do I have to do to trigger use of Mr. Jones's contact details in the mail merge?
Cheers
Richard Kempton
06-04-2013 06:58 AM
Incidentally, although I can use UIcm.WriteOther(delContact) to do a mailmerge with the contact I want, this does not allow me to programatically set the template.
What would be ideal would be:
UIcm.WriteOther("templateDocumentName", delContact)
Any help appreciated.
Richard
06-04-2013 01:30 PM
06-06-2013 07:59 AM
Hi Jim
Sorry, I tried that (as my example showed).
I have just found the solution. Apparently the WriteOther uses the CurrentContactList, with the only entry being the current contact.
So, when I add the following, it works!
actApp.ApplicationState.SetCurrentContactList(actApp.ActFramework.Contacts.GetContactAsContactList(delContact), Nothing)
Thanks for looking.
Richard