AddIns - Add items to interfaced lists

Within the AddIn Framework there are a number of lists on workspace contexts that contained an Interfaced type (something along the lines of IList<IInc2Contact>). In early versions of the framework there was no way to actually create an instance of the object, so to be able to add a single item to the list you had to implement the whole interface. There is another, largely unknown, option however for a number of supported interfaces:


AddInViewsDataFactory.Create<T>()

The currently supported interfaces are (these can be determined at runtime by using AddInViewsDataFactory.IsSupported<T>()):

  • IReportFilter2
  • IReportFilter
  • IProd2Quote
  • IQuote
  • IOrgAddr
  • IOpp2Contact
  • IFAttachOpp
  • IThread
  • ITimeBilled
  • IFAttachTmp
  • IIncResponse
  • IInc2Contact
  • IFAttachInc2
  • IFAttachNest
  • INote
  • IFAttachAns2
  • ILinks
  • IFAttachCO
  • IDataValue

For example the following could be used (after populating a few more required fields) to add a file attachment to an incident:

IIncident incidentContext = (IIncident)context.GetWorkspaceRecord(WorkspaceRecordType.Incident);

IFAttachInc2 newFileAttachment = AddInViewsDataFactory.Create<IFAttachInc2>();
newFileAttachment.Name = "Uploaded by an addin";
//populate additional fields

incidentContext.FAttach2.Add(newFileAttachment);

Comments

Can You please provide the code to create a new Ithread and add to an IIncident object

Zircon - This is a contributing Drupal Theme
Design by WeebPal.