I have created a generic function which returns a list with only selected properties as shown:
var getList = function (listTitle, properties) {
var deferred = $.Deferred();
var clientContext = new SP.ClientContext.get_current();
var list = clientContext.get_web().get_lists().getByTitle(listTitle);
// This works properly
//clientContext.load(list, 'DefaultEditFormUrl', 'DefaultNewFormUrl', 'Id');
clientContext.load(list, properties);
clientContext.executeQueryAsync(
Function.createDelegate(this,
function () { deferred.resolve(list); }),
Function.createDelegate(this,
function (sender, args) { deferred.reject(sender, args); }));
return deferred.promise();
};
The issue is how to call this function properly. The below call only loads 'DefaultEditFormUrl'
.
var ListTitle = 'myListTitle';
getList(ListTitle, 'DefaultEditFormUrl', 'DefaultNewFormUrl', 'Id')
And the below call gives error:
The query expression is not supported
var ListTitle = 'myListTitle';
getList(ListTitle, 'DefaultEditFormUrl\', \'DefaultNewFormUrl\', \'Id')
0 commentaires:
Enregistrer un commentaire