Results 1 to 1 of 1

Thread: Code example request : ZmBatchCommand

Threaded View

  1. #1
    Join Date
    Jul 2012
    Rep Power

    Default [solved] Code example request : ZmBatchCommand


    I would be grateful to anyone who posts an example usage of a very simple code (a hello world code) showing how to use the ZmBatchCommand javascript function in a zimlet to send SOAP requests to zimbra.

    EDIT :

    sorry for bothering again, I'v found one in Zimbra's own source code. Here's how it works (for people like me who were looking for an example)

    ZmContactListController.prototype._doMove = function(items, folder, attrs, isShiftKey) {
        if (moveFromGal.length) {
    	var batchCmd = new ZmBatchCommand(true, null, true);
    	for (var j = 0; j < moveFromGal.length; j++) {
    	    var contact = moveFromGal[j];
    	    contact.attr[ZmContact.F_folderId] =;
    	    batchCmd.add(new AjxCallback(contact, contact.create, [contact.attr]));
    	} AjxCallback(this, this._handleMoveFromGal));
    ZmContact.prototype.create = function(attr, batchCmd) {
        var jsonObj = {CreateContactRequest:{_jsns:"urn:zimbraMail"}};
        var respCallback = new AjxCallback(this, this._handleResponseCreate, [attr, batchCmd != null]);
        if (batchCmd) {
    	batchCmd.addRequestParams(jsonObj, respCallback);
        } else {
    	appCtxt.getAppController().sendRequest({jsonObj:jsonObj, asyncMode:true, callback:respCallback});

    So basically :

    1/ Create a ZmBatchCommand
    1.1/ add your functions/methods via batch.add(callback). You have to wrap them in an AjxCallback first, before adding them.
    2/ In the individual functions/methods, add a new batch argument. Your functions will be called by the ZmBatchCommand and given that as last argument
    3/ In the individual functions/methods, if you're in batch mode (confirmed by a non-null batch parameter), add your json or xml request along with the response callback as shown above with batchCmd.addRequestParams.
    4/ When you're ready, run the batchrequest and optionnaly specify a response handler.
    Last edited by ychaouche; 10-23-2012 at 04:03 AM.

Similar Threads

  1. Where can I get source code?
    By shobha in forum General Questions
    Replies: 0
    Last Post: 07-31-2012, 04:56 AM
  2. Help me about Zimbra IM code !!! Plz
    By hadongtung in forum Developers
    Replies: 0
    Last Post: 10-03-2010, 06:39 PM
  3. ZCS version for code available in SVN?
    By CJ7 in forum Developers
    Replies: 4
    Last Post: 12-11-2009, 10:14 AM
  4. source code
    By adonis1976 in forum Developers
    Replies: 1
    Last Post: 11-06-2009, 06:00 PM
  5. What is Error Code: 7
    By jroberts235 in forum Installation
    Replies: 5
    Last Post: 03-31-2008, 09:04 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts