Skip to content

Commit a6f3946

Browse files
author
Pat Patterson
committed
Make field list optional for retrieve. Closes developerforce#3
1 parent 1f60e0f commit a6f3946

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

forcetk.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,20 @@ if (forcetk.Client === undefined) {
249249
* Retrieves field values for a record of the given type.
250250
* @param objtype object type; e.g. "Account"
251251
* @param id the record's object ID
252-
* @param fields comma-separated list of fields for which to return
253-
* values; e.g. Name,Industry,TickerSymbol
252+
* @param [fields=null] optional comma-separated list of fields for which
253+
* to return values; e.g. Name,Industry,TickerSymbol
254254
* @param callback function to which response will be passed
255255
* @param [error=null] function to which jqXHR will be passed in case of error
256256
*/
257257
forcetk.Client.prototype.retrieve = function(objtype, id, fieldlist, callback, error) {
258+
if (!arguments[4]) {
259+
error = callback;
260+
callback = fieldlist;
261+
fieldlist = null;
262+
}
263+
var fields = fieldlist ? '?fields=' + fieldlist : '';
258264
this.ajax('/' + this.apiVersion + '/sobjects/' + objtype + '/' + id
259-
+ '?fields=' + fieldlist, callback, error);
265+
+ fields, callback, error);
260266
}
261267

262268
/*

0 commit comments

Comments
 (0)