Community
Showing results for 
Search instead for 
Do you mean 
Reply

Programatically triggering Write Other for a different Contact

Tuned Listener
Posts: 15
Country: United_Kingdom

Programatically triggering Write Other for a different Contact

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

 

Tuned Listener
Posts: 15
Country: United_Kingdom

Re: Programatically triggering Write Other for a different Contact

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

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Programatically triggering Write Other for a different Contact

I have never used WriteOther but it sounds like it is using the current contact shich you can change like so...

 

ACTApplication.ApplicationState.CurrentContact = MyCurrentContact

 

-- Jim Durkin

Tuned Listener
Posts: 15
Country: United_Kingdom

Re: Programatically triggering Write Other for a different Contact

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