The 1C:Enterprise developers forum

#1
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

Hi,

I want to ask a question.

I have one document. Entering into business records.
I want a list of all entries in this document.
I can only see the last record.
What am I doing wrong?

Code
Function TestTest(Request)
   Response = New HTTPServiceResponse(200);   
   Result = "";
   
   Query = New Query;
   Query.Text = 
      "SELECT
      |   UguzIsTakip.Date AS Date,
      |   UguzIsTakip.CariHesap.Kompleİsmi AS CariHesapKompleİsmi,
      |   UguzIsTakip.GorusmeTipi.Description,
      |   UguzIsTakip.GorusmeNedeni.Description,
      |   UguzIsTakip.GorusmeDurumu.Description,
      |   UguzIsTakip.GorusmeDetayi,
      |   UguzIsTakip.GorusmeSonucu
      |FROM
      |   Document.UguzIsTakip AS UguzIsTakip
      |
      |ORDER BY
      |   Date,
      |   CariHesapKompleİsmi";
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();
   
     JSONWriter = New JSONWriter;
      JSONWriterSettings = New JSONWriterSettings(, Chars.Tab);
      JSONWriter.SetString(JSONWriterSettings);
    
       yapi = New Structure;
   While SelectionDetailRecords.Next() Do
      
         yapi.Insert("Tarih",SelectionDetailRecords[0]);
        yapi.Insert("Unvan",SelectionDetailRecords[1]);
        yapi.Insert("GorusmeTipi",SelectionDetailRecords[2]);
        yapi.Insert("GorusmeNedeni",SelectionDetailRecords[3]);
        yapi.Insert("GorusmeDurumu",SelectionDetailRecords[4]);
        yapi.Insert("GorusmeDetayi",SelectionDetailRecords[5]);
        yapi.Insert("GorusmeSonucu",SelectionDetailRecords[6]);

     EndDo;
     WriteJSON(JSONWriter, yapi);
      Result = JSONWriter.Close();
       
                 
    Response = New HTTPServiceResponse(?(True, 200, 404));
   Response.SetBodyFromString(Result, TextEncoding.System);  
         Return Response;
   
EndFunction





Quote
{
"Tarih": "2016-07-01T14:28:15",
"Unvan": "xxxyyyzzz Tic. Ltd. Şti.",
"GorusmeTipi": "Telefon Görüşmesi",
"GorusmeNedeni": "Program Görüşmeleri",
"GorusmeDurumu": "Tamamlandı",
"GorusmeDetayi": "yeni formlar yüklndi ",
"GorusmeSonucu": ""
}

 
#2
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Apr 18, 2012
Company:

Hi, Erdogan Uguz!

You can create array of structures and write it to JSON.

Code
Items = New Array;
While SelectionDetailRecords.Next() Do
   
   yapi = New Structure;
   yapi.Insert("Tarih",SelectionDetailRecords[0]);
   yapi.Insert("Unvan",SelectionDetailRecords[1]);
   yapi.Insert("GorusmeTipi",SelectionDetailRecords[2]);
   yapi.Insert("GorusmeNedeni",SelectionDetailRecords[3]);
   yapi.Insert("GorusmeDurumu",SelectionDetailRecords[4]);
   yapi.Insert("GorusmeDetayi",SelectionDetailRecords[5]);
   yapi.Insert("GorusmeSonucu",SelectionDetailRecords[6]);
   
   Items.Add(yapi);
EndDo;
WriteJSON(JSONWriter, Items);

 
#3
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

Super :)

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)