This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Problems when running query on the client

paulo - Friday, January 28, 2011 7:25 AM:

Hi my  friends,

I've debugged and the syntax is correct.

when returnCabecalho.getItemCount run () shows the result equal to 0 (zero) even knowing that there are related items to the objects involved. And when I run the AML below in Nash.aspx page the result is shown normally.

<AML>
<Item type="Grafico Espinha de Peixe" action="get" select="id">
  <Relationships>
    <Item type="Grafico Espinha Cabecalho" action="get" select="related_id">
      <related_id>
        <Item type="Grafico Cabecalho" action="get" select="nome,id">
          <Relationships>
            <Item type="CabecalhoCategoria" action="get" select="related_id">
              <related_id >
                <Item type="Grafico Categoria" action="get" select="nome"/>
              </related_id>
            </Item>
          </Relationships>
        </Item>
      </related_id>
    </Item>
  </Relationships>
</Item>
</AML>


 I will try to explain more fully below.

I have an itemType 'Grafico Espinha de Peixe' related itemType 'Grafico Cabecalho' and this related 'Grafico Categoria'.

When I run the itemType document.thisItem is brought 'Grafico Espinha de Peixe'.
The itemType 'Grafico Espinha dePeixe' contains two itemType 'Grafico Cabecalho'  and each 'Grafico Cabecalho'  contains two itemType 'Grafico Categoria'.
see the script below:

var itemGrafico = document.thisItem;

//var returnCabecalho = itemGrafico.getItemsByXpath("Item/Relationships/Item/related_id/Item[@type='Grafico Cabecalho']");

var returnCabecalho = itemGrafico.getRelationships("Grafico Espinha Cabecalho");
var texto = "<table border=1><tr>";

for (var i=0;i < returnCabecalho.getItemCount(); i++) {
   var company = returnCabecalho.getItemByIndex(i);
   texto+= "<td>"+company.getProperty("nome")+"</td>";
}

texto+= "<td></td></tr><tr>";
for (var j = 0; j < returnCabecalho.getItemCount(); j++) {
   var company2 = returnCabecalho.getItemByIndex(j);

var resp = company2.getRelationships("CabecalhoCategoria");

   texto+= "<td><table>";
   for (var c = 0; c < resp.getItemCount(); c++) {
       var cat = resp.getItemByIndex(c);
       var aki = cat.getItemByIndex(0);
      texto+= "<tr><td>"+aki.getRelatedItem().getProperty("nome")+" </td></tr>";
   }
   texto+= "</table></td>"; //
}

texto+= "</tr><tr><td colspan='"+returnCabecalho.getItemCount()+"'>&nbsp;</td><td>"+itemGrafico.getProperty("nome")+"</td></tr></table>";

document.getElementById('idGrafic').innerHTML = texto;


When I make queries in Nash.aspx although bring result, the script does not
is bringing any results, as this is the same itemType

Thank for Help me



RobMcAveney - Friday, January 28, 2011 10:55 AM:

My guess is that itemGrafico does not have the relationships pre-populated (it is simply the parent item with no relationships).  getRelationships does not make a request to the server to load the relationships -- try using fetchRelationships instead.



paulo - Monday, January 31, 2011 11:06 AM:

Hi friend,
I could write like this:

resp = company.fetchRelationships("CabecalhoCategoria").getRelationships("CabecalhoCategoria");

Thanks for the great help.