Page 1 of 1

[SOLVED] Exporting a user's data

Posted: Mon Sep 26, 2016 3:43 pm
by brick__
Hello everyone,

Once again I am seeking for help on these forums, but this time it's more about a specific function than a zimlet altogether.

I want to export a user's data from the console, and, as each and every time I am looking for how stuff is working, I do a little search in the javascript API, take a look at the doc online, and go through the existing zimlets on github. But once again, I couldn't find any clues anywhere.

Reading the API on the ZmImportExportController, I quickly found the method I was looking for: exportData(params). I am now facing the following, pretty straight-forward, 2 lines of code:

Code: Select all

var params = {type: ZmImportExportController.TYPE_CSV, filename: "export.csv"};
appCtxt.getImportExportController().exportData(params);

It feels right if it wasn't for the following error I am getting from the UI:
You need to specify an export folder.


After going through all the documentation again (including source code) and even making some arguments for params up, I couldn't find a single argument that could specify the destination/export folder.

Do you guys have any idea of what I am missing here?

Re: Exporting a user's data

Posted: Thu Oct 06, 2016 9:14 am
by brick__
All right, I figured it out, and it's really my bad. The error message actually misled me, making me think that the argument it was waiting for was a destination folder. Actually, it doesn't, what he needs is the folderId argument which is clearly referenced in the JSAPI...

So the final snippet looks like this:

Code: Select all

appCtxt.getImportExportController().exportData({
   type: ZmImportExportController.TYPE_DEFAULT,
   subType; ZmImportExportController.TYPE_CSV,
   filename: "export",
   folderId: "All"
});

The mistake I also made in my original post was considering ZmImportExportController.TYPE_CSV as a type instead of a subtype.

Hope it helps someone, but I guess I was pretty much the only one not having figured this out :oops: