# Salesforce Events
In this part, events related to Salesforce are documented.
# Ti.App.fireEvent('sendFileToSFDC')
Send the local stats and path of the file to the SFDC. This method sends file without any timestamp attachment, then creates an attachment object from parameters and redirects all of the data to CRM.
Example:
Ti.App.fireEvent('sendFileToSFDC', {
filePath: 'myFilePath',
objectType: 'myObjectType',
sfdcID: 'mySfdcID',
externalID: 'myExternalID',
externalIDField: 'myExternalIDField',
name: 'myName',
})
filePath
- the full path of the file to be savedobjectType
- salesforce Object API Name of the parent object this attachment should be attached tosfdcID
- ID regarding to SFDC. Instead of externalIDField and externalID an object Id of the parent object can be supplied if knownexternalID
- externalID of the attachment objectexternalIDField
- external ID field name of the parent objectname
- name of the attachment
# Ti.App.fireEvent('resyncData')
Resynchronizes data with Salesforce CRM.
Example:
Ti.App.fireEvent('resyncData')
# Ti.App.fireEvent('makeSFFullScreen')
Converts SalesForce popover into full screen.
Example:
Ti.App.fireEvent('makeSFFullScreen')
# Ti.App.fireEvent('getSFUrl')
Retrieves Salesforce URL using the path and authentication service's sessionID.
Example:
Ti.App.fireEvent('getSFUrl', {
callBackFunc: 'myCallBackFunc',
source: 'mySource',
path: 'myPath',
})
callBackFunc
- callBack function which is evaluated with targeted WebViewsource
- define the targeted web view.- accepted values:
modal
,postcall
,precall
(modalWebView),homescreen
(mainWebView),sfdcWebView
(sfdcWebView),popover
(initPopover.webview),''
(blank, currentPage's webview)
- accepted values:
path
- path to the object. If null, then it will be automatically set to/home/home.jsp
NOTE
Android: No need for source
parameter.
# Ti.App.fireEvent('getSFInfo')
Retrieves Salesforce information using lastCRMUpdate property. Gathers information from tbl_calls_n_v6 table where call is done but not submitted. Then using this information, it matches call information to the current contacts.
Example:
Ti.App.fireEvent('getSFInfo', {
callBackFunc: 'myCallBackFunc',
source: 'mySource',
path: 'myPath',
})
callBackFunc
- callBack function which is evaluated with targeted WebViewsource
- define the targeted web view. Can be: 'modal', 'postcall', 'precall'(modalWebView), 'homescreen'(mainWebView), 'sfdcWebView'(sfdcWebView), 'popover'(initPopover.webview), default -> currentPage's webviewpath
- path to the object. If null, then it will be automatically set to/home/home.jsp
NOTE
Android: Only needs parameter callBack
as callback function.
# Ti.App.fireEvent('fixMissingPDFsFromSFDC')
Fixes missing PDFs from SFDC.
Works with app config and custom caches from app config file; so, if any of these is not existent, then this function will create an SFDC.ForceOAuth.attachment with an update query on custom cache_table to cache attribute and re-fire itself.
Example:
Ti.App.fireEvent('fixMissingPDFsFromSFDC', {
objectType: 'myObjectType',
source: 'mySource',
callBack: 'myCallBack',
})
objectType
- type of the object.source
- defines the targeted web view. Can be: 'modal', 'postcall', 'precall'(modalWebView), 'homescreen'(mainWebView), 'sfdcWebView'(sfdcWebView), 'popover'(initPopover.webview), default -> currentPage's webviewcallBack
- callBack function which is evaluated with targeted WebView
# createMultipleSFDC (event_redirect_createMultipleSFDC)
Creates multiple records on Salesforce.
Example:
const parent = {
objectType: 'MyParentObject__c',
ExternalID__c: 'PIT_MyId',
My_Field__c: 'hello world',
externalField: 'ExternalID__c',
}
const child = {
objectType: 'MyChildObject__c',
externalID: 'PIT_MyOtherAwesomeID',
Parent__c: 'PIT_MyId',
parentExternalField: 'ExternalID__c',
relationshipName: 'Parent__c',
ignoreFields: ['relationshipName'],
}
Ti.App.fireEvent('sendStatsFromHTML', {
event_name: 'event_redirect_createMultipleSFDC',
event_params: {records: [parent,child]},
})
Example 2:
const parent = {
objectType: 'PITCHER__Pitcher_Presentation__c',
PITCHER__Post_Call_Notes__c: 'hello world',
PITCHER__ExternalID__c: 'PIT_1234567890',
externalField: 'PITCHER__ExternalID__c',
}
const child = {
objectType: 'PITCHER__Pitcher_Activity__c',
PITCHER__Pitcher_Presentation__c: 'PIT_1234567890',
parentExternalField: 'PITCHER__ExternalID__c',
relationshipName: 'PITCHER__Pitcher_Presentation__c',
ignoreFields: ['relationshipName'],
}
Ti.App.fireEvent('sendStatsFromHTML', {
event_name: 'event_redirect_createMultipleSFDC',
event_params: {records: [parent,child]},
})
event_params.externalField
- if an external ID is know which field is it saved toevent_params.parentExternalField
- the external field name of the parent objectevent_params.relationshipName
- Parent field for parentExternalFieldevent_params.fieldsToNull
- which fields should be nulled.event_params.ignoreFields
- fields of event_params that are ignored - optionalevent_params.pitcherTimestamp
- timestamp of data - optionalevent_params.ignoreFields
- fields of event_params that are ignored - optionalevent_params.apiVersion
- salesforce API version to be used - optionalevent_params.externalPitcherID
- If object is connected to Contact or Account provide the field of the external ID of parent Account or parent Contact
# createSFDC (event_redirect_createSFDC)
Updates an object on Salesforce and writes it to the local database. If an object was created before with event_redirect_createSFDC
the event
will be merged with this one. Multiple events sent will result in only one event at the end.
Example:
const parent = {
objectType: 'MyParentObject__c',
ExternalID__c: 'PIT_MyId',
My_Field__c: 'hello world',
externalField: 'ExternalID__c',
}
const child = {
objectType: 'MyChildObject__c',
externalID: 'PIT_MyOtherAwesomeID',
Parent__c: 'PIT_MyId',
parentExternalField: 'ExternalID__c',
relationshipName: 'Parent__c',
ignoreFields: ['relationshipName'],
}
Ti.App.fireEvent('sendStatsFromHTML', {
event_name: 'event_redirect_createSFDC',
event_params: parent,
})
Ti.App.fireEvent('sendStatsFromHTML', {
event_name: 'event_redirect_createSFDC',
event_params: child,
})
Example 2:
const parent = {
objectType: 'PITCHER__Pitcher_Presentation__c',
PITCHER__Post_Call_Notes__c: 'hello world',
PITCHER__ExternalID__c: 'PIT_1234567890',
externalField: 'PITCHER__ExternalID__c',
}
const child = {
objectType: 'PITCHER__Pitcher_Activity__c',
PITCHER__Pitcher_Presentation__c: 'PIT_1234567890',
parentExternalField: 'PITCHER__ExternalID__c',
relationshipName: 'PITCHER__Pitcher_Presentation__c',
ignoreFields: ['relationshipName'],
}
Ti.App.fireEvent('sendStatsFromHTML', {
event_name: 'event_redirect_createSFDC',
event_params: parent,
})
Ti.App.fireEvent('sendStatsFromHTML', {
event_name: 'event_redirect_createSFDC',
event_params: child,
})
event_params.externalField
- if an external ID is know which field is it saved toevent_params.parentExternalField
- the external field name of the parent objectevent_params.relationshipName
- Parent field for parentExternalFieldevent_params.fieldsToNull
- which fields should be nulled.event_params.ignoreFields
- fields of event_params that are ignored - optionalevent_params.pitcherTimestamp
- timestamp of data - optionalevent_params.ignoreFields
- fields of event_params that are ignored - optionalevent_params.apiVersion
- salesforce API version to be used - optionalevent_params.externalPitcherID
- If object is connected to Contact or Account provide the field of the external ID of parent Account or parent Contact
# updateSFDC (event_redirect_updateSFDC)
Updates an object on Salesforce and writes it to the local database. If an object was created before with event_redirect_updateSFDC
the event
will be merged with this one. Multiple events sent will result in only one event at the end.
Example:
const params = {
objectType: 'MySalesforceObject__c',
Id: 'a0W1t000001xeLDEAY',
My_Field__c: 'hello world',
}
Ti.App.fireEvent('sendStatsFromHTML', {
event_name: 'event_redirect_updateSFDC',
event_params: params,
})
event_params
- data to be sentevent_params.fieldToUpsert
- which field should be handled as an ID field... externalID field normaly usedevent_params.externalField
- if an external ID is know which field is it saved toevent_params.fieldsToNull
- which fields should be nulled.event_params.ignoreFields
- fields of event_params that are ignored - optionalevent_params.pitcherTimestamp
- timestamp of data - optionalevent_params.ignoreFields
- fields of event_params that are ignored - optionalevent_params.apiVersion
- salesforce API version to be used - optional