BH Salesforce Sync

Drupal Building Housing records are synchronized from MOH SalesForce on a schedule. Salesforce is the authoritative source, and data should not be added or changed in Drupal.

There are 6 synchronizations with Salesforce which run in the following order, every cron run (so every 5 mins) The order is important, because Projects must be created before Attachments & Website Updates before Meetings & Chatter postings.

Sync NameDrupal DestinationSF Origin

Building Housing - Projects

bh_project

Project__c

Building Housing - Website Update

bh_update

Website_Update__c

Building Housing - Project Update

bh_update

Update__c

BH Community Meeting Event

bh_meeting

Community_Meeting_Event__c

Building Housing - Parcels

bh_parcel

Parcel__c

Building Housing - Parcels-Project Assoc

bh_parcel_project_assoc

ParcelProject_Association__c

Each synchronization process does the following: A Drupal Application runs a Salesforce API object query to identify any records in the SF object which have been deleted or which have their last updated date after a last updated date stored by Drupal for that SF object. The identified records are then added/updated or deleted in Drupal. At the end of the process Drupal updates its last updated date for that object with the latest SF updated date found in the import. This date is then used as a high-water mark for the next import cycle.

Building Housing - Projects

This synchronization imports Project records from Salesforce Project__c object into Drupals' bh_project entity.

Synchronization
  • drupal_field_type: properties drupal_field_value: field_bh_project_name direction: sf_drupal salesforce_field: Name id: 0 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_parcel_id direction: sf_drupal salesforce_field: Parcel_ID__c id: 1 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_total_num_units direction: sf_drupal salesforce_field: Total_No_of_Units__c id: 2 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_project_start_date.value direction: sf_drupal salesforce_field: Project_Start_Date__c id: 3 description: ''

  • drupal_field_type: RelatedTermString drupal_field_value: field_bh_record_type direction: sf_drupal salesforce_field: RecordTypeId id: 4 description: ''

  • drupal_field_type: RelatedTermString drupal_field_value: field_bh_project_stage direction: sf_drupal salesforce_field: Project_Stage__c id: 5 description: ''

  • drupal_field_type: RelatedTermString drupal_field_value: field_bh_project_status direction: sf_drupal salesforce_field: Project_Status__c id: 6 description: ''

  • drupal_field_type: RelatedTermString drupal_field_value: field_bh_funding_stage direction: sf_drupal salesforce_field: NHD_Stage__c id: 7 description: ''

  • drupal_field_type: properties drupal_field_value: title direction: sf_drupal salesforce_field: Name id: 8 description: ''

  • drupal_field_type: properties_extended drupal_field_value: field_bh_coordinates.lat direction: sf_drupal salesforce_field: Parcel_Y_Coordinate__c id: 9 description: ''

  • drupal_field_type: properties_extended drupal_field_value: field_bh_coordinates.lng direction: sf_drupal salesforce_field: Parcel_X_Coordinate__c id: 10 description: ''

  • drupal_field_type: properties_extended drupal_field_value: field_bh_wysiwyg_photo_a.value direction: sf_drupal salesforce_field: Project_Photo_1__c id: 11 description: ''

  • drupal_field_type: properties drupal_field_value: body.value direction: sf_drupal salesforce_field: Narrative__c id: 12 description: ''

  • drupal_field_type: RelatedTermString drupal_field_value: field_bh_neighborhood direction: sf_drupal salesforce_field: Neighborhood_computed__c id: 13 description: ''

  • drupal_field_type: RelatedTermString drupal_field_value: field_bh_disposition_type direction: sf_drupal salesforce_field: Disposition_Type__c id: 14 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_project_complete_date.value direction: sf_drupal salesforce_field: Actual_Finish_Date__c id: 15 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_initial_comm_mtg_date.value direction: sf_drupal salesforce_field: Initial_Cmnty_Meeting_Complete_Actual__c id: 16 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_rfp_issued_date.value direction: sf_drupal salesforce_field: RFP_Issued_Actual__c id: 17 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_initial_td_vote_date.value direction: sf_drupal salesforce_field: Initial_TD_Vote_Actual__c id: 18 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_dnd_funding_award_date.value direction: sf_drupal salesforce_field: Award_Enroll__c id: 19 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_conveyance_vote_date.value direction: sf_drupal salesforce_field: Conveyance_Vote_Actual__c id: 20 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_commitment_letter_date.value direction: sf_drupal salesforce_field: Commitment_Letter_Date__c id: 21 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_predicted_closing_date.value direction: sf_drupal salesforce_field: Finance_Closing__c id: 22 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_construction_start_date.value direction: sf_drupal salesforce_field: Construction_Start_Date__c id: 23 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_construct_complete_date.value direction: sf_drupal salesforce_field: Construction_Finish_Actual__c id: 24 description: ''

  • drupal_field_type: RelatedTermString drupal_field_value: field_bh_project_type direction: sf_drupal salesforce_field: Project_Type__c id: 25 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_property_size direction: sf_drupal salesforce_field: Total_Square_Footage__c id: 26 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_units_total direction: sf_drupal salesforce_field: Total_No_of_Units__c id: 27 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_units_affordable direction: sf_drupal salesforce_field: Total_Units_Income__c id: 28 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_units_for_rent direction: sf_drupal salesforce_field: Rent__c id: 29 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_units_to_own direction: sf_drupal salesforce_field: Own__c id: 30 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_councilor direction: sf_drupal salesforce_field: Councilor__c id: 31 description: ''

Custom Sync Code

in SalesforceBuildingHousingUpdateSubscriber.php:

  • function pullQueryAlter changes the SF query to include information on the Projects' Project Manager.

  • function PullPresave runs before the SF Query results are applied to Drupal and manually maps information about the Project Manager so it can be included in the bh_project record.

Building Housing - Website Update

This synchronization manages project stages, documents and messages to appear on the timeline. It extends and replaces the functionality for the Update__c object which is imported for legacy reasons in Building Housing - Project Update.

There is only ever 1 Website Update (Website_Update__c) record per Project (Project__c) record in Salesforce.

There is a rule in Salesforce to stop multiple records which would potentially create confusion for project stages etc.

If multiple Website Update records do exist for a Project in Salesforce, then all records will be imported into Drupal, but ONLY the last (when ordered by createdDate) will be used in the Project Timeline.

About Posts (aka Messages, Text Messages)

MOH Staff sometimes wish to add comments, information or documents (see "About Attachments" section) onto the Projects Timeline in Drupal.

This is done by making Chatter Posts attached to the Website Update (Website_Update__c) object in Salesforce.

Therefore Messages are imported into Drupal by the Website Update sync process.

There are a number of Chatter Post types - This synchronization processes TextPost and ContentPosts - all other Post types are disregarded.

Attachments included in Posts (ContentPosts) are not imported - only the text content is (text content in TextPosts is also always imported). See attachments importing in the "About Attachments" section.

All embellishments included in the Chatter Post (in-line images, links, emoji's and font styling) are stripped during processing so only text is retained.

In Drupal, Posts are saved into an "array" in the field_bh_text_updates field in the bh_update record.

Custom code handles updating and deleting Posts.

In Salesforce, adding a text-only (TextPost) Chatter Post to a Website Update does not automatically trigger a sync. In order to sync a Chatter Post, a MOH Staff member must manually save the Website Update record which then triggers a Drupal sync of the Website Update in turn causing the Posts to be scanned and processed.

About Attachments (aka Documents, Files, Images)

MOH Staff sometimes wish to add documents or images to the project and/or onto the Projects Timeline in Drupal

Documents and images can be added to a Website Update (Website_Update__c)in Salesforce by uploading an Attachment in the Website Update, or by creating a Website Update Chatter Post with an attached document.

Therefore Attachments are imported into Drupal by the Website Update sync process.

Note: There is a process on the Salesforce side which processes Website Update Chatter Posts and saves any attachments as Salesforce Attachment objects.

Note: At the moment, PNG, JPG/JPEG images and PDF documents are properly handled and should open in the users browser. Other document types will import and link to the timeline, but may not display reliably when clicked by a user in the Project Timeline (in Drupal) .

In Drupal, Attachments are saved as file entities and are linked to both the bh_project entity and its associated bh_project entity.

Custom code handles updating and deleting Attachments.

In Salesforce, adding an Attachment (directly or via a Chatter Post) to a Website Update automatically triggers a sync.

Synchronization

The Salesforce Website_Update__c object is linked to the Drupal bh_update entity:

  • Project_Goals__c -> body.value

  • Name => title

  • Boston_gov_Link__c => field_bh_project_web_link

  • Project__c => field_bh_project_ref

  • Follower_emails__c => field_bh_follower_emails

  • "1" => field_sf_web_update

  • Project_Developer_Formula__c => field_bh_developer_name

  • Account_Website__c => field_bh_developer_website

  • Boston_Based_Buiness__c => field_bh_boston_based_business

  • Minority_Owned_Business2__c => field_bh_minority_owned_business

  • Veteran_Owned_Business2__c => field_bh_veteran_owned_business

  • Woman_Owned_Buiness2__c => field_bh_women_owned_business

Note: The field field_bh_text_updatesin Drupal is updated with a string array of Chatter messages.

Note: A Drupal file object is created for each attachment found in the attachment field of the Website_updates__c object in SF.

Note: The field field_bh_attachment and/or field_bh_project_imagesin Drupal bh_update entity is updated with an array of files (attachments found in Website_Updates__c.Attachments in SF).

Note: The field field_bh_attachment and/or field_bh_project_images in Drupal bh_project entity is updated with an array of files (attachments found in Website_Updates__c.Attachments in SF).

Custom Sync Code

in SalesforceBuildingHousingUpdateSubscriber.php:

  • function pullQueryAlter changes the SF query to include information on the Website Updates' Attachments, and the Attachment files.

  • function PullPresave runs before the SF Query results are applied to Drupal and manually - manages Posts in bh_update,and - manages Attachments as file objects, and - links the file objects to the bh_update and the bh_project entities.

Building Housing - Project Update

There should be no new Update__c records being created in SF. However, there are legacy records containing data which must be included in Drupal. Even though we do not normally expect the sync to process these objects, the code is important if the data is to be recreated accurately and completely (for example if a Salesforce purge is performed).

This handles legacy TextMessages (now use chatter) and document attachments (now use Website Update Attachments).

Synchronization
  • drupal_field_type: properties drupal_field_value: field_bh_headline direction: sf_drupal salesforce_field: Headline__c id: 0

  • drupal_field_type: RelatedIDs drupal_field_value: field_bh_project_ref direction: sf_drupal salesforce_field: Project__c id: 1

  • drupal_field_type: properties drupal_field_value: status direction: sf_drupal salesforce_field: Publish_to_Web__c id: 2

  • drupal_field_type: properties drupal_field_value: title direction: sf_drupal salesforce_field: Name id: 3

  • drupal_field_type: properties_extended drupal_field_value: body.value direction: sf_drupal salesforce_field: Update_Body__c id: 4

  • drupal_field_type: RelatedTermString drupal_field_value: field_bh_update_type_ref direction: sf_drupal salesforce_field: Type__c id: 5

  • drupal_field_type: properties drupal_field_value: field_bh_update_posted_date direction: sf_drupal salesforce_field: CreatedDate id: 6

Custom Sync Code

in SalesforceBuildingHousingUpdateSubscriber.php:

  • function pullQueryAlter changes the SF query to include information on the Project Updates' Attachments, and the Attachment files.

  • function PullPresave runs before the SF Query results are applied to Drupal and manually - manages Posts in bh_update,and - manages Attachments as file objects, and - links the file objects to the bh_update and the bh_project entities.

BH Community Meeting Event

This synchronization imports Community Meetings event records from Salesforce Community_Meeting_Event__c object into Drupals bh_meeting entity.

This is a simple mapping and the import does little except cleaning up any URLs and address fields.

The bh_meetingrecord holds a reference to it's parent bh_updatewhich is linked to the bh_project.

If a Meeting event is updated, or deleted in SF, then the associated record will be updated in Drupal, and if necessary will move on the timeline.

Synchronization
  • drupal_field_type: properties drupal_field_value: title direction: sf_drupal salesforce_field: Title__c id: 0 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_meeting_start_time.value direction: sf_drupal salesforce_field: Meeting_Date_Time_Start__c id: 1 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_meeting_end_time.value direction: sf_drupal salesforce_field: Meeting_Date_Time_End__c id: 2 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_languages_supported direction: sf_drupal salesforce_field: Languages_supported__c id: 3 description: ''

  • drupal_field_type: properties drupal_field_value: body.value direction: sf_drupal salesforce_field: Meeting_Description__c id: 4 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_contact_person_sfid direction: sf_drupal salesforce_field: Contact_person__c id: 5 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_meeting_goal direction: sf_drupal salesforce_field: Meeting_Goal__c id: 6 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_meeting_recording_pass direction: sf_drupal salesforce_field: Meeting_Recording_Password__c id: 7 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_number_of_attendees direction: sf_drupal salesforce_field: Number_of_attendees__c id: 8 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_post_meeting_notes direction: sf_drupal salesforce_field: Post_meeting_Notes__c id: 9 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_post_meeting_recording direction: sf_drupal salesforce_field: Post_meeting_recording__c id: 10 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_virt_meeting_web_addr direction: sf_drupal salesforce_field: Virtual_meeting_web_address__c id: 11 description: ''

  • drupal_field_type: RelatedIDs drupal_field_value: field_bh_update_ref direction: sf_drupal salesforce_field: Website_Update__c id: 12 description: ''

  • drupal_field_type: properties drupal_field_value: field_bh_host_organization direction: sf_drupal salesforce_field: Host_Organization2__c id: 13 description: ''

  • drupal_field_type: properties drupal_field_value: field_address.address_line1 direction: sf_drupal salesforce_field: Address__c id: 14 description: 'DU Aug 2022. Insert SF text address into first line of drupal address component.'

Custom Sync Code

in SalesforceBuildingHousingUpdateSubscriber.php:

  • function PullPresave runs before the SF Query results are applied to Drupal and manually cleans up URL's and addresses

Building Housing - Parcels

Synchronization
  • drupal_field_type: properties drupal_field_value: field_bh_parcel_name direction: sf_drupal salesforce_field: Name id: 0

  • drupal_field_type: properties drupal_field_value: field_bh_parcel_header direction: sf_drupal salesforce_field: Parcel_Header__c id: 1

  • drupal_field_type: RelatedTermString drupal_field_value: field_bh_property_type direction: sf_drupal salesforce_field: Property_Type__c id: 2

  • drupal_field_type: properties drupal_field_value: field_bh_owned_by_dnd direction: sf_drupal salesforce_field: Active__c id: 3

  • drupal_field_type: properties drupal_field_value: field_bh_assessing_lot_size direction: sf_drupal salesforce_field: Assessing_Lot_Size__c id: 4

  • drupal_field_type: properties drupal_field_value: field_bh_street_address_temp direction: sf_drupal salesforce_field: Street_Address__c id: 5

  • drupal_field_type: properties drupal_field_value: title direction: sf_drupal salesforce_field: Name id: 6

  • drupal_field_type: properties_extended drupal_field_value: field_bh_coordinates.lat direction: sf_drupal salesforce_field: Y_Coordinate__c id: 7

  • drupal_field_type: properties_extended drupal_field_value: field_bh_coordinates.lng direction: sf_drupal salesforce_field: X_Coordinate__c id: 8

Custom Sync Code

None

Building Housing - Parcels-Project Assoc

Synchronization
  • drupal_field_type: RelatedIDs drupal_field_value: field_bh_parcel_ref direction: sf_drupal salesforce_field: Parcel__c id: 0

  • drupal_field_type: RelatedIDs drupal_field_value: field_bh_project_ref direction: sf_drupal salesforce_field: Project__c id: 1

  • drupal_field_type: properties drupal_field_value: title direction: sf_drupal salesforce_field: Name id: 2

Custom Sync Code

None

Last updated