# How to process the data in the Livetable Checkbox Column Macro serviceDocument?

**URL:** <https://forum.xwiki.org/t/how-to-process-the-data-in-the-livetable-checkbox-column-macro-servicedocument/4356>\
**Category:** Help / Discuss\
**Tags:** livetable, json, servicedocument\
**Created:** [February 8, 2019, 12:43pm UTC](https://forum.xwiki.org/t/how-to-process-the-data-in-the-livetable-checkbox-column-macro-servicedocument/4356 "2019-02-08T12:43:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rostyslav\_Fitsyk](https://forum.xwiki.org/user_avatar/forum.xwiki.org/rostyslav_fitsyk/32/1427_2.png) [@Rostyslav\_Fitsyk](https://forum.xwiki.org/u/Rostyslav_Fitsyk)\
**Post date:** [February 8, 2019, 12:43pm UTC](https://forum.xwiki.org/t/how-to-process-the-data-in-the-livetable-checkbox-column-macro-servicedocument/4356/1 "2019-02-08T12:43:16Z")

</div>

Hello!

Thanks for all the previous hints and help, unfortunately I can not fly by myself, so I ask again 🙂 :

> **[XWiki](https://extensions.xwiki.org/xwiki/bin/view/Extension/Add%20Checkbox%20Column%20To%20Livetable)**
>
> XWiki for sharing information

How to process the data in the resulting serviceDocument?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Rostyslav\_Fitsyk](https://forum.xwiki.org/user_avatar/forum.xwiki.org/rostyslav_fitsyk/32/1427_2.png) [@Rostyslav\_Fitsyk](https://forum.xwiki.org/u/Rostyslav_Fitsyk)\
**Post date:** [February 11, 2019, 9:31am UTC](https://forum.xwiki.org/t/how-to-process-the-data-in-the-livetable-checkbox-column-macro-servicedocument/4356/2 "2019-02-11T09:31:18Z")

</div>

Hi!

Globally, I want to use _Livetable with checkbox_ as a lookup table for displaying and setting data.

1. How to organize data transfer and processing in the resulting _serviceDocument_?

2. Can I redefine the _serviceDocument_ (another space/name)?

3. How to set checkboxes programmatically?

Does anyone have any working examples or can advise?

Thanks.

---

<div class="post-metadata">

**Author:** ![Rostyslav\_Fitsyk](https://forum.xwiki.org/user_avatar/forum.xwiki.org/rostyslav_fitsyk/32/1427_2.png) [@Rostyslav\_Fitsyk](https://forum.xwiki.org/u/Rostyslav_Fitsyk)\
**Post date:** [February 12, 2019, 9:20am UTC](https://forum.xwiki.org/t/how-to-process-the-data-in-the-livetable-checkbox-column-macro-servicedocument/4356/3 "2019-02-12T09:20:50Z")

</div>

Hi!

Describe my efforts:

1. After selecting several values ​​and pressing the “Send checkbox data” button, I see the following query:

```auto
    var formData = {
      "autputSyntax": "plain",
      "cbData": [
        "Alvaro",
        "Brandon"
      ],
      "xpage": "plain"
    };
    $.post('http://xwiki.censored.com/xwiki/bin/view/Code/ServiceDocument', formData)
      .done (showResult)
      .fail(showError);
    {
      "frameId": 0,
      "initiator": "http://xwiki.censored.com",
      "method": "POST",
      "parentFrameId": -1,
      "requestBody": {
        "formData": {
          "autputSyntax": [
            "plain"
          ],
          "cbData": [
            "Alvaro",
            "Brandon"
          ],
          "xpage": [
            "plain"
          ]
        }
      },
      "requestId": "375832",
      "tabId": 1612,
      "timeStamp": 1549962017587.2048,
      "type": "xmlhttprequest",
      "url": "http://xwiki.censored.com/xwiki/bin/view/Code/ServiceDocument"
    }

```

1. I created a terminated page `http://xwiki.censored.com/xwiki/bin/view/Code/ServiceDocument`
2. Added `JavaScriptExtension` object
3. Entered this code:

```auto
    require(['jquery'], function ($) {
     var Target = $('#checkboxService')
     var Launcher = $('#GetJson')
     var Url = new XWiki.Document('cbResults','DatabaseInventory').getURL('get');
     var UrlParams = { 'xpage': 'plain','outputSyntax': 'plain' };
     Launcher.click(function(){
      $.get( Url, UrlParams, function( data ) {
        $( Target )
          .append( "Вибрано: " + data.cbData );
       }, "json" );
     });
    });

```

![image](https://discourse.xwiki.org/uploads/default/original/2X/1/1bcf36ce2e4d92d14883e71565a83e25c1ec3818.png)

What else needs to be done, for example, to display the list of selected values ​​on the resulting page?

Thanks.

---

<div class="post-metadata">

**Author:** ![Rostyslav\_Fitsyk](https://forum.xwiki.org/user_avatar/forum.xwiki.org/rostyslav_fitsyk/32/1427_2.png) [@Rostyslav\_Fitsyk](https://forum.xwiki.org/u/Rostyslav_Fitsyk)\
**Post date:** [February 15, 2019, 10:17am UTC](https://forum.xwiki.org/t/how-to-process-the-data-in-the-livetable-checkbox-column-macro-servicedocument/4356/4 "2019-02-15T10:17:30Z")

</div>

Hi!

At the moment I have been able to transfer data to `ServiceDocument` and get `Response`:

ServiceDocument code:

```
{{velocity wiki="false"}}

#set ($responseMessage = 'Slepping...')

## If AJAX call
#if("$!request.autputSyntax" != '')
  $response.setContentType('application/json')
  set ($responseMessage = 'Request detected')
#end

$responseMessage

{{/velocity}}

```

Response:

![image](https://discourse.xwiki.org/uploads/default/original/2X/f/faa770caee78eb812e4d7d637b2a922ca09889ed.png)

But I still do not know how to process the data in the section`Form Data`:  
 ![image](https://discourse.xwiki.org/uploads/default/original/2X/6/63932455c29ad1e7cc36564b5a2c86bca759dee1.png)

Any ideas?

Thanks…

---

<div class="post-metadata">

**Author:** ![Rostyslav\_Fitsyk](https://forum.xwiki.org/user_avatar/forum.xwiki.org/rostyslav_fitsyk/32/1427_2.png) [@Rostyslav\_Fitsyk](https://forum.xwiki.org/u/Rostyslav_Fitsyk)\
**Post date:** [February 20, 2019, 11:54am UTC](https://forum.xwiki.org/t/how-to-process-the-data-in-the-livetable-checkbox-column-macro-servicedocument/4356/5 "2019-02-20T11:54:33Z")

</div>

Solved:

```
.......................................
{{addCheckboxColumnToLivetable livetable="hdwLookUpSoftware" column="softID" buttonId="sftCheckboxService" serviceDocument=$doc /}}
.......................................
#if("$!request.autputSyntax" != '')

    #set ($paramlist = '[')
    #foreach ($param in $request.getParameterValues("cbData"))
      #set ($paramlist = $paramlist + $param + ', ')
    #end
    #set ($paramlist = $paramlist + ']')
    #set ($paramlist = $paramlist.replace(', ]', ']'))
  
    $doc.set('hdwSoftware2', $paramlist)
    $doc.save()

  #end

```

Сode is ugly, but it works 🙂
