Community
Showing results for 
Search instead for 
Do you mean 
Reply

Deleting Attachments from Opportunities via SDK -> Mostly works but synchronized machines do not delete the actual files

New Member
Posts: 1
Country: Canada

Deleting Attachments from Opportunities via SDK -> Mostly works but synchronized machines do not delete the actual files

Hello.  I'm a new member to the community but I've been working with the Act SDK for a little while now, and have read these forums for guidance.

I am using Act Premium 2012.  I've made a little program that purges certain attachments from opportunities when they get to a certain age.  After I query which opportunities have the attachments to remove, I run the following code to delete the attachments:

foreach (Opportunity opportunity in opportunitiesToDeleteAttachmentsFrom)
{
    HistoryList historyList = actFramework.Histories.GetHistories(null, opportunity,
        new IFilterCriteria[] { 
            new ComparisonFilterCriteria(actFramework.Histories.GetFieldDescriptor("HISTORYTYPEID"), ComparisonFilterCriteria.Operation.Equals, -1)
        }, false);
    foreach (History history in historyList)
    {
        actFramework.Histories.DeleteHistory(history);
    }
}

This appears to work well on the master database that the software does the work on.  The files themselves are deleted from the attachments folder.  However when the changes are synchronized to other clients using Act Synchonization, the files themselves in the attachments folder are not deleted from the client computers.  The references to the files are deleted properly on the client machines (in TBL_HISTORY, TBL_OPPORTUNITYHISTORY, AND TBL_ATTACHMENT)  so the attachments no longer appear in the ACT clients, but the files are still there on the client hard drives.  If you delete the attachments using the Act client on the master database computer as opposed to using the SDK calls above, then the synchronized clients do seem to delete the attachments properly...  Any ideas?