- 03 Jun 2022
- 3 Minutes to read
- Print
- DarkLight
Force.com Adapter Actions
- Updated on 03 Jun 2022
- 3 Minutes to read
- Print
- DarkLight
Force.com Adapter Actions
deleteForceComRecord
Deletes the record in ForceCom. Returns a success boolean.
Property | Value | Description |
connection* | expression, variable | the ForceCom connection object |
id* | text, expression, variable | The Id of the ForceCom record to delete. |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
# Delete the incident
if(incident){
deleted = deleteForceComRecord(sessionForce, newIncidentId)
if(deleted){
log("incident deleted")
} else {
log("Unable to delete incident", "ERROR")
}
} else {
}
deleteForceComRecords
Deletes the records in ForceCom. Returns a result object containing the fields 'id','success', and 'errors', which are either single entries or arrays.
Property | Value | Description |
connection* | expression, variable | the ForceCom connection object |
ids* | text, expression, variable | The Ids of the ForceCom records to delete. |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
deleted = deleteForceComRecords(sessionForce, [idToDeleteA,
idToDeleteB])
getForceComRecord
Gets a given ForceCom Record.
Property | Value | Description |
connection* | expression, variable | the ForceCom connection object |
objectType* | text, expression, variable | The ForceCom object type |
id* | text, expression, variable | The Id of the ForceCom record. |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
records = getForceComRecords(sessionForce, "Account", "Id, Name,
OwnerId"
getForceComRecords
Get multiple ForceCom Records matching the given filter, or all records if no filter is supplied.
Property | Value | Description |
connection* | expression, variable | the ForceCom connection object |
objectType* | text, expression, variable | The ForceCom object type |
filter | text, expression, variable | The filter used to limit results. Can either be an encoded query as specified by ForceCom, or a Record example object. |
fields | text, expression, variable | The fields returned in the query. Defaults to all fields. |
limit | expression, variable | The maximum number of records to return. Defaults to all objects. |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
records - getForceComRecords(sessionForce, "Account", query,
"Id, Name, OwnerId")
openForceComConnection
Opens a connection to a ForceCom Server.
Property | Value | Description |
username* | text, expression, variable | Username for authentication to the ForceCom web service |
password* | password, string, expression, variable | Password for authentication to the ForceCom web service. When authenticating through the API or client it is necessary to append the security token to the password in the form passwordSecurityToken. The security token is a case-sensitive, alphanumeric string and it can be obtained through the Salesforce UI Personal Settings through Reset Your Security Token or by changing the Salesforce password. |
apiVersion | text, expression, variable | API Version to use |
options | expression, variable | A record or JavaScript object with a field for each additional option. The currently defined fields are connectTimeout and socketTime which require a numeric value from 1 to 2147483647 (0x7FFFFFFF) that represents the number of milliseconds for the timeout, and 0 representing no timeout. |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
# Open Connections
{
sessionAD = openADConnection(Global.idautoHost, Global.idautoPort,
Global.idautoSSL, Global.idautoUser, <Password>)
sessionForce = openForceComConnection(Global.forceUser, <Password>)
if(!sessionAD || !sessionForce){
# --- Error making connections. Terminating process.
return null
} else {
}
}
openForceComRecordIterator
Open ForceCom Record Iterator.
Property | Value | Description |
connection* | expression, variable | the ForceCom connection object |
objectType* | text, expression, variable | The ForceCom object type |
filter | text, expression, variable | The filter used to limit results. Can either be an encoded query as specified by ForceCom, or a Record example object. |
fields | text, expression, variable | The fields returned in the query. Defaults to all fields. |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
records = openForceComRecordIterator(sessionForce, "Contact", filter)
saveForceComRecord
Creates or updates the record in ForceCom. Returns the id of the object, or null on failure.
Property | Value | Description |
connection* | expression, variable | the ForceCom connection object |
record* | text, expression, variable | A Record object containing the fields you want to save. If 'Id' is set, an update will be performed, otherwise a create will be performed. |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
result = saveForceComRecord(sessionForce, recordForce)
saveForceComRecords
Creates or updates multiple records in ForceCom. Returns a result object containing the fields 'id','success', and 'errors', which are either single entries or arrays.
Property | Value | Description |
connection* | expression, variable | the ForceCom connection object |
records* | text, expression, variable | An array of Record objects containing the fields you want to save. If 'Id' is set for a given Record, an update will be performed, otherwise a create will be performed. |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
results = saveForceComRecords(sessionForce, records)
Complete Example
# open csv file containing new leads
csvInput = openDelimitedTextInput("data/leads.csv",
"FirstName,LastName,Email,Company")
# open session to Force.com to access Salesforce app
sessionSalesforce = openForceComConnection("user@example.com",
<Password> , {
socketTimeout: 10000
})
# loop through new leads
forEach(csvRecord, csvInput) {
# check for existing lead with same email address
existing = getForceComRecords(sessionSalesforce, "Lead", {
Email: "'" + csvRecord["Email"] + "'"
})
if (existing & amp; & amp; existing[0]) {
# lead exists, update the other fields
record = createRecord(true) setRecordFieldValue(record, "type",
"Lead")
setRecordFieldValue(record, "Id", existing[0]["Id"])
copyRecordFields(csvRecord, record, "FirstName, LastName,
Company")
updatedId = saveForceComRecord(sessionSalesforce, record)
if (updatedId) {
log("Updated existing lead for: " + toJSON(csvRecord),
"INFO")
} else {
log("Error updating existing lead for: " +
toJSON(csvRecord), "ERROR")
}
} else {
# lead doesn 't exist, so add
record = createRecord(true)
setRecordFieldValue(record, "type", "Lead")
copyRecordFields(csvRecord, record, "FirstName, LastName,
Email, Company")
createdId = saveForceComRecord(sessionSalesforce, record)
if (createdId) {
log("Added new lead for: " + toJSON(csvRecord), "INFO")
} else {
log("Error updating existing lead for: " + toJSON(csvRecord),
"ERROR")
Go }
}
}
close(sessionSalesforce)
close(csvInput)