AnsweredAssumed Answered

Passing a result from a post webscript to a get webscript

Question asked by itzamna on Mar 10, 2014
Latest reply on May 23, 2014 by mrogers
Hi all,

I'm facing the following challange: I've a GET web-script that returns a  set of documents from a Javabacked script in Share. The documents will be displayed in a table to the user. Now, the user is able to select from a dropdown a number of documents that should be displayed (pre-defined as: 50, 100, 250) and also to select a filter of available document types.
I'm able to post the submitted values of the webform (myshare.get.html.ftl) via a POST ( to Alfresco (see below), query the database based on the specified arguments and return a JSON with the results. So the "result" below contains a long JSON with all search results that was requested by the user:

Snippet of my
function execute(jsonString)
   logger.log("JSONString that will be send to Alfresco: " + jsonUtils.toJSONString(jsonString));
   var connector = remote.connect("alfresco");   
   var result ="/com/company/feature/share?type=" + jsonUtils.toJSONString(jsonString), "application/json");
        var resultObject = jsonUtils.toObject(result.response);
        //resultObject["searchResults"]; ==> contains the evaluated result with all documents of the users request
   if (result.status == 200)
             var res_status = resultObject["status"];
             if (res_status == "OK")
                status.setCode(302); //303,307,308
                status.setLocation(url.context + "/page/console/myfeature/myshare");


My problem currently: After re-directing back to my GET webscript (setLocation(…)) the initial Javabacked script will be invoked again and return the default results. So, the user can select anything he wants but he'll getting always the default search result of the GET webscript… How I'm able to "overwrite" these values (in this case a map)? I've checked the but there are only some examples (like the blog search) that set always only one parameter with one value. I've a large map as JSON that must be given back to the GET webscript.
What is the best way to pass such a result from a POST webscript to a GET webscript?
Just passing it as a parameter like

status.setLocation(url.context + "/page/console/myfeature/myshare?result=" +jsonUtils.toObject(resultObject["searchResults"]));

is not a good idea I assume because the result can be some Miles long…

Thanks for any hint.