1

I have one data webscript at alfresco side which return json response.

i want this json response in share webscript to display that json data on share.

following is the my code written in getLocation.get.js file @ share.

      var result1 = new Array();
      var connector = remote.connect("alfresco");
      var data = connector.get("/com/portfolio/ds/getlocation");

        // create json object from data
      if(data.status == 200){
      var result = jsonUtils.toJSONString(eval(data.response));
        model.docprop = result ;
         }else{
         model.docprop = "Failed";
        }

Following is the output from alfresco side

     { 
        "subgroups": [
        {
        "name": "grp_pf_india_user" ,
            "label": "INDIA"
         }, 
    {
      "name": "grp_pf_israil_user" ,
      "label": "ISRAIL"
     }, 
    {
      "name": "grp_pf_usa_user" ,
      "label": "USA"
      } 
     ]
     }
1
  • Are you getting any error and what exactly you're looking here? Commented Feb 3, 2016 at 7:30

1 Answer 1

1

use this code to call repo webscripts from share side by using the concept or RMI. (Alfresco.constants.PROXY_URI) = (http://host:port/share/proxy/alfresco/)

var xurl=Alfresco.constants.PROXY_URI+"HR-webscripts/createHRDocument/"+JSON.stringify(o);
    //alert(xurl);
    var request = $.ajax({
        url: xurl ,
        type: "POST",
        //data: { "groupname" : o},
        beforeSend : function(xhr){
            /*
            Alfresco.util.Ajax & alfresco/core/CoreXhr – will automatically take the token from the cookie and add it as a request header for every request.
            Alfresco.forms.Form – will automatically take the token from the cookie and add it as a url parameter to when submitting an multipart/form-data request.
            (When submitting a form as JSON the Alfresco.util.Ajax will be used internally) 
            */                  
            if (Alfresco.util.CSRFPolicy && Alfresco.util.CSRFPolicy.isFilterEnabled()){    
                xhr.setRequestHeader(Alfresco.util.CSRFPolicy.getHeader(), Alfresco.util.CSRFPolicy.getToken() );
            }
        },
        dataType: "html"
    });

    request.done(function(msg) {
       //alert( "Request OK: " + msg );
      $("#res").html( msg );
    });

    request.fail(function(jqXHR, textStatus) {
      alert( "Request failed: " + textStatus );
    });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.