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

Hello there.
I want to display a unique key documents.
How can I do that?

I have a document.

Code
//////////////
dizi = New Array;
   
   Query = New Query;
   
   Query.Text = 
      "SELECT
      |   Test.Alan1,
      |   Test.Alan2,
      |   Test.Alan3
      |FROM
      |   Document.Test AS Test";
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();
   
   While SelectionDetailRecords.Next() Do
      yapi = New Structure;
      yapi.Insert("RecordId",<<<<<UNIQUE ID>>>>>)
      yapi.Insert("Alan1",SelectionDetailrecords[0]);
      yapi.Insert("Alan2",SelectionDetailrecords[1]);
      yapi.Insert("Alan3",SelectionDetailrecords[2]);         
      dizi.Add(yapi);

 
#2
People who like this: 0 Yes / 0 No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Erdogan!

You can use the UUID() method of the Ref field. In your example, you need to add Test.Ref field to the query text and then you can use this script:

Code
   Query.Text = 
      "SELECT
      |   Test.Ref,
      |   Test.Alan1,
      |   Test.Alan2,
      |   Test.Alan3
      |FROM
      |   Document.Test AS Test";
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();
   
   While SelectionDetailRecords.Next() Do
      yapi = New Structure;
      yapi.Insert("RecordId", SelectionDetailRecords.Ref.UUID());

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

Error ..

{HTTPService.Test.Module(44)}: An error occurred in the process of content method call  (WriteJSON)


Code
Function TestTest(Request)
   Response = New HTTPServiceResponse(200);
    Result = "";
           
   
   dizi = New Array;
   
   Query = New Query;
   
   Query.Text = 
      "SELECT
      |   Test.Ref,
      |   Test.Alan1,
      |   Test.Alan2,
      |   Test.Alan3
      |FROM
      |   Document.Test AS Test";
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();
   
   While SelectionDetailRecords.Next() Do
      yapi = New Structure;
      yapi.Insert("RecordId", SelectionDetailRecords.Ref.UUID());
      yapi.Insert("Alan1",SelectionDetailrecords[1]);
      yapi.Insert("Alan2",SelectionDetailrecords[2]);
      yapi.Insert("Alan3",SelectionDetailrecords[3]);         
      dizi.Add(yapi);
   EndDo;   
  
    JSONWriter = New JSONWriter;
    JSONWriterSettings =JSONWriter = New JSONWriter;
   JSONWriter.SetString();

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

EndFunction

 
#4
People who like this: 0 Yes / 0 No
Interested
Rating: 27
Joined: Apr 5, 2012
Company: 1TÇ Şirketi - Merv Bilgi İşlem Otomasyonu Yazılım Ltd. Şti.

Hi Erdogan Uguz,
UUID() function returns you "UUID" type. json converter does not support uuid type, that for you get an error.
json converter support only "String, Number, Boolean, Date (converted to a string)" types. You need to convert received UUID to string.

Code
UUID_as_string = ""+SelectionDetailRecords.Ref.UUID();

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

Thank you Murat :)

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