Skip to content

Scheduled sync with salesforce

Bryan Eli edited this page Oct 13, 2020 · 9 revisions

Accounts does a sync with salesforce on a schedule basis. It pulls information about Contacts and Leads from Salesforce and updates User records in Accounts accordingly.

All the code for this is in one file, here: https://github.com/openstax/accounts/blob/35629624f3569327afa552900490e72d2372ae51/app/routines/update_user_salesforce_info.rb#L1

It does is the following:

  • Goes through all users that have already have a Salesforce Contact ID, pulls their Salesforce information, and saves it in the User record.
  • For users who do not yet have a Contact ID, looks for any leads with the given user's email address. If we find any, we check their lead's Status, and if all their leads have the status as "Converted", then it means that the user has been rejected as faculty.
  • For all other users who we don't have a contact or a lead for in SF, we change their User faculty_status to "no_faculty_info".
Clone this wiki locally