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