Advertisement
matthewpoer

Basic SF to SugarCRM

May 8th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 4.65 KB | None | 0 0
  1. -- Manual opt-outs for some folks...
  2. select id,FirstName,LastName from contact where HasOptedOutOfEmail = 1;
  3.  
  4. -- get list of Lead Sources
  5. select distinct(LeadSource) from contact;
  6.  
  7. -- create these custom fields:
  8. -- Campaign__c as campaign_c,
  9. -- RFC_Rcd__c as rfc_rcd_c,
  10. -- Spouse__C as spouse_c,
  11. -- Partner__c as partner_c,
  12. -- Dev_Agent__C as dev_agent_c,
  13. -- Status__c as status_c,
  14. -- -- Temp__c as temp_c,
  15. -- Item_23_Rcd__c as item_23_rc_c,
  16. -- FDD_Sent__c as fdd_sent_c
  17.  
  18. -- Pull contact information, formatted headers
  19. select
  20. Id as id,
  21. Salutation as salutation,
  22. Firstname as first_name,
  23. LastName as last_name,
  24.  
  25. MailingStreet as primary_address_street,
  26. MailingCity as primary_address_city,
  27. MailingState as primary_address_state,
  28. MailingPostalCode as primary_address_postalcode,
  29. MailingCountry as primary_address_country,
  30.  
  31. OtherStreet as alt_address_street,
  32. OtherCity as alt_address_city,
  33. OtherState as alt_address_state,
  34. OtherPostalCode as alt_address_postalcode,
  35. OtherCountry as alt_address_country,
  36.  
  37. Phone as phone_work,
  38. Fax as phone_fax,
  39. MobilePhone as phone_mobile,
  40. HomePhone as phone_home,
  41. OtherPhone as phone_other,
  42. AssistantPhone as assistant_phone,
  43. Email as email1,
  44. Title as title,
  45. Department as department,
  46. AssistantName as assistant,
  47. LeadSource as lead_source,
  48. Birthdate as birthdate,
  49. Description as description,
  50. DoNotCall as do_not_call,
  51. Campaign__c as campaign_c,
  52. RFC_Rcd__c as rfc_rcd_c,
  53. Spouse__C as spouse_c,
  54. Partner__c as partner_c,
  55. Dev_Agent__C as dev_agent_c,
  56. Status__c as status_c,
  57. Temp__c as temp_c,
  58. Item_23_Rcd__c as item_23_rc_c,
  59. FDD_Sent__c as fdd_sent_c
  60.  
  61. from contact
  62. where IsDeleted = 0;
  63.  
  64. -- pull event/meeting information, formatted headers
  65. select
  66. WhoId as parent_id,
  67. 'Contacts' as parent_type,
  68. Subject as name,
  69. Location as location,
  70. ActivityDateTime as start_date,
  71. DurationInMinutes as total_duration_in_minutes, -- won't be used, just for error-checking
  72. DurationInMinutes DIV 60 as duration_hours,
  73. DurationInMinutes MOD 60 as duration_minutes,
  74. Description as description
  75. from event
  76. where IsDeleted = 0;
  77.  
  78. -- pull notes information, formatted headers
  79. select
  80. ParentId as parent_id,
  81. Title as name,
  82. Body as description,
  83. 'Contacts' as parent_type
  84. from note
  85. where IsDeleted = 0;
  86.  
  87. -- pull task information, formatted headers
  88. select
  89. WhoId as parent_id,
  90. 'Contacts' as parent_type,
  91. Subject as name,
  92. ActivityDate as start_date,
  93. ActivityDate as end_date,
  94. Status as status,
  95. Priority as priority,
  96. CASE
  97.     WHEN Priority = 'Normal' THEN 'Medium'
  98.     WHEN Priority = 'High' THEN 'High'
  99.     ELSE NULL
  100. END as priority
  101. from task
  102. where IsDeleted = 0;
  103.  
  104. --           --
  105. -- Round Two --
  106. --           --
  107.  
  108. -- Pull contact information, formatted headers
  109. select
  110. Id as id,
  111. `First Name` as first_name,
  112. `Last Name` as last_name,
  113. `Primary Address` as primary_address_street,
  114. `Primary Address City` as primary_address_city,
  115. `Primary Address State` as primary_address_state,
  116. `Primary Address Postal Code` as primary_address_postalcode,
  117. `Primary Address Country` as primary_address_country,
  118. `Alternate Address` as alt_address_street,
  119. `Alternate Address City` as alt_address_city,
  120. `Alternate Address State` as alt_address_state,
  121. `Alternate Address Postalcode` as alt_address_postalcode,
  122. `Alternate Address Country` as alt_address_country,
  123. `Office Phone` as phone_work,
  124. Fax as phone_fax,
  125. `Mobile Phone` as phone_mobile,
  126. `Home Phone` as phone_home,
  127. `Other Phone` as phone_other,
  128. Email as email1,
  129. `Lead Source` as lead_source,
  130. `Campaign/Referral Source` as campaign_c,
  131. `RFC Rcd` as rfc_rcd_c,
  132. `Spouse` as spouse_c,
  133. `Partner` as partner_c,
  134. `Development Agent` as dev_agent_c,
  135. `Status` as status_c,
  136. `Item 23 Rcd` as item_23_rc_c,
  137. `FDD Sent` as fdd_sent_c
  138. from contact;
  139.  
  140. -- pull event/meeting information, formatted headers
  141. select
  142. WhoId as parent_id,
  143. 'Contacts' as parent_type,
  144. Subject as name,
  145. Location as location,
  146. ActivityDateTime as start_date,
  147. DurationInMinutes DIV 60 as duration_hours,
  148. DurationInMinutes MOD 60 as duration_minutes,
  149. Description as description,
  150. OwnerId as assigned_user_name
  151. from events
  152. where IsDeleted = 0;
  153.  
  154. -- pull notes information, formatted headers
  155. select
  156. ParentId as parent_id,
  157. Title as name,
  158. Body as description,
  159. OwnerId as assigned_user_name,
  160. 'Contacts' as parent_type
  161. from notes
  162. where IsDeleted = 0;
  163.  
  164. -- pull task information, formatted headers
  165. select
  166. WhoId as parent_id,
  167. 'Contacts' as parent_type,
  168. Subject as name,
  169. ActivityDate as start_date,
  170. ActivityDate as end_date,
  171. Status as status,
  172. OwnerId as assigned_user_name,
  173. CASE
  174.     WHEN Priority = 'Normal' THEN 'Medium'
  175.     WHEN Priority = 'High' THEN 'High'
  176.     ELSE NULL
  177. END as priority
  178. from tasks
  179. where IsDeleted = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement