AnsweredAssumed Answered

query webscript from share dashlet

Question asked by kay_be_ on Mar 21, 2012
Latest reply on Mar 22, 2012 by kay_be_
I need some clarification on how to get a second result from a webscript when the dashlet is already created. Let me explain. I created a webschript in alfresco that queries the companies of the users. Then I made a dashlet that lists these companies. Each company is a link, when the user clicks on a company, a list appears of the members with their emailadresses.
How can I make that second call to a different webscript and return the data in the dashlet?
I tried to solve it with javascript using this dashlet template:
<script type="text/javascript">//<![CDATA[
   new Alfresco.widget.DashletResizer("${args.htmlid}", "${instance.object.id}");
   function getjson(e){
      var name = e.id;
      var scriptURL = "/RedTree/emaillist?company=" + name + "&format=json";
      alert(scriptURL);
      var connector = remote.connect("alfresco");
      alert ("connector ok");
      var json = connector.call(scriptURL);
      if (json.status == 200) {
         var obj = eval('(' + json + ')');
         alert('done');
      }else {
      alert('failed');
      }
      
   }

//]]></script>
<div class="dashlet">
   <div class="title">${msg("header")}</div>
   <p style="color:green;font-size:10px;font-weight:bold;">Click a company to view the memberlist with contact details.</p>
   <div class="body scrollableList" <#if args.height??>style="height: ${args.height}px;"</#if>>
     <div class="detail-list-item first-item last-item">
      <#list result.companylist as company>
         <a id="${company.companyname}" href = "#" onclick="getjson(this);">${company.companyname}</a>
      </#list>
     </div>
   </div>
</div>

But this doesn't work out well. I even don't know if this is the way to go.
I don't get to the check that alerts that connector is made.
The alfresco script /RedTree/emaillist?company=" + name + "&format=json works fine and results in json data.
Where did I went wrong?

Outcomes