Add Attachments to a Contact Record

To complete his admission formalities, Matt Grammer, a lead at Northside School of Engineering, attaches copies of recommendation letters and previous education grades in his email to the university. When Matt sends these details, the attachments are automatically added to the Attachments tab of Matt’s contact record.

  1. Launch Workflow Composer.

  2. Click New Event Workflow.

  3. In the Name field, type a name for the workflow (e.g., AddingAttachment)

  4. In the Entities area:

    1. Click select next to Cmc.Core.Eventing.

    2. Select Void (VoidEntity). Select the appropriate entity for which the workflow must be triggered.

  5. In the Events area, click Saving (SavingEvent). In this step, ensure that you select the appropriate event for the entity selected in the previous step.

  6. Click OK. The sequence is created in the Designer pane.

Retrieve the Contact Entity and its Associated Previous Education Records

  1. In the Variables pane, create a variable for the contact object, e.g., contact, and select Cmc.NexusCrm.Common.Entities.Contact in the Variable type column

  2. In the Toolbox, under Cmc.Core.Workflow.Activities.EntityModel, select the GetEntity<> activity and drop it into the Designer pane. The Select Types dialog box is displayed.

    1. In the TEntity drop-down list, select Browse for Types. The Browse and Select a .Net Type window is displayed.

    2. In the Type Name field, type Contact. The Contact object is selected under Cmc.NexusCrm.Common.Entities.

    3. Click OK twice. The Contact object is added to the GetEntity<> activity in the sequence.

    4. In the Toolbox, specify the entity identifier in the EntityId field.

    5. In the Result field, type the name of the variable created previously (contact). This entity will be retrieved in this workflow activity.

  3. In the Toolbox, under Cmc.NexusCrm.Common.Workflow, select the GetRelatedEntity<> activity and drop it into the Designer pane. The Select Types dialog box is displayed.

    1. In the TEntity drop-down list, select Cmc.NexusCrm.Common.Entities.Contact and click OK.

    2. In the Toolbox, select the parent entity in the ParentEntity field, e.g., contact.

    3. In the Type Name field, type Contact. The Contact object is selected under Cmc.NexusCrm.Common.Entities.

    4. In the RelatedEntityName field, type the name of the related tab that needs to be fetched, e.g., ContactPreviousEducations.

Create a New Previous Education Record

  1. In the Variables pane, create a variable for the lead, e.g., previousEducation, and select Cmc.NexusCrm.Common.Entities.ContactPreviousEducation.

  2. In the Toolbox, under Cmc.Core.Workflow.Activities.EntityModel, select the CreateEntity<> activity and drop it into the sequence. The Select Types window is displayed.

    1. In the TEntity drop-down list, select Browse for Types. The Browse and Select a .Net Type window is displayed.

    2. Select ContactPreviousEducation and click OK twice. The Lead object is added to the CreateEntity<> activity in the sequence.

    3. In the Result field of the Properties pane, specify the name of the variable created above, e.g., previousEducation.

Assign Relationship Property Values to the Previous Education Record

  1. From the Toolbox, drop an Assign activity for each row in the following table and type the indicated values:

    To Value
    previousEducation.ContactPreviousEducationId 1
    previousEducation.Gpa 4

    In this step, the details of the new previous education record are set. The contact will be associated with the account instance assigned to previouEducation.ContactPreviousEducationId.

  2. To add the previous education record to the previous education collection, drop the AddToCollection<> activity into the Designer pane.

  3. Type or select the following details in the Properties tab:

    • Collection — AddToCollection<ContactPreviousEducation>
    • Item — previousEducation
    • TypeArgument — Cmc.NexusCrm.Common.entities.ContactPreviousEducation

Retrieve Attachments of the Contact Record

  1. In the Toolbox, under Cmc.NexusCrm.Common.Workflow, select the GetRelatedEntity<> activity and drop it into the Designer pane. The Select Types dialog box is displayed.

    1. In the TEntity drop-down list, select Browse for Types. The Browse and Select a .Net Type window is displayed.

    2. In the Type Name field, type Contact. The Contact item is selected in Cmc.NexusCrm.Common.Entities.

    3. Click OK twice.

    4. In the Toolbox, select the parent entity in the ParentEntity field, e.g., contact.

    5. In the Type Name field, type Contact. The Contact object is selected under Cmc.NexusCrm.Common.Entities.

    6. In the RelatedEntityName field, type the name of the related tab that needs to be fetched, e.g., “Attachments”.

Set Attachment File Name and File Content

  1. In the Variables pane, create a variable called marksAttachment. In the Variable type column, select Cmc.NexusCrm.Common.Entities.Attachment.

  2. In the Default column, type new Attachment().

  3. From the Toolbox, drop an Assign activity for each row in the following table and type the indicated values:

    To Value
    marksAttachment.FileName “School Marks.doc”
    marksAttachment.FileBlob System.IO.File.ReadAllBytes(“<path of the School Marks.doc file>”)

Add the Attachment to the Retrieved Contact Record

  1. To add the School Marks.doc file to the Attachment tab, drop the AddToCollection<> activity into the Designer pane.

  2. Type or select the following details in the Properties tab:

    • Collection — contact.Attachments
    • DisplayName — AddToCollection<Attachment>
    • Item — marksAttachment
    • TypeArgument — Cmc.NexusCrm.Common.Entities.Attachment
  3. From Cmc.Core.Workflow.Activities.EntityModel in the Toolbox, drag the SaveEntity<> activity to the Designer pane. The Select Types dialog is displayed.

  4. In the TEntity drop-down list, select Cmc.Nexus.Crm.Common.Entities.Contact and click OK.

  5. In the Properties area, type the following values:

    • DisplayName — type an appropriate display name.
    • Entity — type contact.
    • ValidationMessages — this field is optional.
  6. Click Publish. The New Workflow Definition Version window is displayed.

  7. If you want the workflow to be run as soon as the event occurs on the entity, select Enable This Workflow Version, otherwise leave the check box cleared.

  8. Click Save, then Cancel to close the publisher window.