Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents

"CRUD" Request Types

...

...

Read

Read object data from the database. This API will filter the objects based on the field names and values in the data portion of the request. There is no way to limit the fields returned by this API, so full object data will always be returned.

language
var request = {
 

  "type"
 : "read",
  
"object" : "Account",
  
"data" 
: { "Name" : "John Doe Industries" }
};
bridge.sendRequest(request, function (responseData) {
  
alert('Javascript got its read response: ' + responseData); });

Create a Salesforce Object. This API will create only one object per request using the field names and values provided in the data portion of the request. This is equivalent to saving a new record from the Pulsar native user interface. Optionally, specifying the argument skipLayoutRequiredFieldCheck as TRUE will avoid checking for fields marked required on the Salesforce layout for the object.

Code Block
js
Anchor
createcreate
Panel
titleCreate
Warning

Multiple create, update, or delete requests MUST NOT run concurrently, and should instead be run sequentially. Furthermore, this API will have the following effects (if these features are enabled):

  • run PSL Object Triggers for the record(s) in question
  • process SFDC ValidationRules for the record(s) in question
  • re-calculate and save formula fields for the record(s) in question
  • re-calculate roll-up summary fields on parent object(s) records(s) for record(s) in question
Code Block
languagejs
var request = {
    "type" : "create",
    "object" : "Account",
    "data" : { "Name" : "John Doe Industries", "Phone" : "867-5309" },
    "args" : { "skipLayoutRequiredFieldCheck" : "FALSE" } // OPTIONAL : if specified as "TRUE", will avoid checking for missing layout required fields
};
bridge.sendRequest(request, function (responseData) { 
	alert('Javascript got its create response: ' + responseData); 
});
Anchorupdateupdate Panel
titleUpdate (single record only)

Update an existing Salesforce Object. This API will update only one object per request using the field names and values provided in the data portion of the request. The Id field is a required to identify the record to update. This is equivalent to saving a record from the Pulsar native user interface. Optionally, specifying the argument skipLayoutRequiredFieldCheck as TRUE will avoid checking for fields marked required on the Salesforce layout for the object

Warning

Multiple create, update, or delete requests MUST NOT run concurrently, and should instead be run sequentially. Furthermore, this API will have the following effects (if these features are enabled):

  • run PSL Object Triggers for the record(s) in question
  • process SFDC ValidationRules for the record(s) in question
  • re-calculate and save formula fields for the record(s) in question
  • re-calculate roll-up summary fields on parent object(s) records(s) for record(s) in question
Code Block
languagejs
var request = { 
    "type" : "update",
    "object" : "Account",
    "data" : { "Id" : "001234567891234", "Name" : "John Doe Industries, Inc", "Phone" : "(555) 867-5309" },
              // Id is a required field to identify the record to update
    "args" : { "skipLayoutRequiredFieldCheck" : "FALSE" } // OPTIONAL : if specified as "TRUE", will avoid checking for missing layout required fields
};
bridge.sendRequest(request, function (responseData) { 
	alert('Javascript got its update response: ' + responseData); 
});
Anchordeletedelete Panel
titleDelete (single record only)

Delete an existing Salesforce Object. This API will delete only one object per request using the Id field to identify the record. This is equivalent to deleting a record from the Pulsar native user interface. 

Warning

Multiple create, update, or delete requests MUST NOT run concurrently, and should instead be run sequentially. Furthermore, this API will have the following effects (if these features are enabled):

  • run PSL Object Triggers for the record(s) in question
  • process SFDC ValidationRules for the record(s) in question
  • re-calculate and save formula fields for the record(s) in question
  • re-calculate roll-up
    if (responseData.type === 'error') {
        // when there is an error, the responseData will contain the error message
        alert('There was an error submitting your read request to Pulsar. ' + responseData.data);
      } else {
        // when the request succeeds, the responseData will contain an array of the matching objects
        const records = responseData.data;
        if (records.length > 0) {
          alert(`We found ${records.length} records matching Name = John Doe Industries`);
          alert(`The Id of the first record is ${records[0]['Id']}`);
        }
      }
    });

    Create

    Create a Salesforce Object. This API will create only one object per request using the field names and values provided in the data portion of the request. This is equivalent to saving a new record from the Pulsar native user interface. Optionally, specifying the argument skipLayoutRequitedFieldCheck as TRUE will avoid checking for fields marked required on the Salesforce layout for the object. The default behavior for is to display Pulsar’s record create screen if a field validation error or record creation error occurs. To disable this behavior, specify the allowEditOnFailure argument with a value of FALSE.

    Note

    Multiple create, update, or delete requests MUST NOT run concurrently, and should instead be run sequentially. Furthermore, this API will have the following effects (if these features are enabled):

    • run PSL Object Triggers for the record(s) in question

    • process SFDC ValidationRules for the record(s) in question

    • re-calculate and save formula fields for the record(s) in question

    • re-calculate roll-up summary fields on parent object(s) records(s) for record(s) in question

    Code Block
    var request = {
        "type" : "create",
        "object" : "Account",
        "data" : { "Name" : "John Doe Industries", "Phone" : "867-5309" },
    	"args" : { 
    		"allowEditOnFailure" : "FALSE", // OPTIONAL : DEFAULT IS "TRUE"-- Allow editing the record using the Pulsar object edit screen to fix errors on a create failure
    		"skipLayoutRequiredFieldCheck" : "FALSE" // <-- OPTIONAL : if specified as "TRUE", will avoid checking for missing layout required fields
    	}};
    bridge.sendRequest(request, function (responseData) { 
    	alert('Javascript got its create response: ' + responseData); 
    });

    Update (single record only)

    Update an existing Salesforce Object. This API will update only one object per request using the field names and values provided in the data portion of the request. The Id field is required to identify the record to update. This is equivalent to saving a record from the Pulsar native user interface. Optionally, specifying the argument skipLayoutRequiredFieldCheck as TRUE will avoid checking for fields marked required on the Salesforce layout for the object.

    Note

    Multiple create, update, or delete requests MUST NOT run concurrently, and should instead be run sequentially. Furthermore, this API will have the following effects (if these features are enabled):

    • run PSL Object Triggers for the record(s) in question

    • process SFDC ValidationRules for the record(s) in question

    • re-calculate and save formula fields for the record(s) in question

    • re-calculate roll-up summary fields on parent object(s) records(s) for record(s) in question

    var request = {
     
     
        "type" : "
    delete
    update",
        "object" : "Account",
        "data" : { "Id" : "001234567891234", 
    } // only Id is required }; bridge.sendRequest(request, function (responseData) { alert('Javascript got its delete response: ' + responseData); });

    Deletes an existing set of Salesforce objects. This API will delete multiple objects per request using the objectIdList paramter to identify the records. This is equivalent to deleting the records sequentially from the Pulsar native user interface.

    Code Block
    languagejs
    Panel
    titleBatch Delete
    Warning

    This API MUST NOT run concurrently with create, update, or delete requests. Furthermore, this API will have the following effects (if these features are enabled):

    • run PSL Object Triggers for the record(s) in question
    • process SFDC ValidationRules for the record(s) in question
    • re-calculate and save formula fields for the record(s) in question
    • re-calculate roll-up summary fields on parent object(s) records(s) for record(s) in question
    Info

    The deletebatch API allows efficiently deleting multiple objects, provided as an array of object Ids. See the example syntax below.

    Code Block
    languagejs
    var request = { 
        "type" : "deletebatch",
        "object" : "Account",
        "data" : { "objectIdList" : [ "001234567891234","001234567891235","001234567891236" ] } // only Ids are required
    };
    bridge.sendRequest(request, function (responseData) { 
        console.log('Javascript got its response: ' + responseData);
     
        if (results.type === "deletebatchResponse") {
            var resultObject = results.data;
            var wasSuccessful = resultObject.summary.success; // overall success encoded here as "TRUE" or "FALSE" 
    		var resultIds = Object.keys(resultObject.results); // results are encoded as a dictionary, keyed by object id
            for (var objId in resultIds) { // results is a dictionary of objects with a success flag, object id, and error message (if unsuccessful)
            	var objectResult = resultObject.results[objId];
    			if (objectResult.success === "FALSE") { // success encoded here as "TRUE" or "FALSE"
    				alert('This object failed to delete: ' +  objectResult.objectId);  
            	}
    		}
            
        } else if (results.type == 'error') {
            errStr = results.data;
            alert('A problem occurred:\n' + errStr);
        } });

    Sample response:

    Paste code macro
    languagejson
    { "type": "deletebatchResponse", "object": "Account", "fieldName": null, "data": { "summary": { "success":
    "Name" : "John Doe Industries, Inc", "Phone" : "(555) 867-5309" },
                  // Id is a required field to identify the record to update
        "args" : {
            "skipLayoutRequiredFieldCheck" : "FALSE" // OPTIONAL : if specified as "TRUE", will avoid checking for missing layout required fields
        }
    };
    bridge.sendRequest(request, function (responseData) {
        alert('Javascript got its update response: ' + responseData);
    });

    Delete (single record only)

    Delete an existing Salesforce Object. This API will delete only one object per request using the Id field to identify the record. This is equivalent to deleting a record from the Pulsar native user interface. 

    Note

    Multiple create, update, or delete requests MUST NOT run concurrently, and should instead be run sequentially. Furthermore, this API will have the following effects (if these features are enabled):

    • run PSL Object Triggers for the record(s) in question

    • process SFDC ValidationRules for the record(s) in question

    • re-calculate and save formula fields for the record(s) in question

    • re-calculate roll-up summary fields on parent object(s) records(s) for record(s) in question

    Code Block
    var request = { 
        "type" : "delete",
        "object" : "Account",
        "data" : { "Id" : "001234567891234" } // only Id is required
    };
    bridge.sendRequest(request, function (responseData) {
        alert('Javascript got its delete response: ' + responseData);
    });

    Batch Delete

    Deletes an existing set of Salesforce objects. This API will delete multiple objects per request using the objectIdList paramter to identify the records. This is equivalent to deleting the records sequentially from the Pulsar native user interface.

    Note

    Multiple create, update, or delete requests MUST NOT run concurrently, and should instead be run sequentially. Furthermore, this API will have the following effects (if these features are enabled):

    • run PSL Object Triggers for the record(s) in question

    • process SFDC ValidationRules for the record(s) in question

    • re-calculate and save formula fields for the record(s) in question

    • re-calculate roll-up summary fields on parent object(s) records(s) for record(s) in question

    Info

    The deletebatch API allows efficiently deleting multiple objects, provided as an array of object Ids. See the example syntax below.

    Code Block
    var request = { 
        "type" : "deletebatch",
        "object" : "Account",
        "data" : { "objectIdList" : [ "001234567891234","001234567891235","001234567891236" ] } // only Ids are required
    };
    bridge.sendRequest(request, function (responseData) {
        console.log('Javascript got its response: ' + responseData);
      
        if (results.type === "deletebatchResponse") {
            var resultObject = results.data;
            var wasSuccessful = resultObject.summary.success; // overall success encoded here as "TRUE" or "FALSE"
            
    },
    var resultIds = Object.keys(resultObject.results); // results are encoded as 
    "results": {
    a dictionary, keyed by object id
            
    "001234567891234": { "objectId": "001234567891234",
    for (var objId in resultIds) { // results is a dictionary of objects with a success flag, object id, and error message (if unsuccessful)
               
    "success": "TRUE",
     var objectResult = resultObject.results[objId];
                
    "error":
    if (objectResult.success === "FALSE") { // success encoded here as "TRUE" or "FALSE"
       
    },
                 
    "001234567891235": {
    alert('This object failed to delete: ' +  objectResult.objectId); 
             
    "objectId":
     
    "001234567891235",
      }
            }
         
    "success":
     
    "FALSE",
       
        } else if (results.type 
    "error": "delete failed - Error occurred during object delete"
    == 'error') {
            errStr = results.data;
            
    },
    alert('A problem occurred:\n' + errStr);
        
    "001234567891236":
    } });

    Sample response:

    Code Block
    {
        "type": "deletebatchResponse",
        "object": "Account",
        "
    objectId
    fieldName": 
    "001234567891236"
    null,
        "data": {
            
    "
    success
    summary": 
    "TRUE",
    {
                "success": "FALSE"
       
    "error
         },
            "results": {
                "001234567891234": {
                
    }
        "objectId": "001234567891234",
        
    }
         
    }
     
    }
    Section
    Anchor
    selectselect
    Panel
    titleLocal SQL Queries
    Panel
    titleSelect (read-only local query)
    Note
    iconfalse

    The select request allows advanced users to create an arbitrary select query using Pulsar's built in database engine. 

    Code Blockvar request = {  "type" : "select",
          "success": "TRUE",
                    "error": ""
        
    "object"
     
    :
     
    "Account",
         
    "data" : { "query" : "Select Id from Account Where Name like '%hello%'" } }; bridge.sendRequest(request, function (responseData) { alert('Javascript got its select response: ' + responseData); }); Anchorupdateupdate Panel
    titleUpdate (local update query)
    Note
    titleNote

    We encourage you to use the standard CRUD update request, (see above).  The updateQuery request allows developers to issue a raw UPDATE to the local database.

    Warning
    titleCaveat Programmer!

    updateQuery is an advanced request for custom/batch updates, and extreme care should be taken with its use

    • Does not perform processing of ValidationRules for the record(s) in question
    • Will not re-calculate and save formula fields for the record(s) in question
    • Will not re-calculate roll-up summary fields on parent object(s) records(s) for record(s) in question
    • It is possible to write values to the Db offline that will not sync cleanly to Salesforce or may damage your Salesforce instance when synced
    • It is possible to write values to the Db that will break functionality across the Pulsar app
    Code Blockvar request = {  "type" : "updateQuery", "object"
     },
                "001234567891235": {
                    "objectId": "001234567891235",
                    "success": "FALSE",
                    "error": "delete failed - Error occurred during object delete"
                },
                "001234567891236": {
                    "objectId": "001234567891236",
                    "success": "TRUE",
                    "error": ""
                }
            }
        }
    }

    Local SQL Queries

    Select (read-only local query)

    Info

    The select request allows advanced users to create an arbitrary select query using Pulsar's built in database engine. 

    Code Block
    var request = { 
        "type" : "select",
        "object" : "Account",
        "data" : { "query" : "Select Id from Account Where Name like '%hello%'" }
    };
    bridge.sendRequest(request, function (responseData) {
        alert('Javascript got its select response: ' + responseData);
    });

    Update (local update query)

    Info

    We encourage you to use the standard CRUD updaterequest, (see above).  The updateQueryrequest allows developers to issue a raw UPDATE to the local database.

    Note

    Caveat Programmer!

    updateQueryis an advanced request for custom/batch updates, and extreme care should be taken with its use

    • Does not perform processing of ValidationRules for the record(s) in question

    • Will not re-calculate and save formula fields for the record(s) in question

    • Will not re-calculate roll-up summary fields on parent object(s) records(s) for record(s) in question

    • It is possible to write values to the Db offline that will not sync cleanly to Salesforce or may damage your Salesforce instance when synced

    • It is possible to write values to the Db that will break functionality across the Pulsar app

    Info

    When Pulsar is in online mode, the updateQuery request will attempt to push the resulting database changes to your Salesforce instance. Responses to the updateQuery request will always reflect the success or failure of the local database query, even if the push to Salesforce has failed. In this situation, errors from Salesforce are reported as part of the success response (see example below), and the results of the query are maintained in the local database as offline changes.

    Code Block
    var request = { 
        "type" : "updateQuery",
        "object" : "Account",
        "data" : { "query" : "UPDATE Account SET ActiveCustomer__c = 'TRUE' WHERE OpportunityCount__c > 0;" }
    };
    bridge.sendRequest(request, function (responseData) { 
    	alert('Javascript got its update query response: ' + responseData); 
    });

    Sample Response (with a reported Salesforce error):

    Code Block
    Response: {
        "type": "updateQueryResponse",
        "object": "Account",
        "data": 
    "
    data
    success",
    
    :
     
    {
       "
    query
    errors"
    : 
    "UPDATE
    [
    
    Account
     
    SET ActiveCustomer__c = 'TRUE' WHERE OpportunityCount__c > 0;" } }; bridge.sendRequest(request, function (responseData) { alert('Javascript got its update query response: ' + responseData); });
           {
                "errorCode": "ENTITY_IS_LOCKED",
                "message": "This record is locked. If you need to edit it, contact your admin."
            }
        ]
    }