@@ -53,10 +53,12 @@ Create a job
5353 contentType : 'CSV'
5454 };
5555
56- client.createJob(job, function(response) {
56+ client.createJob(job)
57+ .then(function(response) {
5758 jobId = response.jobInfo.id;
5859 console.log('Job created with id '+jobId+'\n');
59- }, function(jqXHR, textStatus, errorThrown) {
60+ })
61+ .catch(function(jqXHR, textStatus, errorThrown) {
6062 console.log('Error creating job', jqXHR.responseText);
6163 });
6264
@@ -69,10 +71,11 @@ You can add multiple batches to the job; each batch can contain up to 10,000 rec
6971 "Tom,Jones,Marketing,1940-06-07Z,"Self-described as ""the top"" branding guru on the West Coast\n"+
7072 "Ian,Dury,R&D,,"World-renowned expert in fuzzy logic design. Influential in technology purchases."\n";
7173
72- client.addBatch(jobId, "text/csv; charset=UTF-8", csvData,
73- function(response){
74+ client.addBatch(jobId, "text/csv; charset=UTF-8", csvData)
75+ .then( function(response){
7476 console.log('Added batch '+response.batchInfo.id+'. State: '+response.batchInfo.state+'\n');
75- }, function(jqXHR, textStatus, errorThrown) {
77+ })
78+ .catch(function(jqXHR, textStatus, errorThrown) {
7679 console.log('Error adding batch', jqXHR.responseText);
7780 });
7881
@@ -83,18 +86,22 @@ Close the job
8386
8487You must close the job to inform Salesforce that no more batches will be submitted for the job.
8588
86- client.closeJob(jobId, function(response){
89+ client.closeJob(jobId)
90+ .then(function(response){
8791 console.log('Job closed. State: '+response.jobInfo.state+'\n');
88- }, function(jqXHR, textStatus, errorThrown) {
92+ })
93+ .catch(function(jqXHR, textStatus, errorThrown) {
8994 console.log('Error closing job', jqXHR.responseText);
9095 });
9196
9297Check batch status
9398------------------
9499
95- client.getBatchDetails(jobId, batchId, function(response){
100+ client.getBatchDetails(jobId, batchId)
101+ .then(function(response){
96102 console.log('Batch state: '+response.batchInfo.state+'\n');
97- }, function(jqXHR, textStatus, errorThrown) {
103+ })
104+ .catch(function(jqXHR, textStatus, errorThrown) {
98105 console.log('Error getting batch details', jqXHR.responseText);
99106 });
100107
@@ -103,9 +110,10 @@ Get batch results
103110
104111Pass ` true ` as the ` parseXML ` parameter to get batch results for a query, false otherwise.
105112
106- client.getBatchResult(jobId, batchId, false, function(response){
113+ client.getBatchResult(jobId, batchId, false)
114+ .then(function(response){
107115 console.log('Batch result: '+response);
108- }, function(jqXHR, textStatus, errorThrown) {
116+ }).then( function(jqXHR, textStatus, errorThrown) {
109117 console.log('Error getting batch result', jqXHR.responseText);
110118 });
111119
@@ -116,22 +124,28 @@ When adding a batch to a bulk query job, the `contentType` for the request must
116124
117125 var soql = 'SELECT Id, FirstName, LastName, Email FROM Contact';
118126
119- client.addBatch(jobId, 'text/csv', soql, function(response){
127+ client.addBatch(jobId, 'text/csv', soql)
128+ .then(function(response){
120129 console.log('Batch state: '+response.batchInfo.state+'\n');
121- }, function(jqXHR, textStatus, errorThrown) {
130+ })
131+ .catch(function(jqXHR, textStatus, errorThrown) {
122132 console.log('Error getting batch result', jqXHR.responseText);
123133 });
124134
125135Getting bulk query results is a two step process. Call ` getBatchResult() ` with ` parseXML ` set to ` true ` to get a set of result IDs, then call ` getBulkQueryResult() ` to get the actual records for each result
126136
127- client.getBatchResult(jobId, batchId, true, function(response){
137+ client.getBatchResult(jobId, batchId, true)
138+ .then(function(response){
128139 response['result-list'].result.forEach(function(resultId){
129- client.getBulkQueryResult(jobId, batchId, resultId, function(response){
140+ client.getBulkQueryResult(jobId, batchId, resultId)
141+ .then(function(response){
130142 console.log('Batch result: '+response);
131- }, function(jqXHR, textStatus, errorThrown) {
143+ })
144+ .catch(function(jqXHR, textStatus, errorThrown) {
132145 console.log('Error getting bulk query results', jqXHR.responseText);
133146 });
134147 });
135- }, function(jqXHR, textStatus, errorThrown) {
148+ })
149+ .catch(function(jqXHR, textStatus, errorThrown) {
136150 console.log('Error getting batch result', jqXHR.responseText);
137151 });
0 commit comments