Angelo Chiello
Angelo Chiello

Reputation: 65

Breeze named saves do not work as expected


I tried to use the named saves as below and as explained in the release notes here, but it dosen't work and returns:

Uncaught Error: The 'entities' parameter is optional or it must be an array where each element must be an entity => breeze.debug.js:724
proto.check => breeze.debug.js:724
proto.saveChanges => breeze.debug.js:11150
sendEmail

The function is:

var sendEmail = function () {
        var option = new breeze.SaveOptions({ resourceName: 'sendMail'})
        return manager.saveChanges({ saveOptions: option })
            .then(saveSucceeded)
            .fail(saveFailed);

        function saveSucceeded(saveResult) {
            log('La email è stata invata.', saveResult, true);
        }

        function saveFailed(error) {
            var msg = 'Invio della email è fallito: ' + getErrorMessages(error);
            logError(msg, error);
            error.message = msg;
            throw error;
        }
    };

Any help appretiated!

Upvotes: 1

Views: 984

Answers (1)

Jay Traband
Jay Traband

Reputation: 17052

The writeup in the release notes has the wrong syntax. I will have it fixed.

The first arg to EntityManager.saveChanges is always a list of entities, or it can be null to indicate all entities. The 2nd arg is an optional SaveOptions instance. See here. So your expression should be

  var option = new breeze.SaveOptions({ resourceName: 'sendMail'})
  return manager.saveChanges(null, option)

Upvotes: 2

Related Questions