Zimlets in zimbra, how to make a simple SearchRequest?

544 views Asked by At

I'm a little desperate because I can not perform a simple search on my zimlet.

I just want to make a search in the custom folder.

The search should only display messages that are within my custom folder.

Like when I click on the custom folder in the left pane. exactly the same.

this is what shows the html header by pressing the icon of my custom folder in the left pane.

{"Header":{"context":{"_jsns":"urn:zimbra","userAgent":{"name":"ZimbraWebClient - FF39 (Linux)","version":"8.6.0_GA_1153"},"session":{"_content":150,"id":150},"account":{"_content":"[email protected]","by":"name"},"csrfToken":"0_a3050edfdf238eadfdfdfdff2f14b4968e3"}},"Body":{"SearchRequest":{"_jsns":"urn:zimbraMail","sortBy":"dateDesc","header":[{"n":"List-ID"},{"n":"X-Zimbra-DL"},{"n":"IN-REPLY-TO"}],"tz":{"id":"America/Mexico_City"},"locale":{"_content":"es_MX"},"offset":0,"limit":100,"query":"in:\\"mycustomfolder\\"","types":"conversation","recip":"0","fullConversation":1,"needExp":1}}}

I'm trying with this code, within my com_zimbra_myzimlet.js

com_zimbra_myzimlet_HandlerObject.prototype._getShowResultFolderId = 
    function(t) {
    var e=AjxSoapDoc.create("SearchRequest","urn:zimbraMail");
    var cuery="raulicci";
    e.setMethodAttribute("types","conversation");
    e.setMethodAttribute("limit",100);
    e.setMethodAttribute("offset",0);
    e.set("query",cuery);
    t.response=appCtxt.getAppController().sendRequest({
        soapDoc:e,noBusyOverlay:false}
    );
    this.handleSearchResponse(t)
};

so far I can not find a way to make the consultation, although I imagine it is something easy as already implemented in zimbra comes when one gives click on the icon in my custom folder in the left pane.

1

There are 1 answers

0
laur On BEST ANSWER

I would like to use the default template that has zimbra to show INBOX, or the current folders.

When you click on the icon of the current folder in the left pane, us a list of emails appears as INBOX

I'm doing with my little zimlet one query with soap and json and I answered a JSON string.

This string json is a mailing list that are in the folder where you perform the query.

For request use:

var jsonObj = {SearchRequest:{_jsns:"urn:zimbraMail"}};
var request = jsonObj.SearchRequest;
request.sortBy = "dateDesc";
request.offset = 0;
request.limit = 100;
request.query = 'in:\"MYCURRENTFOLDER\"';
request.types = "conversation";
request.recips = "0";
request.fullConversation = 1;
request.needExp = 1;

var params = {
        jsonObj:jsonObj,
        asyncMode:true,
        callback: (new AjxCallback(this, this._handleSOAPResponseJSON)),
        errorCallback: (new AjxCallback(this, this._handleSOAPErrorResponseJSON)),
};
return appCtxt.getAppController().sendRequest(params);

For response use:

if (result.isException()) {
    // do something with exception
    var exception = result.getException();      

    return;
}
else {
    response = { _jsns: "urn:zimbraMail", more: false };
}
// do something with response (in JSON format)
var response = result.getResponse();
var name = response.name;
var soapURL = response.publicURL;
var soapURL = response.soapURL;
var aller = result.getResponse();
var searchResult = new ZmSearchResult(this);

appCtxt.setStatusMsg("Response (JSON) success - "+name);
alert(aller.toSource());

JSON response to be displayed in the default template of INBOX integrated zimbra

({SearchResponse:{sortBy:"dateDesc", offset:0, c:[{id:"314", u:0, n:2, f:"s", d:1438663876000, su:"lokitox", fr:"lex", e:[{a:"[email protected]", d:"admin", t:"f"}], m:[{id:"313", l:"300"}, {id:"312", l:"5", f:"s"}], sf:"1438663876000"}, {id:"-309", u:0, n:1, d:1438662639000, su:"Daily mail report for 2015-08-03", fr:"Grand Totals -- messages 91 received 117 delivered 0 forwarded 134 deferred (134 deferrals) 169 bounced 0 rejected (0%) 0 reject warnings 0 held 0 ...", e:[{a:"[email protected]", d:"admin", t:"f"}], m:[{id:"309", s:"7232", l:"300"}], sf:"1438662639000"}], more:false, _jsns:"urn:zimbraMail"}})

Thankz, I hope someone has knowledge of how to do it