Community
Showing results for 
Search instead for 
Do you mean 
Reply

How to attach files to Group or Companies using C# SDK?

New Member
Posts: 2
Country: USA

How to attach files to Group or Companies using C# SDK?

I'm developing an ACT integration in C# to automatically upload attachments into ACT. I'm able to attach files to Contacts using the following code:

 

public void AttachDocumentToContact(string contactId, string filePath, string displayname)
{
    _framework = new ActFramework();
    _framework.LogOn("act-db", "act-username", "act-password");
    
    HistoryType documentType = _framework.Histories.GetHistoryType("Library Document");
    Attachment attachment = _framework.SupplementalFileManager.CreateAttachment(AttachmentMate.History, filePath, displayname, false);

    var myContact = _framework.Contacts.GetMyRecord();
    var contact = _framework.Contacts.GetContactsByID(null, new[] { Guid.Parse(contactId) })[0];

    History h = _framework.Histories.CreateHistory(contact, myContact.ID, documentType, false, DateTime.Now, DateTime.Now, "", "", attachment);
}

 

 This works for attaching files to Contacts, however I don't see equivalent methods for attaching to Groups or Companies.  Am I going about this the right way?  Thanks for any insight you can provide.

New Member
Posts: 2
Country: USA

Re: How to attach files to Group or Companies using C# SDK?

I was able to attach the same file to a company by appending the following code to the snippet above:

 

var companyList = _framework.Companies.GetCompaniesByID(null, new[] {Guid.Parse(companyId)});

h.CompanyList = companyList;
h.Update();

The trick is to completely replace the CompanyList or GroupList properties of the history with the associations you want.

 

I'd still like to know if there are any other approaches to this that may be better.