Results 1 to 4 of 4

Thread: Create contact group via zimlet - HELP!

  1. #1
    tjpatter is offline Junior Member
    Join Date
    Dec 2007
    Posts
    9
    Rep Power
    7

    Exclamation Create contact group via zimlet - HELP!

    I am trying to create a contact group through a zimlet... If you take a look at my code below, you can see what I'm trying to accomplish. Below my code snippet you will find a the xml packet that is getting transmitted to the server (obtained using firebug and breakpoints).

    Any advise would be GREATLY appreciated!!!

    -------- ZIMLET CODE --------------

    // Add a new group contact object...

    // set up a BatchRequest for all contacts that need to be added... (Even though in this case it is only 1)

    var soapDoc = null;
    soapDoc = AjxSoapDoc.create("BatchRequest", "urn:zimbra");
    soapDoc.setMethodAttribute("onerror", "continue");

    var createContactReq = soapDoc.set("CreateContactRequest");
    createContactReq.setAttribute("xmlns", "urn:zimbraMail");
    var doc = soapDoc.getDoc();
    var cn = doc.createElement("cn");
    createContactReq.appendChild(cn);

    // add nickname
    var fn = doc.createElement("a");
    fn.setAttribute("n", 'nickname');
    fn.appendChild(doc.createTextNode(document.getElem entById('svsuNewGroup').value));
    cn.appendChild(fn);

    // add type
    var ln = doc.createElement("a");
    ln.setAttribute("n", 'type');
    ln.appendChild(doc.createTextNode('group'));
    cn.appendChild(ln);

    // add dlist
    var dl = doc.createElement("a");
    dl.setAttribute("n", 'dlist');
    dl.appendChild(doc.createTextNode('teststu@svsu.ed u'));
    cn.appendChild(dl);

    if (soapDoc) {
    // finally, send the BatchRequest to the server
    var respCallback = new AjxCallback(this, this._handleResponseCreate);
    appCtxt.getAppController().sendRequest({soapDoc:so apDoc, asyncMode:true, callback:respCallback});
    } else {
    this._questionDialog.popdown();
    }


    -------- XML Call ---------

    <BatchRequest xmlns="urn:zimbra" onerror="continue"><CreateContactRequest xmlns=""><cn><a n="nickname">def</a><a n="type">group</a><a n="dlist">tjpatter@svsu.edu</a></cn></CreateContactRequest></BatchRequest>

  2. #2
    tdesorbaix is offline Zimlet Guru & Moderator
    Join Date
    Apr 2007
    Location
    Paris, France
    Posts
    367
    Rep Power
    8

    Default

    Hi,

    Here is some example code that work .
    It create a contact group "test" with "john doe" and "xxx" :
    Code:
    	var soapDoc = AjxSoapDoc.create("CreateContactRequest", "urn:zimbraMail");
    	var cn = soapDoc.set("cn");
    
    	var fileAs = soapDoc.set("a", "8:test", cn);
    	fileAs.setAttribute("n", "fileAs");
    
    	var nickname = soapDoc.set("a", "test", cn);
    	nickname.setAttribute("n", "nickname");
    
    	var dlist = soapDoc.set("a", "\"john doe\" <foo@bar.com>, \"xxx\" <xxx@xxx.com>", cn);
    	dlist.setAttribute("n", "dlist");
    	
    	var type = soapDoc.set("a", "group", cn);
    	type.setAttribute("n", "type");
    
    	var command = new ZmCsfeCommand();
    	var response = command.invoke({soapDoc: soapDoc});

  3. #3
    tjpatter is offline Junior Member
    Join Date
    Dec 2007
    Posts
    9
    Rep Power
    7

    Default Thanks!

    That code block worked great! I kind of figured it had something to do with how I was building the XML SoapDoc.

    One additional question arises now... Is there a way to automatically refresh the contacts list without having a user to log off then log back on to see any new contact groups once the above code has executed?

    Thanks again for all of your help! I will see if I can get permission to post our finished zimlet once complete.

  4. #4
    tdesorbaix is offline Zimlet Guru & Moderator
    Join Date
    Apr 2007
    Location
    Paris, France
    Posts
    367
    Rep Power
    8

    Default

    You shouldn't need to refresh anything.
    When I tested the code block, the group added was visible immediately in the "Contacts" folder.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 03-05-2010, 01:13 AM
  2. Replies: 21
    Last Post: 02-04-2010, 10:06 AM
  3. Compartmentalized groups or locations sharing a domain
    By dstoliker in forum Administrators
    Replies: 5
    Last Post: 07-14-2008, 12:06 PM
  4. Post instsallation problems
    By Assaf in forum Installation
    Replies: 14
    Last Post: 01-29-2007, 11:38 AM

Posting Permissions

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