Results 1 to 2 of 2

Thread: create Appt

  1. #1
    REMI is offline Member
    Join Date
    Apr 2011
    Posts
    10
    Rep Power
    4

    Default create Appt

    Hello, I want create new appointement in calendar.I have see a function createappt in evite zimlet. But I want add participant's and choose calendar(I think change this.eviteFolderID)... How can I process?

    Evite | Zimbra :: Gallery

    Code:
    /**
     * Creates soap request to create an appointment in Evite-calendar folder
     *
     * @param {string} title  		the appointment subject
     * @param {string} url			the Evite url
     * @param {date} date 			the date of the appointment
     * @param {string} time			the time of the appointment
     */
    EviteZimlet.prototype._createAppt =
    function(title, url, date, time) {
    	if (!this.userID || !this.eviteFolderID) {
    		appCtxt.getAppController().setStatusMsg(this.getMessage("EviteZimlet_NotInitialized"), ZmStatusView.LEVEL_CRITICAL);
    		return;
    	}
    	var soapDoc = AjxSoapDoc.create("CreateAppointmentRequest", "urn:zimbraMail");
    	var m = soapDoc.set("m");
    	m.setAttribute("l", this.eviteFolderID);
    	var node = soapDoc.set("inv", null, m);
    	node.setAttribute("method", "REQUEST");
    	node.setAttribute("type", "event");
    	node.setAttribute("fb", "B");
    	node.setAttribute("transp", "O");
    	node.setAttribute("status", "CONF");
    	node.setAttribute("allDay", "1");
    	node.setAttribute("name", title);
    	node.setAttribute("loc", "");
    
    	var subnode = soapDoc.set("s", null, node);
    	subnode.setAttribute("d", date);
    	subnode = soapDoc.set("e", null, node);
    	subnode.setAttribute("d", date);
    	subnode = soapDoc.set("or", null, node);
    	subnode.setAttribute("a", this._getUsername());
    
    	node = soapDoc.set("mp", null, m);
    	node.setAttribute("ct", "text/plain");
    	subnode = soapDoc.set("content", url, node);
    
    	node = soapDoc.set("su", title, m);
    
    	var command = new ZmCsfeCommand();
    	var resp = command.invoke({soapDoc: soapDoc});
    };
    Regards... Rémi

  2. #2
    ychaouche is offline Senior Member
    Join Date
    Jul 2012
    Location
    Algiers
    Posts
    55
    Rep Power
    2

    Default

    Hi,

    You can set attendees by adding an at(tendee) element to your /m/inv/comp element (so it should be /m/inv/comp/at). See documentation of the SOAP API here for what attributes and content to set inside this element : Zimbra SOAP API Reference 8.0.0_GA_5424

    Also, if you want to change the folder, you have to change the "l" attribute of your message (m).

    Hope that helps. The API documentation may seem a little hieroglyphic/cryptic, but if you look at it 3 or more times you get accustomed to its layout. Not all elements and attributes are necessary of course.

    What I did is take a look at the SOAP message create by Zimbra itself when I manually added an appointement, the XML looked like this :

    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    	<soap:Header>
    		<context xmlns="urn:zimbra">
    			<userAgent xmlns="" name="ZimbraWebClient - FF3.0 (Win)" version="7.2.1 GA"/>
    			<session xmlns="" id="16"/>
    			<account xmlns="" by="name">ychaouche@feeder.fr</account>
    			<format xmlns="" type="js"/>
    		</context>
    	</soap:Header>
    	<soap:Body>
    		<CreateAppointmentRequest xmlns="urn:zimbraMail">
    			<m xmlns="" l="57f6a117-cf46-41d8-8956-a38d06c8cd1e:10">
    				<inv>
    					<comp status="CONF" fb="B" class="PUB" transp="O" draft="0" allDay="0" name="test" loc="">
    						<s tz="Europe/Berlin" d="20121016T083000"/>
    						<e tz="Europe/Berlin" d="20121016T090000"/>
    						<or a="ychaouche@feeder.fr" d="Yassine Chaouche"/>
    						<alarm action="DISPLAY">
    							<trigger>
    								<rel m="5" related="START" neg="1"/>
    							</trigger>
    						</alarm>
    					</comp>
    				</inv>
    				<e a="ychaouche@feeder.fr" t="f"/>
    				<su>test</su>
    				<mp ct="multipart/alternative">
    					<mp ct="text/plain">
    						<content></content>
    					</mp>
    					<mp ct="text/html">
    						<content>&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;</content>
    					</mp>
    				</mp>
    			</m>
    		</CreateAppointmentRequest>
    	</soap:Body>
    </soap:Envelope>
    I took the elements that mattered to me and put them inside my javascript code (also, you can construct your SOAP request out of pure javascript, no XML, see below) :

    Code:
    AppointmentZimlet.prototype.az_create_appointment = function(){
    // <CreateAppointmentRequest xmlns="urn:zimbraMail">
    // 	<m xmlns="" l="57f6a117-cf46-41d8-8956-a38d06c8cd1e:10">
    // 		<inv>...</inv>
    // 		<e a="ychaouche@feeder.fr" t="f"/>
    // 		<su>test</su>
    // 		<mp ct="multipart/alternative">...</mp>		
    // 	</m>
    // </CreateAppointmentRequest>
    
        var component  = {
    	status : "CONF",
    	fb     : "B",
    	class  : "PUB",
    	allDay : 0,
    	name   : "Test",
    	loc    : "Somewhere, beyond the sea",
    	s      : {d:"20121016T083000"},
    	e      : {d:"20121016T090000"},
    	or     : {a:"ychaouche@feeder.fr", d:"yassine chaouche mon pote"}
        };
        var invitation = {comp : component};
        var message    = {inv:invitation,e:"ychaouche@feeder.fr",su:"LE SUJET DU JOUR EST : LA CREVETTE AUX CHAMPIGNONS NOIRS"};
        jsonObj = {
    	CreateAppointmentRequest : {
    	    _jsns:"urn:zimbraMail",
    	    m:message
    	}
        };
    
        return appCtxt.getAppController().sendRequest({jsonObj:jsonObj, asyncMode:true, callback:new AjxCallback(this,this.az_create_appointment_cb)});
    
    };
    To my big surprise, this code worked the very first time. It happens very, very rarely to me.
    Last edited by ychaouche; 10-14-2012 at 07:08 AM. Reason: worked first time

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. 5.01 GA Create certificate ?
    By woeper in forum Installation
    Replies: 1
    Last Post: 01-25-2008, 12:05 AM
  2. Various errors during install and initial startup
    By theschles in forum Installation Help
    Replies: 2
    Last Post: 11-21-2007, 02:51 PM
  3. unable to create inexistent folder
    By dhain in forum Developers
    Replies: 2
    Last Post: 07-16-2007, 11:27 AM
  4. Fedora 5: Could not create the Java virtual machine
    By mi2enno in forum Installation
    Replies: 6
    Last Post: 06-01-2007, 03:16 AM
  5. Opensource backup Question.
    By nfear24 in forum Administrators
    Replies: 3
    Last Post: 03-31-2007, 11:47 PM

Posting Permissions

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