Commit fa23ef18 authored by Andrey Shevchuk's avatar Andrey Shevchuk

removed converted leads from search results

parent 5d2a4e79
...@@ -3,466 +3,468 @@ package Integration::CRM::SalesForce; ...@@ -3,466 +3,468 @@ package Integration::CRM::SalesForce;
use strict; use strict;
use warnings; use warnings;
use WWW::Salesforce; use WWW::Salesforce;
use Data::Dumper; use Data::Dumper;
our $VERSION = '1'; our $VERSION = '1';
my %object_prefixes = ( my %object_prefixes = (
ACCOUNT => '001', ACCOUNT => '001',
NOTE => '002', NOTE => '002',
CONTACT => '003', CONTACT => '003',
USERS => '005', USERS => '005',
OPPORTUNITY => '006', OPPORTUNITY => '006',
ACTIVITY => '007', ACTIVITY => '007',
OPPORTUNITY_HISTORY => '008', OPPORTUNITY_HISTORY => '008',
FORECAST_ITEM => '00A', FORECAST_ITEM => '00A',
FILTER => '00B', FILTER => '00B',
DELETE_EVENT => '00C', DELETE_EVENT => '00C',
ORGANIZATION => '00D', ORGANIZATION => '00D',
USER_ROLE => '00E', USER_ROLE => '00E',
QUEUE => '00G', QUEUE => '00G',
GROUPS => '00G', GROUPS => '00G',
PARTNER => '00I', PARTNER => '00I',
OPPORTUNITY_COMPETITOR => '00J', OPPORTUNITY_COMPETITOR => '00J',
OPPORTUNITY_CONTACT_ROLE => '00K', OPPORTUNITY_CONTACT_ROLE => '00K',
CUSTOM_FIELD_DEFINITION => '00N', CUSTOM_FIELD_DEFINITION => '00N',
REPORT => '00O', REPORT => '00O',
ATTACHMENT => '00P', ATTACHMENT => '00P',
LEAD => '00Q', LEAD => '00Q',
IMPORT_QUEUE => '00S', IMPORT_QUEUE => '00S',
TASK => '00T', TASK => '00T',
EVENT => '00U', EVENT => '00U',
EMAIL_TEMPLATE => '00X', EMAIL_TEMPLATE => '00X',
EMAIL_TEMP => '00Y', EMAIL_TEMP => '00Y',
COMMENTS => '00a', COMMENTS => '00a',
CUSTOM_RESOURCE_LINK => '00b', CUSTOM_RESOURCE_LINK => '00b',
TRAINING => '00c', TRAINING => '00c',
PROFILE => '00e', PROFILE => '00e',
MH_BLUESHEET => '00f', MH_BLUESHEET => '00f',
MH_GOLDSHEET => '00g', MH_GOLDSHEET => '00g',
LAYOUT => '00h', LAYOUT => '00h',
PRICEBOOK_MAPPING => '00i', PRICEBOOK_MAPPING => '00i',
PRICEBOOK_ENTRY_MAPPING => '00j', PRICEBOOK_ENTRY_MAPPING => '00j',
OPPORTUNITY_LINEITEM => '00k', OPPORTUNITY_LINEITEM => '00k',
FOLDER => '00l', FOLDER => '00l',
EMAIL_ATTACHMENT_LOOKUP => '00m', EMAIL_ATTACHMENT_LOOKUP => '00m',
EMAIL_ATTACHMENT_ARCHIVE => '00n', EMAIL_ATTACHMENT_ARCHIVE => '00n',
LINEITEM_SCHEDULE => '00o', LINEITEM_SCHEDULE => '00o',
USER_TEAM_MEMBER => '00p', USER_TEAM_MEMBER => '00p',
OPP_TEAM_MEMBER => '00q', OPP_TEAM_MEMBER => '00q',
ACC_SHARE => '00r', ACC_SHARE => '00r',
ACC_SHARE_DEFAULT => '00s', ACC_SHARE_DEFAULT => '00s',
OPP_SHARE => '00t', OPP_SHARE => '00t',
OPP_SHARE_DEFAULT => '00u', OPP_SHARE_DEFAULT => '00u',
CAMPAIGN_MEMBER => '00v', CAMPAIGN_MEMBER => '00v',
PAYMENT_APPLICATION => '00w', PAYMENT_APPLICATION => '00w',
BILLED_PRODUCT => '00x', BILLED_PRODUCT => '00x',
PURCHASE_RULE => '00y', PURCHASE_RULE => '00y',
PURCHASE_RULE_ENTRY => '00z', PURCHASE_RULE_ENTRY => '00z',
CASE_SOLUTION => '010', CASE_SOLUTION => '010',
GROUP_MEMBER => '011', GROUP_MEMBER => '011',
RECORD_TYPE => '012', RECORD_TYPE => '012',
RECORD_TYPE_PICKLIST => '013', RECORD_TYPE_PICKLIST => '013',
PROFILE_RECORD_TYPE => '014', PROFILE_RECORD_TYPE => '014',
DOCUMENT => '015', DOCUMENT => '015',
BRAND_TEMPLATE => '016', BRAND_TEMPLATE => '016',
ENTITY_HISTORY => '017', ENTITY_HISTORY => '017',
EMAIL_STATUS => '018', EMAIL_STATUS => '018',
BUSINESS_PROCESS => '019', BUSINESS_PROCESS => '019',
BUSINESS_PROCESS_PICKLIST => '01A', BUSINESS_PROCESS_PICKLIST => '01A',
LAYOUT_SECTION => '01B', LAYOUT_SECTION => '01B',
LAYOUT_ITEM => '01C', LAYOUT_ITEM => '01C',
PROFILE_LAYOUT => '01G', PROFILE_LAYOUT => '01G',
MAILMERGE_TEMPLATE => '01H', MAILMERGE_TEMPLATE => '01H',
CUSTOM_ENTITY_DEFINITION => '01I', CUSTOM_ENTITY_DEFINITION => '01I',
PICKLIST_MASTER => '01J', PICKLIST_MASTER => '01J',
CURRENCY_TYPE => '01L', CURRENCY_TYPE => '01L',
ACC_TEAM_MEMBER => '01M', ACC_TEAM_MEMBER => '01M',
ACTIVE_CONTENT => '01N', ACTIVE_CONTENT => '01N',
USER_UI_CONFIGURATION => '01O', USER_UI_CONFIGURATION => '01O',
PROFILE_TAB_CONFIGURATION => '01P', PROFILE_TAB_CONFIGURATION => '01P',
WORKFLOW_RULE => '01Q', WORKFLOW_RULE => '01Q',
RULE_FILTER => '01R', RULE_FILTER => '01R',
RULE_FILTER_ITEM => '01S', RULE_FILTER_ITEM => '01S',
RULE_FILTER_ACTION => '01T', RULE_FILTER_ACTION => '01T',
ACTION_ASSIGN_ESCALATE => '01U', ACTION_ASSIGN_ESCALATE => '01U',
ACTION_TASK => '01V', ACTION_TASK => '01V',
ACTION_EMAIL => '01W', ACTION_EMAIL => '01W',
ACTION_EMAIL_RECIPIENT => '01X', ACTION_EMAIL_RECIPIENT => '01X',
CAMPAIGN_MEMBER_STATUS => '01Y', CAMPAIGN_MEMBER_STATUS => '01Y',
DASHBOARD => '01Z', DASHBOARD => '01Z',
DASHBOARD_COMPONENT => '01a', DASHBOARD_COMPONENT => '01a',
FILTER_ITEM => '01b', FILTER_ITEM => '01b',
FILTER_COLUMN => '01c', FILTER_COLUMN => '01c',
FOLDER_GROUPS => '01d', FOLDER_GROUPS => '01d',
PICKLIST_SET => '01e', PICKLIST_SET => '01e',
WEBEX_MEETING => '01f', WEBEX_MEETING => '01f',
API_QUERY => '01g', API_QUERY => '01g',
TRANSLATION => '01h', TRANSLATION => '01h',
TRANSLATION_USER => '01i', TRANSLATION_USER => '01i',
TRANSLATION_VALUE => '01j', TRANSLATION_VALUE => '01j',
PROFILE_FLS_ITEM => '01k', PROFILE_FLS_ITEM => '01k',
ACTION_RESPONSE => '01l', ACTION_RESPONSE => '01l',
BUSINESS_HOURS => '01m', BUSINESS_HOURS => '01m',
CASE_SHARE => '01n', CASE_SHARE => '01n',
LEAD_SHARE => '01o', LEAD_SHARE => '01o',
CUSTOM_TAB_DEFINITION => '01r', CUSTOM_TAB_DEFINITION => '01r',
PRICEBOOK2 => '01s', PRICEBOOK2 => '01s',
PRODUCT2 => '01t', PRODUCT2 => '01t',
PRICEBOOK_ENTRY => '01u', PRICEBOOK_ENTRY => '01u',
PRICEBOOK_SHARE => '01v', PRICEBOOK_SHARE => '01v',
OPP_UPDATE_REMINDER => '01w', OPP_UPDATE_REMINDER => '01w',
OPP_UPDATE_REMINDER_STATS => '01x', OPP_UPDATE_REMINDER_STATS => '01x',
CASE_SHARE_DEFAULT => '01y', CASE_SHARE_DEFAULT => '01y',
CASE_ESCALATION => '01z', CASE_ESCALATION => '01z',
EVENT_ATTENDEE => '020', EVENT_ATTENDEE => '020',
QUANTITY_FORECAST => '021', QUANTITY_FORECAST => '021',
FISCAL_YEAR_SETTINGS => '022', FISCAL_YEAR_SETTINGS => '022',
APP_CALENDAR => '023', APP_CALENDAR => '023',
APP_CALENDAR_SHARING => '024', APP_CALENDAR_SHARING => '024',
LIST_LAYOUT_ITEM => '025', LIST_LAYOUT_ITEM => '025',
PERIOD => '026', PERIOD => '026',
REVENUE_FORECAST => '027', REVENUE_FORECAST => '027',
OPPORTUNITY_OVERRIDE => '028', OPPORTUNITY_OVERRIDE => '028',
LINEITEM_OVERRIDE => '029', LINEITEM_OVERRIDE => '029',
LEAD_SHARE_DEFAULT => '02A', LEAD_SHARE_DEFAULT => '02A',
LABEL_DEFINITION => '02B', LABEL_DEFINITION => '02B',
LABEL_DATA => '02C', LABEL_DATA => '02C',
CASES_HISTORY2 => '02D', CASES_HISTORY2 => '02D',
HELP_SETTING => '02E', HELP_SETTING => '02E',
CUSTOM_FIELD_MAP => '02F', CUSTOM_FIELD_MAP => '02F',
MH_GOLD_PROGRAM => '02H', MH_GOLD_PROGRAM => '02H',
MH_GOLD_INFORMATION => '02I', MH_GOLD_INFORMATION => '02I',
MH_GOLD_CONTACT => '02J', MH_GOLD_CONTACT => '02J',
MH_GOLD_ACTION => '02K', MH_GOLD_ACTION => '02K',
MH_CUSTOMER_CRITERION => '02L', MH_CUSTOMER_CRITERION => '02L',
MH_GREENSHEET => '02M', MH_GREENSHEET => '02M',
MH_GREEN_GIVE_INFO => '02N', MH_GREEN_GIVE_INFO => '02N',
MH_GREEN_GET_INFO => '02O', MH_GREEN_GET_INFO => '02O',
MH_CONTACT_ROLE => '02P', MH_CONTACT_ROLE => '02P',
MH_INFORMATION => '02Q', MH_INFORMATION => '02Q',
USER_PREFERENCE2 => '02R', USER_PREFERENCE2 => '02R',
HTML_COMPONENT => '02S', HTML_COMPONENT => '02S',
CUSTOM_PAGE => '02T', CUSTOM_PAGE => '02T',
CUSTOM_PAGE_ITEM => '02U', CUSTOM_PAGE_ITEM => '02U',
PAGE_COMPONENT => '02V', PAGE_COMPONENT => '02V',
CUSTOM_PAGE_PROFILE => '02X', CUSTOM_PAGE_PROFILE => '02X',
USER_COMPONENT_DATA => '02Y', USER_COMPONENT_DATA => '02Y',
ACCOUNT_CONTACT_ROLE => '02Z', ACCOUNT_CONTACT_ROLE => '02Z',
CONTRACT_CONTACT_ROLE => '02a', CONTRACT_CONTACT_ROLE => '02a',
COMPONENT_RESOURCE_LINK => '02b', COMPONENT_RESOURCE_LINK => '02b',
DIVISION => '02d', DIVISION => '02d',
DIVISION_WORKFLOW_RULE => '02e', DIVISION_WORKFLOW_RULE => '02e',
DELEGATE_GROUP => '02f', DELEGATE_GROUP => '02f',
DELEGATE_GROUP_MEMBER => '02g', DELEGATE_GROUP_MEMBER => '02g',
DELEGATE_GROUP_GRANT => '02h', DELEGATE_GROUP_GRANT => '02h',
ASSET => '02i', ASSET => '02i',
PROFILE_ENTITY_PERMISSIONS => '02j', PROFILE_ENTITY_PERMISSIONS => '02j',
LIST_LAYOUT => '02k', LIST_LAYOUT => '02k',
OUTBOUND_QUEUE => '02l', OUTBOUND_QUEUE => '02l',
CUSTOM_INDEX => '02m', CUSTOM_INDEX => '02m',
CATEGORY_NODE => '02n', CATEGORY_NODE => '02n',
CATEGORY_DATA => '02o', CATEGORY_DATA => '02o',
DIV_TRANSFER_EVENT => '02p', DIV_TRANSFER_EVENT => '02p',
LAYOUT_ITEM_COLUMN => '02q', LAYOUT_ITEM_COLUMN => '02q',
OPPORTUNITY_ALERT => '02r', OPPORTUNITY_ALERT => '02r',
EMAIL_MESSAGE => '02s', EMAIL_MESSAGE => '02s',
EMAIL_ROUTING_ADDRESS => '02t', EMAIL_ROUTING_ADDRESS => '02t',
TAB_SET => '02u', TAB_SET => '02u',
TAB_SET_MEMBER => '02v', TAB_SET_MEMBER => '02v',
LOGIN_IP_RANGE => '02w', LOGIN_IP_RANGE => '02w',
LOGIN_HOURS => '02x', LOGIN_HOURS => '02x',
REPORT_AGGREGATE => '02y', REPORT_AGGREGATE => '02y',
REPORT_COLOR_RANGE => '02z', REPORT_COLOR_RANGE => '02z',
PROFILE_TAB_SET => '030', PROFILE_TAB_SET => '030',
USER_TAB_SET_MEMBER => '031', USER_TAB_SET_MEMBER => '031',
ACC_TERRITORY_RULE => '032', ACC_TERRITORY_RULE => '032',
PROJECT => '033', PROJECT => '033',
PROJECT_MEMBER => '034', PROJECT_MEMBER => '034',
SELF_SERVICE_USER => '035', SELF_SERVICE_USER => '035',
JOB_QUEUE => '036', JOB_QUEUE => '036',
REPORT_COLUMN => '037', REPORT_COLUMN => '037',
REPORT_FILTER_ITEM => '038', REPORT_FILTER_ITEM => '038',
REPORT_BREAK => '039', REPORT_BREAK => '039',
DEPENDENT_PICKLIST => '03a', DEPENDENT_PICKLIST => '03a',
PACKAGE_EXPORT => '03b', PACKAGE_EXPORT => '03b',
LAYOUT_RIGHT_PANEL => '03c', LAYOUT_RIGHT_PANEL => '03c',
CUSTOM_SETUP_DEFINITION => '03e', CUSTOM_SETUP_DEFINITION => '03e',
CUSTOM_SETUP => '03f', CUSTOM_SETUP => '03f',
REPORT_PARAM => '040', REPORT_PARAM => '040',
ACC_TERRITORY_ASSIGN => '041', ACC_TERRITORY_ASSIGN => '041',
ACC_TERR_ASSIGN_RULE_ITEM => '042', ACC_TERR_ASSIGN_RULE_ITEM => '042',
OUTBOUND_FIELD => '043', OUTBOUND_FIELD => '043',
USER_TERRITORY => '04S', USER_TERRITORY => '04S',
TERRITORY => '04T', TERRITORY => '04T',
DNB_ACCOUNT_MAPPING => '04U', DNB_ACCOUNT_MAPPING => '04U',
DNB_FIELD => '04V', DNB_FIELD => '04V',
REVENUE_FORECAST_HISTORY => '04W', REVENUE_FORECAST_HISTORY => '04W',
QUANTITY_FORECAST_HISTORY => '04X', QUANTITY_FORECAST_HISTORY => '04X',
CONTENTVERSION => '068', CONTENTVERSION => '068',
CONTENTDOCUMENT => '069', CONTENTDOCUMENT => '069',
ENTITY_PERMISSION => '110', ENTITY_PERMISSION => '110',
SFDC_PARTNER => '204', SFDC_PARTNER => '204',
SFDC_DIVISION => '208', SFDC_DIVISION => '208',
CASES => '500', CASES => '500',
SOLUTION => '501', SOLUTION => '501',
BILLING_DIVISION => '600', BILLING_DIVISION => '600',
BILLING_ORDER => '601', BILLING_ORDER => '601',
CURRENCY => '602', CURRENCY => '602',
PLAN => '604', PLAN => '604',
PRODUCT => '605', PRODUCT => '605',
BILLING_ORDER_ITEM => '606', BILLING_ORDER_ITEM => '606',
PLAN_PRODUCT => '607', PLAN_PRODUCT => '607',
CAMPAIGN => '701', CAMPAIGN => '701',
FIELD_HISTORY => '737', FIELD_HISTORY => '737',
UI_STYLE_DEFINITION => '766', UI_STYLE_DEFINITION => '766',
UI_STYLE => '777', UI_STYLE => '777',
CONTRACT => '800', CONTRACT => '800',
ORDERS => '801', ORDERS => '801',
ORDER_ITEM => '802', ORDER_ITEM => '802',
INVOICE => '803', INVOICE => '803',
INVOICE_ITEM => '804', INVOICE_ITEM => '804',
PAYMENT => '805', PAYMENT => '805',
APPROVAL => '806', APPROVAL => '806',
URI_BLOCK_RULE => '807', URI_BLOCK_RULE => '807',
CUSTOM_ENTITY_DATA => 'a00', CUSTOM_ENTITY_DATA => 'a00',
ACCOUNT => '001', ACCOUNT => '001',
NOTE => '002', NOTE => '002',
CONTACT => '003', CONTACT => '003',
USERS => '005', USERS => '005',
OPPORTUNITY => '006', OPPORTUNITY => '006',
ACTIVITY => '007', ACTIVITY => '007',
OPPORTUNITY_HISTORY => '008', OPPORTUNITY_HISTORY => '008',
FORECAST_ITEM => '00A', FORECAST_ITEM => '00A',
FILTER => '00B', FILTER => '00B',
DELETE_EVENT => '00C', DELETE_EVENT => '00C',
ORGANIZATION => '00D', ORGANIZATION => '00D',
USER_ROLE => '00E', USER_ROLE => '00E',
QUEUE => '00G', QUEUE => '00G',
GROUPS => '00G', GROUPS => '00G',
PARTNER => '00I', PARTNER => '00I',
OPPORTUNITY_COMPETITOR => '00J', OPPORTUNITY_COMPETITOR => '00J',
OPPORTUNITY_CONTACT_ROLE => '00K', OPPORTUNITY_CONTACT_ROLE => '00K',
CUSTOM_FIELD_DEFINITION => '00N', CUSTOM_FIELD_DEFINITION => '00N',
REPORT => '00O', REPORT => '00O',
ATTACHMENT => '00P', ATTACHMENT => '00P',
LEAD => '00Q', LEAD => '00Q',
IMPORT_QUEUE => '00S', IMPORT_QUEUE => '00S',
TASK => '00T', TASK => '00T',
EVENT => '00U', EVENT => '00U',
EMAIL_TEMPLATE => '00X', EMAIL_TEMPLATE => '00X',
EMAIL_TEMP => '00Y', EMAIL_TEMP => '00Y',
COMMENTS => '00a', COMMENTS => '00a',
CUSTOM_RESOURCE_LINK => '00b', CUSTOM_RESOURCE_LINK => '00b',
TRAINING => '00c', TRAINING => '00c',
PROFILE => '00e', PROFILE => '00e',
MH_BLUESHEET => '00f', MH_BLUESHEET => '00f',
MH_GOLDSHEET => '00g', MH_GOLDSHEET => '00g',
LAYOUT => '00h', LAYOUT => '00h',
PRICEBOOK_MAPPING => '00i', PRICEBOOK_MAPPING => '00i',
PRICEBOOK_ENTRY_MAPPING => '00j', PRICEBOOK_ENTRY_MAPPING => '00j',
OPPORTUNITY_LINEITEM => '00k', OPPORTUNITY_LINEITEM => '00k',
FOLDER => '00l', FOLDER => '00l',
EMAIL_ATTACHMENT_LOOKUP => '00m', EMAIL_ATTACHMENT_LOOKUP => '00m',
EMAIL_ATTACHMENT_ARCHIVE => '00n', EMAIL_ATTACHMENT_ARCHIVE => '00n',
LINEITEM_SCHEDULE => '00o', LINEITEM_SCHEDULE => '00o',
USER_TEAM_MEMBER => '00p', USER_TEAM_MEMBER => '00p',
OPP_TEAM_MEMBER => '00q', OPP_TEAM_MEMBER => '00q',
ACC_SHARE => '00r', ACC_SHARE => '00r',
ACC_SHARE_DEFAULT => '00s', ACC_SHARE_DEFAULT => '00s',
OPP_SHARE => '00t', OPP_SHARE => '00t',
OPP_SHARE_DEFAULT => '00u', OPP_SHARE_DEFAULT => '00u',
CAMPAIGN_MEMBER => '00v', CAMPAIGN_MEMBER => '00v',
PAYMENT_APPLICATION => '00w', PAYMENT_APPLICATION => '00w',
BILLED_PRODUCT => '00x', BILLED_PRODUCT => '00x',
PURCHASE_RULE => '00y', PURCHASE_RULE => '00y',
PURCHASE_RULE_ENTRY => '00z', PURCHASE_RULE_ENTRY => '00z',
CASE_SOLUTION => '010', CASE_SOLUTION => '010',
GROUP_MEMBER => '011', GROUP_MEMBER => '011',
RECORD_TYPE => '012', RECORD_TYPE => '012',
RECORD_TYPE_PICKLIST => '013', RECORD_TYPE_PICKLIST => '013',
PROFILE_RECORD_TYPE => '014', PROFILE_RECORD_TYPE => '014',
DOCUMENT => '015', DOCUMENT => '015',
BRAND_TEMPLATE => '016', BRAND_TEMPLATE => '016',
ENTITY_HISTORY => '017', ENTITY_HISTORY => '017',
EMAIL_STATUS => '018', EMAIL_STATUS => '018',
BUSINESS_PROCESS => '019', BUSINESS_PROCESS => '019',
BUSINESS_PROCESS_PICKLIST => '01A', BUSINESS_PROCESS_PICKLIST => '01A',
LAYOUT_SECTION => '01B', LAYOUT_SECTION => '01B',
LAYOUT_ITEM => '01C', LAYOUT_ITEM => '01C',
PROFILE_LAYOUT => '01G', PROFILE_LAYOUT => '01G',
MAILMERGE_TEMPLATE => '01H', MAILMERGE_TEMPLATE => '01H',
CUSTOM_ENTITY_DEFINITION => '01I', CUSTOM_ENTITY_DEFINITION => '01I',
PICKLIST_MASTER => '01J', PICKLIST_MASTER => '01J',
CURRENCY_TYPE => '01L', CURRENCY_TYPE => '01L',
ACC_TEAM_MEMBER => '01M', ACC_TEAM_MEMBER => '01M',
ACTIVE_CONTENT => '01N', ACTIVE_CONTENT => '01N',
USER_UI_CONFIGURATION => '01O', USER_UI_CONFIGURATION => '01O',
PROFILE_TAB_CONFIGURATION => '01P', PROFILE_TAB_CONFIGURATION => '01P',
WORKFLOW_RULE => '01Q', WORKFLOW_RULE => '01Q',
RULE_FILTER => '01R', RULE_FILTER => '01R',
RULE_FILTER_ITEM => '01S', RULE_FILTER_ITEM => '01S',
RULE_FILTER_ACTION => '01T', RULE_FILTER_ACTION => '01T',
ACTION_ASSIGN_ESCALATE => '01U', ACTION_ASSIGN_ESCALATE => '01U',
ACTION_TASK => '01V', ACTION_TASK => '01V',
ACTION_EMAIL => '01W', ACTION_EMAIL => '01W',
ACTION_EMAIL_RECIPIENT => '01X', ACTION_EMAIL_RECIPIENT => '01X',
CAMPAIGN_MEMBER_STATUS => '01Y', CAMPAIGN_MEMBER_STATUS => '01Y',
DASHBOARD => '01Z', DASHBOARD => '01Z',
DASHBOARD_COMPONENT => '01a', DASHBOARD_COMPONENT => '01a',
FILTER_ITEM => '01b', FILTER_ITEM => '01b',
FILTER_COLUMN => '01c', FILTER_COLUMN => '01c',
FOLDER_GROUPS => '01d', FOLDER_GROUPS => '01d',
PICKLIST_SET => '01e', PICKLIST_SET => '01e',
WEBEX_MEETING => '01f', WEBEX_MEETING => '01f',
API_QUERY => '01g', API_QUERY => '01g',
TRANSLATION => '01h', TRANSLATION => '01h',
TRANSLATION_USER => '01i', TRANSLATION_USER => '01i',
TRANSLATION_VALUE => '01j', TRANSLATION_VALUE => '01j',
PROFILE_FLS_ITEM => '01k', PROFILE_FLS_ITEM => '01k',
ACTION_RESPONSE => '01l', ACTION_RESPONSE => '01l',
BUSINESS_HOURS => '01m', BUSINESS_HOURS => '01m',
CASE_SHARE => '01n', CASE_SHARE => '01n',
LEAD_SHARE => '01o', LEAD_SHARE => '01o',
CUSTOM_TAB_DEFINITION => '01r', CUSTOM_TAB_DEFINITION => '01r',
PRICEBOOK2 => '01s', PRICEBOOK2 => '01s',
PRODUCT2 => '01t', PRODUCT2 => '01t',
PRICEBOOK_ENTRY => '01u', PRICEBOOK_ENTRY => '01u',
PRICEBOOK_SHARE => '01v', PRICEBOOK_SHARE => '01v',
OPP_UPDATE_REMINDER => '01w', OPP_UPDATE_REMINDER => '01w',
OPP_UPDATE_REMINDER_STATS => '01x', OPP_UPDATE_REMINDER_STATS => '01x',
CASE_SHARE_DEFAULT => '01y', CASE_SHARE_DEFAULT => '01y',
CASE_ESCALATION => '01z', CASE_ESCALATION => '01z',
EVENT_ATTENDEE => '020', EVENT_ATTENDEE => '020',
QUANTITY_FORECAST => '021', QUANTITY_FORECAST => '021',
FISCAL_YEAR_SETTINGS => '022', FISCAL_YEAR_SETTINGS => '022',
APP_CALENDAR => '023', APP_CALENDAR => '023',
APP_CALENDAR_SHARING => '024', APP_CALENDAR_SHARING => '024',
LIST_LAYOUT_ITEM => '025', LIST_LAYOUT_ITEM => '025',
PERIOD => '026', PERIOD => '026',
REVENUE_FORECAST => '027', REVENUE_FORECAST => '027',
OPPORTUNITY_OVERRIDE => '028', OPPORTUNITY_OVERRIDE => '028',
LINEITEM_OVERRIDE => '029', LINEITEM_OVERRIDE => '029',
LEAD_SHARE_DEFAULT => '02A', LEAD_SHARE_DEFAULT => '02A',
LABEL_DEFINITION => '02B', LABEL_DEFINITION => '02B',
LABEL_DATA => '02C', LABEL_DATA => '02C',
CASES_HISTORY2 => '02D', CASES_HISTORY2 => '02D',
HELP_SETTING => '02E', HELP_SETTING => '02E',
CUSTOM_FIELD_MAP => '02F', CUSTOM_FIELD_MAP => '02F',
MH_GOLD_PROGRAM => '02H', MH_GOLD_PROGRAM => '02H',
MH_GOLD_INFORMATION => '02I', MH_GOLD_INFORMATION => '02I',
MH_GOLD_CONTACT => '02J', MH_GOLD_CONTACT => '02J',
MH_GOLD_ACTION => '02K', MH_GOLD_ACTION => '02K',
MH_CUSTOMER_CRITERION => '02L', MH_CUSTOMER_CRITERION => '02L',
MH_GREENSHEET => '02M', MH_GREENSHEET => '02M',
MH_GREEN_GIVE_INFO => '02N', MH_GREEN_GIVE_INFO => '02N',
MH_GREEN_GET_INFO => '02O', MH_GREEN_GET_INFO => '02O',
MH_CONTACT_ROLE => '02P', MH_CONTACT_ROLE => '02P',
MH_INFORMATION => '02Q', MH_INFORMATION => '02Q',
USER_PREFERENCE2 => '02R', USER_PREFERENCE2 => '02R',
HTML_COMPONENT => '02S', HTML_COMPONENT => '02S',
CUSTOM_PAGE => '02T', CUSTOM_PAGE => '02T',
CUSTOM_PAGE_ITEM => '02U', CUSTOM_PAGE_ITEM => '02U',
PAGE_COMPONENT => '02V', PAGE_COMPONENT => '02V',
CUSTOM_PAGE_PROFILE => '02X', CUSTOM_PAGE_PROFILE => '02X',
USER_COMPONENT_DATA => '02Y', USER_COMPONENT_DATA => '02Y',
ACCOUNT_CONTACT_ROLE => '02Z', ACCOUNT_CONTACT_ROLE => '02Z',
CONTRACT_CONTACT_ROLE => '02a', CONTRACT_CONTACT_ROLE => '02a',
COMPONENT_RESOURCE_LINK => '02b', COMPONENT_RESOURCE_LINK => '02b',
DIVISION => '02d', DIVISION => '02d',
DIVISION_WORKFLOW_RULE => '02e', DIVISION_WORKFLOW_RULE => '02e',
DELEGATE_GROUP => '02f', DELEGATE_GROUP => '02f',
DELEGATE_GROUP_MEMBER => '02g', DELEGATE_GROUP_MEMBER => '02g',
DELEGATE_GROUP_GRANT => '02h', DELEGATE_GROUP_GRANT => '02h',
ASSET => '02i', ASSET => '02i',
PROFILE_ENTITY_PERMISSIONS => '02j', PROFILE_ENTITY_PERMISSIONS => '02j',
LIST_LAYOUT => '02k', LIST_LAYOUT => '02k',
OUTBOUND_QUEUE => '02l', OUTBOUND_QUEUE => '02l',
CUSTOM_INDEX => '02m', CUSTOM_INDEX => '02m',
CATEGORY_NODE => '02n', CATEGORY_NODE => '02n',
CATEGORY_DATA => '02o', CATEGORY_DATA => '02o',
DIV_TRANSFER_EVENT => '02p', DIV_TRANSFER_EVENT => '02p',
LAYOUT_ITEM_COLUMN => '02q', LAYOUT_ITEM_COLUMN => '02q',
OPPORTUNITY_ALERT => '02r', OPPORTUNITY_ALERT => '02r',
EMAIL_MESSAGE => '02s', EMAIL_MESSAGE => '02s',
EMAIL_ROUTING_ADDRESS => '02t', EMAIL_ROUTING_ADDRESS => '02t',
TAB_SET => '02u', TAB_SET => '02u',
TAB_SET_MEMBER => '02v', TAB_SET_MEMBER => '02v',
LOGIN_IP_RANGE => '02w', LOGIN_IP_RANGE => '02w',
LOGIN_HOURS => '02x', LOGIN_HOURS => '02x',
REPORT_AGGREGATE => '02y', REPORT_AGGREGATE => '02y',
REPORT_COLOR_RANGE => '02z', REPORT_COLOR_RANGE => '02z',
PROFILE_TAB_SET => '030', PROFILE_TAB_SET => '030',
USER_TAB_SET_MEMBER => '031', USER_TAB_SET_MEMBER => '031',
ACC_TERRITORY_RULE => '032', ACC_TERRITORY_RULE => '032',
PROJECT => '033', PROJECT => '033',
PROJECT_MEMBER => '034', PROJECT_MEMBER => '034',
SELF_SERVICE_USER => '035', SELF_SERVICE_USER => '035',
JOB_QUEUE => '036', JOB_QUEUE => '036',
REPORT_COLUMN => '037', REPORT_COLUMN => '037',
REPORT_FILTER_ITEM => '038', REPORT_FILTER_ITEM => '038',
REPORT_BREAK => '039', REPORT_BREAK => '039',
DEPENDENT_PICKLIST => '03a', DEPENDENT_PICKLIST => '03a',
PACKAGE_EXPORT => '03b', PACKAGE_EXPORT => '03b',
LAYOUT_RIGHT_PANEL => '03c', LAYOUT_RIGHT_PANEL => '03c',
CUSTOM_SETUP_DEFINITION => '03e', CUSTOM_SETUP_DEFINITION => '03e',
CUSTOM_SETUP => '03f', CUSTOM_SETUP => '03f',
REPORT_PARAM => '040', REPORT_PARAM => '040',
ACC_TERRITORY_ASSIGN => '041', ACC_TERRITORY_ASSIGN => '041',
ACC_TERR_ASSIGN_RULE_ITEM => '042', ACC_TERR_ASSIGN_RULE_ITEM => '042',
OUTBOUND_FIELD => '043', OUTBOUND_FIELD => '043',
USER_TERRITORY => '04S', USER_TERRITORY => '04S',
TERRITORY => '04T', TERRITORY => '04T',
DNB_ACCOUNT_MAPPING => '04U', DNB_ACCOUNT_MAPPING => '04U',
DNB_FIELD => '04V', DNB_FIELD => '04V',
REVENUE_FORECAST_HISTORY => '04W', REVENUE_FORECAST_HISTORY => '04W',
QUANTITY_FORECAST_HISTORY => '04X', QUANTITY_FORECAST_HISTORY => '04X',
CONTENTVERSION => '068', CONTENTVERSION => '068',
CONTENTDOCUMENT => '069', CONTENTDOCUMENT => '069',
ENTITY_PERMISSION => '110', ENTITY_PERMISSION => '110',
SFDC_PARTNER => '204', SFDC_PARTNER => '204',
SFDC_DIVISION => '208', SFDC_DIVISION => '208',
CASES => '500', CASES => '500',
SOLUTION => '501', SOLUTION => '501',
BILLING_DIVISION => '600', BILLING_DIVISION => '600',
BILLING_ORDER => '601', BILLING_ORDER => '601',
CURRENCY => '602', CURRENCY => '602',
PLAN => '604', PLAN => '604',
PRODUCT => '605', PRODUCT => '605',
BILLING_ORDER_ITEM => '606', BILLING_ORDER_ITEM => '606',
PLAN_PRODUCT => '607', PLAN_PRODUCT => '607',
CAMPAIGN => '701', CAMPAIGN => '701',
FIELD_HISTORY => '737', FIELD_HISTORY => '737',
UI_STYLE_DEFINITION => '766', UI_STYLE_DEFINITION => '766',
UI_STYLE => '777', UI_STYLE => '777',
CONTRACT => '800', CONTRACT => '800',
ORDERS => '801', ORDERS => '801',
ORDER_ITEM => '802', ORDER_ITEM => '802',
INVOICE => '803', INVOICE => '803',
INVOICE_ITEM => '804', INVOICE_ITEM => '804',
PAYMENT => '805', PAYMENT => '805',
APPROVAL => '806', APPROVAL => '806',
URI_BLOCK_RULE => '807', URI_BLOCK_RULE => '807',
PERMISSION_SET => '0PS', PERMISSION_SET => '0PS',
CUSTOM_ENTITY_DATA => 'a00' CUSTOM_ENTITY_DATA => 'a00'
); );
our $DEBUG = 1; our $DEBUG = 0;
sub new { sub new {
my( $class, $args ) = @_; my ( $class, $args ) = @_;
my $self = bless( { }, $class ); my $self = bless( {}, $class );
$DEBUG = $args->{debug} if exists $args->{debug}; $DEBUG = $args->{debug} if exists $args->{debug};
$self->{config} = $args; $self->{config} = $args;
$self->{version} = $VERSION; $self->{version} = $VERSION;
$self->{id} = $args->{id} || 0; $self->{id} = $args->{id} || 0;
die unless $args->{user}->{login} && $args->{user}->{password} && $args->{user}->{token}; die
unless $args->{user}->{login}
&& $args->{user}->{password}
&& $args->{user}->{token};
die unless $self->_connect; die unless $self->_connect;
return $self; return $self;
...@@ -471,10 +473,10 @@ sub new { ...@@ -471,10 +473,10 @@ sub new {
sub detect_type_by_id { sub detect_type_by_id {
my ( $self, $id ) = @_; my ( $self, $id ) = @_;
my ( $object_prefix ) = $id =~ m/^(.*?)w.*?$/isg; my ($object_prefix) = $id =~ m/^(.*?)w.*?$/isg;
foreach my $object_name ( keys %object_prefixes ) { foreach my $object_name ( keys %object_prefixes ) {
return $object_name if $object_prefixes{$object_name} eq $object_prefix; return $object_name if $object_prefixes{$object_name} eq $object_prefix;
} }
} }
...@@ -490,219 +492,288 @@ sub get_fields { ...@@ -490,219 +492,288 @@ sub get_fields {
my @fields; my @fields;
foreach my $field ( @{ $self->get_field_list($object) } ) { foreach my $field ( @{ $self->get_field_list($object) } ) {
push @fields, $field->{name}; push @fields, $field->{name};
} }
return \@fields; return \@fields;
} }
sub _connect { sub _connect {
my $self = shift; my $self = shift;
printf('login: %s pass: %s token: %s\n', $self->{config}->{user}->{login}, printf(
$self->{config}->{user}->{password}, $self->{config}->{user}->{token}) if $DEBUG; 'login: %s pass: %s token: %s\n',
$self->{config}->{user}->{login},
$self->{config}->{user}->{password},
$self->{config}->{user}->{token}
) if $DEBUG;
my $sforce = eval { my $sforce = eval {
WWW::Salesforce->login( WWW::Salesforce->login(
username => $self->{config}->{user}->{login}, username => $self->{config}->{user}->{login},
password => $self->{config}->{user}->{password} . $self->{config}->{user}->{token} password => $self->{config}->{user}->{password}
); . $self->{config}->{user}->{token}
}; );
};
$self->{connection} = $sforce unless $@; $self->{connection} = $sforce unless $@;
$self->{server} = $self->{connection}->{sf_serverurl} unless $@; $self->{server} = $self->{connection}->{sf_serverurl} unless $@;
( $self->{instance} ) = $self->{server} =~ m/https\:\/\/(.*?)\.salesforce\.com\// if $self->{server}; ( $self->{instance} ) =
$self->{server} = sprintf("https://%s.salesforce.com", $self->{instance}) if $self->{instance}; $self->{server} =~ m/https\:\/\/(.*?)\.salesforce\.com\//
if $self->{server};
$self->{server} = sprintf( "https://%s.salesforce.com", $self->{instance} )
if $self->{instance};
return $self unless $@; return $self unless $@;
return undef; return undef;
} }
sub get_url { sub get_url {
my( $self, $id ) = @_; my ( $self, $id ) = @_;
return sprintf("%s/%s", $self->{server}, $id); return sprintf( "%s/%s", $self->{server}, $id );
} }
sub fix_object { sub fix_object {
my( $self, $object ) = @_; my ( $self, $object ) = @_;
$object->{contact_source} = $self->{id}; return
if exists $object->{IsDeleted} and delete $object->{IsDeleted} eq 'true';
return
if exists $object->{IsConverted}
and delete $object->{IsConverted} eq 'true';
if (exists $object->{Id}) { $object->{contact_source} = $self->{id};
$object->{contact_source_type} = "Salesforce";
if (ref $object->{Id} eq "ARRAY") { if ( exists $object->{Id} ) {
$object->{URL} = $self->get_url($object->{Id}->[0]); $object->{contact_source_type} = "Salesforce";
$object->{Id} = [ $object->{Id}->[0] ];
} else { if ( ref $object->{Id} eq "ARRAY" ) {
$object->{URL} = $self->get_url($object->{Id}); $object->{URL} = $self->get_url( $object->{Id}->[0] );
$object->{Id} = [ $object->{Id} ]; $object->{Id} = [ $object->{Id}->[0] ];
} }
else {
$object->{URL} = $self->get_url( $object->{Id} );
$object->{Id} = [ $object->{Id} ];
}
} }
$object = $self->bless_hash($object); $object = $self->fix_hash($object);
return $object; return $object;
} }
sub upsert { sub upsert {
my( $self, $args ) = @_; my ( $self, $args ) = @_;
my $want_object = delete $args->{want_object}; my $want_object = delete $args->{want_object};
my $response = $self->{connection}->upsert( my $response = $self->{connection}->upsert(
type => $args->{object}, type => $args->{object},
key => $args->{key} || "Id", key => $args->{key} || "Id",
$args->{record} $args->{record}
); );
for my $result ($response->valueof('//upsertResponse/result')) { for my $result ( $response->valueof('//upsertResponse/result') ) {
my $object = $self->query({object => $args->{object}, query => {criteria => sprintf ( "Id = '%s'", $result->{id} ) } }) if exists $result->{id}; my $object = $self->query(
return $object->[0] if ref $object eq "ARRAY" && scalar @{ $object }; {
object => $args->{object},
query => { criteria => sprintf( "Id = '%s'", $result->{id} ) }
}
) if exists $result->{id};
return $object->[0] if ref $object eq "ARRAY" && scalar @{$object};
} }
} }
sub find { sub find {
my( $self, $args ) = @_; my ( $self, $args ) = @_;
my @result; my @result;
my @returns; my @returns;
# ALL FIELDS NAME FIELDS EMAIL FIELDS PHONE FIELDS SIDEBAR FIELDS my $query = sprintf(
my $query = sprintf("find {%s} in %s fields returning ", $args->{query}->{what}, $args->{query}->{where} || "ALL"); "find {%s} in %s fields returning ",
$args->{query}->{what},
$args->{query}->{where} || "ALL"
);
foreach my $object ( keys %{ $args->{returns} } ) { foreach my $object ( keys %{ $args->{returns} } ) {
push @returns, sprintf("%s(%s)", $object, join ( ", ", @{ $args->{returns}->{$object} } ) ); push @returns,
sprintf( "%s(%s)",
$object, join( ", ", @{ $args->{returns}->{$object} } ) );
} }
$query .= join ", ", @returns; $query .= join ", ", @returns;
my $response = $self->{connection}->search( 'searchString' => $query ); my $response = $self->{connection}->search( 'searchString' => $query );
for my $rec_result ($response->valueof('//searchResponse/result/searchRecords')) { for my $rec_result (
push @result, $self->fix_object($rec_result->{record}); $response->valueof('//searchResponse/result/searchRecords') )
{
push @result, $self->fix_object( $rec_result->{record} );
} }
return \@result; return [ grep { defined $_ } @result ];
} }
sub query { sub query {
my( $self, $args ) = @_; my ( $self, $args ) = @_;
my @result; my @result;
my @returns; my @returns;
my $query = sprintf("SELECT %s FROM %s WHERE %s", my $query = sprintf(
join(" ,", @{ exists $args->{query}->{fields} ? $args->{query}->{fields} : $self->get_fields($args->{object}) } ), "SELECT %s FROM %s WHERE %s",
$args->{object}, join(
$args->{query}->{criteria} " ,",
); @{
exists $args->{query}->{fields}
? $args->{query}->{fields}
: $self->get_fields( $args->{object} )
}
),
$args->{object},
$args->{query}->{criteria}
);
my $response = $self->{connection}->query( query => $query ); my $response = $self->{connection}->query( query => $query );
for my $rec_result ($response->valueof('//queryResponse/result/records')) { for my $rec_result ( $response->valueof('//queryResponse/result/records') )
push @result, $self->fix_object($rec_result); {
push @result, $self->fix_object($rec_result);
} }
return \@result; return \@result;
} }
sub get_records { sub get_records {
my( $self, $args ) = @_; my ( $self, $args ) = @_;
my @result; my @result;
my @returns; my @returns;
my $query = sprintf("SELECT %s FROM %s", my $query = sprintf(
join(" ,", @{ exists $args->{query}->{fields} ? $args->{query}->{fields} : $self->get_fields($args->{object}) } ), "SELECT %s FROM %s",
$args->{object} join(
); " ,",
@{
exists $args->{query}->{fields}
? $args->{query}->{fields}
: $self->get_fields( $args->{object} )
}
),
$args->{object}
);
my $response = $self->{connection}->query( query => $query, limit => $args->{limit} || 1000 ); my $response = $self->{connection}
->query( query => $query, limit => $args->{limit} || 1000 );
for my $rec_result ($response->valueof('//queryResponse/result/records')) { for my $rec_result ( $response->valueof('//queryResponse/result/records') )
push @result, $self->fix_object($rec_result); {
push @result, $self->fix_object($rec_result);
} }
return \@result; return \@result;
} }
sub _get_data { sub _get_data {
my( $self ) = @_; my ($self) = @_;
my $response = $self->{connection}->get_session_header; my $response = $self->{connection}->get_session_header;
return { return {
session => $response, session => $response,
client => $self->{connection}->{sf_serverurl} client => $self->{connection}->{sf_serverurl}
}; };
} }
sub get_session_id { sub get_session_id {
my( $self ) = @_; my ($self) = @_;
my $session_value = eval { my $session_value = eval {
my $session = $self->{connection}->get_session_header->value; my $session = $self->{connection}->get_session_header->value;
$$session->${'value'}; $$session->${'value'};
}; };
return $session_value; return $session_value;
} }
sub find_phone { sub find_phone {
my( $self, $phone ) = @_; my ( $self, $phone ) = @_;
return $self->find({ return $self->find(
query => { {
what => $phone, query => {
where => "phone" what => $phone,
}, where => "phone"
returns => { },
contact => ["id", "phone", "firstname", "lastname", "department", "email"], returns => {
lead => ["id", "phone", "firstname", "lastname", "company", "email"] contact => [
} "id", "phone", "firstname", "lastname",
}); "department", "email"
],
lead => [
"id", "phone", "firstname", "lastname",
"company", "email", "isconverted", "isdeleted"
]
}
}
);
} }
sub query_by_fields { sub query_by_fields {
my( $self, $query, $fields ) = @_; my ( $self, $query, $fields ) = @_;
my $lead_fields = { my $lead_fields = {
"fullname" => qq{FirstName LIKE '%$query%' OR LastName LIKE '%$query%'}, "fullname" => qq{FirstName LIKE '%$query%' OR LastName LIKE '%$query%'},
"firstname"=> qq{FirstName LIKE '%$query%'}, "firstname" => qq{FirstName LIKE '%$query%'},
"lastname" => qq{LastName LIKE '%$query%'}, "lastname" => qq{LastName LIKE '%$query%'},
"comapny" => qq{Company LIKE '%$query%'}, "comapny" => qq{Company LIKE '%$query%'},
"phone" => qq{Phone LIKE '%$query%' OR Fax LIKE '%$query%' OR MobilePhone LIKE '%$query%'}, "phone" =>
"email" => qq{Email LIKE '%$query%'}, qq{Phone LIKE '%$query%' OR Fax LIKE '%$query%' OR MobilePhone LIKE '%$query%'},
"email" => qq{Email LIKE '%$query%'},
}; };
my $contact_fields = { my $contact_fields = {
"fullname" => qq{FirstName LIKE '%$query%' OR LastName LIKE '%$query%'}, "fullname" => qq{FirstName LIKE '%$query%' OR LastName LIKE '%$query%'},
"firstname"=> qq{FirstName LIKE '%$query%'}, "firstname" => qq{FirstName LIKE '%$query%'},
"lastname" => qq{LastName LIKE '%$query%'}, "lastname" => qq{LastName LIKE '%$query%'},
"comapny" => qq{Department LIKE '%$query%'}, "comapny" => qq{Department LIKE '%$query%'},
"phone" => qq{Phone LIKE '%$query%' OR Fax LIKE '%$query%' OR HomePhone LIKE '%$query%' OR MobilePhone LIKE '%$query%' OR OtherPhone LIKE '%$query%'}, "phone" =>
"email" => qq{Email LIKE '%$query%'}, qq{Phone LIKE '%$query%' OR Fax LIKE '%$query%' OR HomePhone LIKE '%$query%' OR MobilePhone LIKE '%$query%' OR OtherPhone LIKE '%$query%'},
"email" => qq{Email LIKE '%$query%'},
}; };
my $contacts_query_criteria = [ ]; my $contacts_query_criteria = [];
map { push @{ $contacts_query_criteria }, $contact_fields->{$_} if exists $contact_fields->{$_} } @{ $fields }; map {
push @{$contacts_query_criteria}, $contact_fields->{$_}
my $leads_query_criteria = [ ]; if exists $contact_fields->{$_}
map { push @{ $leads_query_criteria }, $lead_fields->{$_} if exists $lead_fields->{$_} } @{ $fields }; } @{$fields};
my $contacts = $self->query({ my $leads_query_criteria = [];
query => { map {
criteria => join ' OR ', @{ $contacts_query_criteria } push @{$leads_query_criteria}, $lead_fields->{$_}
}, if exists $lead_fields->{$_}
object => 'Contact' } @{$fields};
});
my $contacts = $self->query(
{
query => {
criteria => join ' OR ',
@{$contacts_query_criteria}
},
object => 'Contact'
}
);
my $leads = $self->query({ my $leads = $self->query(
query => { {
criteria => join ' OR ', @{ $leads_query_criteria } query => {
}, criteria => join ' OR ',
object => 'Lead' @{$leads_query_criteria}
}); },
object => 'Lead'
}
);
my @result = ( @{$contacts}, @{$leads} ); my @result = ( @{$contacts}, @{$leads} );
...@@ -710,93 +781,122 @@ sub query_by_fields { ...@@ -710,93 +781,122 @@ sub query_by_fields {
} }
sub query_all { sub query_all {
my( $self, $query, $fields ) = @_; my ( $self, $query, $fields ) = @_;
return $self->query_by_fields($query, $fields) if defined $fields && ref $fields eq 'ARRAY' && scalar @{ $fields }; return $self->query_by_fields( $query, $fields )
if defined $fields && ref $fields eq 'ARRAY' && scalar @{$fields};
return $self->find({
query => { return $self->find(
what => $query, {
#where => "phone" query => {
where => "ALL" what => $query,
},
returns => { #where => "phone"
contact => ["id", "phone", "homephone", "mobilephone", "otherphone", "firstname", "lastname", "department", "email"], where => "ALL"
lead => ["id", "phone", "mobilephone", "firstname", "lastname", "company", "email"] },
} returns => {
}); contact => [
"id", "phone", "homephone", "mobilephone",
"otherphone", "firstname", "lastname", "department",
"email"
],
lead => [
"id", "phone",
"mobilephone", "firstname",
"lastname", "company",
"email", "isconverted",
"isdeleted"
]
}
}
);
} }
sub query_tasks_by_rec_id { sub query_tasks_by_rec_id {
my( $self, $rec_id ) = @_; my ( $self, $rec_id ) = @_;
return $self->query(
{
query => {
return $self->query({
query => {
# fields => ["Id", "AccountId", "CallDisposition", "Description", "OwnerId", "Subject", "CallType", "WhatId", "WhoId"], # fields => ["Id", "AccountId", "CallDisposition", "Description", "OwnerId", "Subject", "CallType", "WhatId", "WhoId"],
criteria => "CallDisposition = '" . $rec_id . "'" criteria => "CallDisposition = '" . $rec_id . "'"
}, },
object => "Task" object => "Task"
}); }
);
} }
sub query_tasks_by_id { sub query_tasks_by_id {
my( $self, $id ) = @_; my ( $self, $id ) = @_;
return $self->query(
{
query => {
return $self->query({
query => {
# fields => ["Id", "AccountId", "CallDisposition", "Description", "OwnerId", "Subject", "CallType", "WhatId", "WhoId"], # fields => ["Id", "AccountId", "CallDisposition", "Description", "OwnerId", "Subject", "CallType", "WhatId", "WhoId"],
criteria => "Id = '" . $id . "'" criteria => "Id = '" . $id . "'"
}, },
object => "Task" object => "Task"
}); }
);
} }
sub query_leads_by_id { sub query_leads_by_id {
my( $self, $id ) = @_; my ( $self, $id ) = @_;
return $self->query(
{
query => {
return $self->query({
query => {
# fields => ["Id", "Company", "Description", "Email", "FirstName", "LastName", "Name", "Phone", "Title"], # fields => ["Id", "Company", "Description", "Email", "FirstName", "LastName", "Name", "Phone", "Title"],
criteria => "Id = '" . $id . "'" criteria => "Id = '" . $id . "'"
}, },
object => "Lead" object => "Lead"
}); }
);
} }
sub query_contacts_by_id { sub query_contacts_by_id {
my( $self, $id ) = @_; my ( $self, $id ) = @_;
return $self->query(
{
query => {
return $self->query({
query => {
# fields => ["Id", "Department", "Description", "Email", "FirstName", "LastName", "Name", "Phone", "Title"], # fields => ["Id", "Department", "Description", "Email", "FirstName", "LastName", "Name", "Phone", "Title"],
criteria => "Id = '" . $id . "'" criteria => "Id = '" . $id . "'"
}, },
object => "Contact" object => "Contact"
}); }
);
} }
sub query_accounts_by_id { sub query_accounts_by_id {
my( $self, $id ) = @_; my ( $self, $id ) = @_;
return $self->query(
{
query => {
return $self->query({
query => {
# fields => ["Id", "Department", "Description", "Email", "FirstName", "LastName", "Name", "Phone", "Title"], # fields => ["Id", "Department", "Description", "Email", "FirstName", "LastName", "Name", "Phone", "Title"],
criteria => "Id = '" . $id . "'" criteria => "Id = '" . $id . "'"
}, },
object => "Account" object => "Account"
}); }
);
} }
sub bless_hash { sub fix_hash {
my ($self, $object) = @_; my ( $self, $object ) = @_;
my $result = { }; my $result = {};
eval { eval {
foreach my $key ( keys %{ $object } ) { foreach my $key ( keys %{$object} ) {
next if $key =~ m/\_{2,}/; next if $key =~ m/\_{2,}/;
$result->{$key} = $object->{$key}; $result->{$key} = $object->{$key};
$result->{$key} = '' unless defined $object->{$key}; $result->{$key} = '' unless defined $object->{$key};
} }
}; };
return $result; return $result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment