Search in Sharepoint list with SPservices Javascript

0

Good afternoon, guys!

I'm using the SPservices library to work with information from a company's Sharepoint application. I need to create graphs based on the information in a given list.

The list has several records of problem problems detected in a particular process. The list has a column with the problem date.

I need to create graphs that return the number of occurrences in the year, month, and day (current month).

What is the best way for me to perform this search? The annual search I did this way:

 chartQtdAnual: function (divShowChart) {

    var xml          = objetcXml;
    var total        = 0;

    var data_inicio  = util.dataUs('01/01/' + ano);
    var data_fim     = util.dataUs('31/12/' + ano);

    var consultaInicio  = "<Query><OrderBy><FieldRef Name='DataOcorrencia' Ascending='FALSE'/></OrderBy><Where>";
    var consultaAnd     = '';
    var consultaFiltros = "<Geq><FieldRef Name='ID' /><Value Type='Number'>0</Value></Geq>";
    var consultaFim     = "</Where></Query>";

    if (area != 'Motores' && area != "") {
        consultaAnd += "<And>";
        consultaFiltros +=
                    "<Eq><FieldRef Name='AreaIdentificacao' /><Value Type='Text'>" + area + "</Value> </Eq>" +
                "</And>";
    }

    if (data_inicio != '--' && data_inicio != '') {
        consultaAnd += "<And>";
        consultaFiltros +=
                    "<Geq><FieldRef Name='DataOcorrencia' /><Value Type='DateTime'>" + data_inicio + "</Value></Geq>" +
                "</And>";
    }

    if (data_fim != '--' && data_fim != '') {
        consultaAnd += "<And>";
        consultaFiltros +=
                    "<Leq><FieldRef Name='DataOcorrencia' /><Value Type='DateTime'>" + data_fim + "</Value></Leq>" +
                "</And>";
    }

    var consulta = consultaInicio + consultaAnd + consultaFiltros + consultaFim;
    xml          = crud.read(listItemSolicitacao, consulta, '');
    total        = util.countSPServices(xml); 

},  

Is it the best way? How to retrieve information for monthly and daily charts?

    
asked by anonymous 21.02.2017 / 16:24

1 answer

0

Hello, I did not have time to look at Query, but ti can use SPServices, Create Web Part, Etc. And for charts I've already used Google Chart and it's pretty cool.

Good luck.

    
27.03.2017 / 18:45