# LiveTable query parameters

**URL:** <https://forum.xwiki.org/t/livetable-query-parameters/6063>\
**Category:** Help / Discuss\
**Created:** [January 6, 2020, 4:32pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063 "2020-01-06T16:32:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JurjenRoels](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jurjenroels/32/2126_2.png) [@JurjenRoels](https://forum.xwiki.org/u/JurjenRoels)\
**Post date:** [January 6, 2020, 4:32pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/1 "2020-01-06T16:32:57Z")

</div>

Hello,

I have two Classes.

ClassOne with data and ClassTwo with data. ClassTwo has a multiple select database list consisting of ClassOne ID’s.

Our Classes have generated ID’s that correspond with their page ID’s. (idString)

So ClassTwo.usesClassOneRecords can contain ID1, ID2, ID4

I want to populate a livetable of ClassOne where ID in ClassTwo.usesClassOneRecords. (ID1,ID2,ID4)  
I got $searchVar filled with the right ID’s and want to pass them to the livetable.

I used “extraParams” : “&idString=$searchVar” and “extraParams” : “&idString in $searchVar”

But both do not work. Is there a way to get this working as if it was a select \* from ClassOne where idString IN ($searchvar)

Thanks in advance  
Jurjen

---

<div class="post-metadata">

**Author:** ![Oana-Lavinia\_Florean](https://forum.xwiki.org/user_avatar/forum.xwiki.org/oana-lavinia_florean/32/1187_2.png) [@Oana-Lavinia\_Florean](https://forum.xwiki.org/u/Oana-Lavinia_Florean)\
**Post date:** [January 7, 2020, 7:37am UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/2 "2020-01-07T07:37:24Z")

</div>

Hi Jurjen,

I think this answer [Merging 2 or more classes into 1 livetable - #2 by Oana-Lavinia\_Florean](https://forum.xwiki.org/t/merging-2-or-more-classes-into-1-livetable/5561/2) should be helpful in your case as well (i.e. using that page to apply your filter).

Thanks,  
Lavinia

---

<div class="post-metadata">

**Author:** ![JurjenRoels](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jurjenroels/32/2126_2.png) [@JurjenRoels](https://forum.xwiki.org/u/JurjenRoels)\
**Post date:** [January 10, 2020, 10:58am UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/3 "2020-01-10T10:58:27Z")

</div>

Thank you Oana,

I have made an JSON but I have no results yet.

I have two questions.

1. I have a variable I want to pass to the query in the JSON, how do you do this?
2. How do I see if the livetable actually gets the JSON. If I test the JSON with the variable set in the velocity code, I get a JSON file. But I do not get the results in the livetable

Thanks  
Jurjen

---

<div class="post-metadata">

**Author:** ![Oana-Lavinia\_Florean](https://forum.xwiki.org/user_avatar/forum.xwiki.org/oana-lavinia_florean/32/1187_2.png) [@Oana-Lavinia\_Florean](https://forum.xwiki.org/u/Oana-Lavinia_Florean)\
**Post date:** [January 10, 2020, 2:01pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/4 "2020-01-10T14:01:06Z")

</div>

> 1. I have a variable I want to pass to the query in the JSON, how do you do this?

You can use bindValue like in this example [https://extensions.xwiki.org/xwiki/bin/view/Extension/Query%20Module#HFindingpagesundernestedpages](https://extensions.xwiki.org/xwiki/bin/view/Extension/Query%20Module#HFindingpagesundernestedpages)

> 1. How do I see if the livetable actually gets the JSON. If I test the JSON with the variable set in the velocity code, I get a JSON file. But I do not get the results in the livetable

You can follow it using Network tab by selecting the request to you page that contains the JSON. There you will see what exactly is the result. Also, if there are other results beside the json (if you put something for debug purposes), the livetable will just be empty.

Hope it’s helpful,  
Lavinia

---

<div class="post-metadata">

**Author:** ![JurjenRoels](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jurjenroels/32/2126_2.png) [@JurjenRoels](https://forum.xwiki.org/u/JurjenRoels)\
**Post date:** [January 20, 2020, 10:02am UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/5 "2020-01-20T10:02:06Z")

</div>

Hi Oana,

Thank you. It helped.

I used the example code, modified it a bit, to get the right data.

What I see is a request with a /bin/get/JSON. It gives an empty page. The same request with /bin/view/JSON gives the JSON (with the XWIKI format of pages).

Any ideas where I should search to fix that.

---

<div class="post-metadata">

**Author:** ![Oana-Lavinia\_Florean](https://forum.xwiki.org/user_avatar/forum.xwiki.org/oana-lavinia_florean/32/1187_2.png) [@Oana-Lavinia\_Florean](https://forum.xwiki.org/u/Oana-Lavinia_Florean)\
**Post date:** [January 20, 2020, 12:26pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/6 "2020-01-20T12:26:34Z")

</div>

Hi,

Maybe your page is actually called “JSON.WebHome” and you didn’t added it correctly in the resultPage attribute? In view mode is not necessarily to add it to the url.  
Also, you could check to output the json only on a get request `#if ($xcontext.action == 'get') .. #end` .

---

<div class="post-metadata">

**Author:** ![JurjenRoels](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jurjenroels/32/2126_2.png) [@JurjenRoels](https://forum.xwiki.org/u/JurjenRoels)\
**Post date:** [January 21, 2020, 10:41am UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/7 "2020-01-21T10:41:35Z")

</div>

Hi Oana,

I think I am very close, but I don’t get it. I have two questions

1. Why do I not get a valid JSON response?

2. How do I pass a custom variable to the call of the JSON. I have a variable I bind in the query. But how do I get it in the request string?

3. The page is RapJSON in GeneriekeKlassen. If I call it with trailing / I get results, but escaped. Without I get a blank page.

[http://dev.wiki:8080/bin/get/GeneriekeKlassen/RapJSON/?reqNo=1](http://dev.wiki:8080/bin/get/GeneriekeKlassen/RapJSON/?reqNo=1)

Gives the following result:

`<p>&#123;"totalrows":2,"matchingtags":&#123;},"tags":[],"returnedrows":2,"offset":1,"reqNo":1,"rows":[&#123;"doc_viewable":true,"afkorting":"Test","naam":"Test","korteOmschrijving":"Test","PrivacyGevoelig":""},&#123;"doc_viewable":true,"afkorting":"Test2","naam":"Test2","korteOmschrijving":"Test2","PrivacyGevoelig":""}]}</p>`

dev.wiki:8080/bin/get/GeneriekeKlassen/RapJSON?reqNo=1

Gives a blank page.

The URL calling the livetable which I see in the Network Tab of the browser =

[http://dev.wiki:8080/bin/get/GeneriekeKlassen/RapJSON?outputSyntax=plain&transprefix=GeneriekeKlassen.DatasetClass\_LT\_&classname=GeneriekeKlassen.DatasetClass&collist=afkorting%2Cnaam%2CkorteOmschrijving%2CPrivacyGevoelig%2CidentificatieString&queryFilters=currentlanguage%2Chidden&offset=1&limit=15&reqNo=1&sort=afkorting&dir=asc](http://dev.wiki:8080/bin/get/GeneriekeKlassen/RapJSON?outputSyntax=plain&transprefix=GeneriekeKlassen.DatasetClass_LT_&classname=GeneriekeKlassen.DatasetClass&collist=afkorting%2Cnaam%2CkorteOmschrijving%2CPrivacyGevoelig%2CidentificatieString&queryFilters=currentlanguage%2Chidden&offset=1&limit=15&reqNo=1&sort=afkorting&dir=asc)

So the request is without the /

If I put a custom variable in the options. This is not passed to the JSON.

---

<div class="post-metadata">

**Author:** ![Oana-Lavinia\_Florean](https://forum.xwiki.org/user_avatar/forum.xwiki.org/oana-lavinia_florean/32/1187_2.png) [@Oana-Lavinia\_Florean](https://forum.xwiki.org/u/Oana-Lavinia_Florean)\
**Post date:** [January 21, 2020, 12:39pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/8 "2020-01-21T12:39:12Z")

</div>

Hi Jurjen,

The problem that you have with ‘/’ I suspect is, as I wrote in the previous message, because your page is actually called GeneriekeKlassen.RapJSON.WebHome. Update this in your resultPage and see if you get the results in the Network tab.

> [@JurjenRoels](#):
>
> How do I pass a custom variable to the call of the JSON. I have a variable I bind in the query. But how do I get it in the request string?

You cannot pass custom variables through options, only the already refined ones. For this scenario you should use the url option that is defined here [https://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable%20Macro#HParameter24options](https://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable%20Macro#HParameter24options)

A quick example:

```
  #set ($queryString = $escapetool.url({
    'xpage': 'plain',
    'outputSyntax': 'plain',
    'classname': 'GeneriekeKlassen.DatasetClass',
    'collist': 'col1,col2',
    'rowCount': 15,
    'maxPages': 10,
    'selectedColumn': 'col1',
    'extraParam': 'extraValue'
  }))
  #set ($customURL = $xwiki.getURL('GeneriekeKlassen.RapJSON.WebHome', 'get', $queryString))

  #set ($options = {
    'url' : $customURL
  })

```

---

<div class="post-metadata">

**Author:** ![JurjenRoels](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jurjenroels/32/2126_2.png) [@JurjenRoels](https://forum.xwiki.org/u/JurjenRoels)\
**Post date:** [January 21, 2020, 2:04pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/9 "2020-01-21T14:04:30Z")

</div>

Hi Oana,

Somehow I made an error adding the .WebHome in my test.

Everything Works now.

Thank you for your support

---

<div class="post-metadata">

**Author:** ![Oana-Lavinia\_Florean](https://forum.xwiki.org/user_avatar/forum.xwiki.org/oana-lavinia_florean/32/1187_2.png) [@Oana-Lavinia\_Florean](https://forum.xwiki.org/u/Oana-Lavinia_Florean)\
**Post date:** [January 21, 2020, 2:08pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/10 "2020-01-21T14:08:00Z")

</div>

You’re welcome! 🙂

---

<div class="post-metadata">

**Author:** ![JurjenRoels](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jurjenroels/32/2126_2.png) [@JurjenRoels](https://forum.xwiki.org/u/JurjenRoels)\
**Post date:** [January 21, 2020, 3:21pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/11 "2020-01-21T15:21:04Z")

</div>

Oana,

I have added doc\_url, with the correct URL to the livetable. So the link works if I click it.

Is there a simular field you have to add to your JSON to get a correct edit link in \_actions with a custom JSON?

Regards  
Jurjen

---

<div class="post-metadata">

**Author:** ![Oana-Lavinia\_Florean](https://forum.xwiki.org/user_avatar/forum.xwiki.org/oana-lavinia_florean/32/1187_2.png) [@Oana-Lavinia\_Florean](https://forum.xwiki.org/u/Oana-Lavinia_Florean)\
**Post date:** [January 21, 2020, 3:31pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/12 "2020-01-21T15:31:49Z")

</div>

To see if I fully understand. You have used the url option for your custom json page, with an extra doc\_url parameter send and everything looks ok.  
Now you want to add in your columns an \_actions like one, that will link to the edit page of the doc\_url? Or you just want to have the \_actions column using your custom json page?

---

<div class="post-metadata">

**Author:** ![JurjenRoels](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jurjenroels/32/2126_2.png) [@JurjenRoels](https://forum.xwiki.org/u/JurjenRoels)\
**Post date:** [January 21, 2020, 4:04pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/13 "2020-01-21T16:04:45Z")

</div>

I have already found out I have to add

“doc\_url” : $xwiki.getURL("${item}).  
“doc\_edit\_url” : “edit\_link”,  
“doc\_delete\_url” : “delete\_link”,

to the JSON

these URLS are then used in links or in the edit and delete function in the \_actions of the livetable.

Now to only find a string substitute or a getURL varian for the delete and edit URL.

---

<div class="post-metadata">

**Author:** ![JurjenRoels](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jurjenroels/32/2126_2.png) [@JurjenRoels](https://forum.xwiki.org/u/JurjenRoels)\
**Post date:** [January 21, 2020, 4:09pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/14 "2020-01-21T16:09:12Z")

</div>

And this is the solution:

#set($docURL=$xwiki.getURL("${item}"))  
#set($docEditURL=$docURL)  
#set($docEditURL=$stringtool.replace($docEditURL,’/bin/view/’,’/bin/edit/’))  
#set($docDeleteURL=$docURL)  
#set($docDeleteURL=$stringtool.replace($docDeleteURL,’/bin/view/’,’/bin/delete/’))  
#set($discard=$json.rows.add({  
“doc\_viewable” : true,  
“doc\_url” : “$docURL”,  
“doc\_edit\_url” : “$docEditURL”,  
“doc\_delete\_url” :"$docDeleteURL",

---

<div class="post-metadata">

**Author:** ![Oana-Lavinia\_Florean](https://forum.xwiki.org/user_avatar/forum.xwiki.org/oana-lavinia_florean/32/1187_2.png) [@Oana-Lavinia\_Florean](https://forum.xwiki.org/u/Oana-Lavinia_Florean)\
**Post date:** [January 23, 2020, 11:18am UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/15 "2020-01-23T11:18:57Z")

</div>

Hi Jurjen,

Cleaner than using the replace:

> #set (#docEditURL = $xwiki.getURL($docReference, ‘edit’))  
> #set (#docDeleteURL = $xwiki.getURL($docReference, ‘delete’))

> **[XWiki Scripting API Reference (XWiki.org)](https://www.xwiki.org/xwiki/bin/view/ScriptingDocumentation/?url=http:%2F%2Fnexus.xwiki.org%2Fnexus%2Fservice%2Flocal%2Frepositories%2Fpublic%2Farchive%2Forg%2Fxwiki%2Fplatform%2Fxwiki-platform-oldcore%2F8.4.4%2Fxwiki-platform-oldcore-8.4.4-javadoc.jar%2F%21%2Fcom%2Fxpn%2Fxwiki%2Fapi%2FXWiki.html%23getURL-org.xwiki.model.reference.DocumentReference-java.lang.String-java.lang.String-)**
>
> Enterprise wiki for sharing knowledge

---

<div class="post-metadata">

**Author:** ![JurjenRoels](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jurjenroels/32/2126_2.png) [@JurjenRoels](https://forum.xwiki.org/u/JurjenRoels)\
**Post date:** [February 17, 2020, 1:35pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/16 "2020-02-17T13:35:59Z")

</div>

I have a field with HTML formatted content. Which I want to display as HTML in the livetable.

I retrieve it like this:

> #set($docitem=$xwiki.getDocument($item))  
> #set($objitem=$docitem.getObject(“Space.SomeClass”))  
> #set($docProp=$objitem.getProperty(“property”).value)

The output is not HTML in the JSON.

Any suggestions?

Thanks

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [February 17, 2020, 1:51pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/17 "2020-02-17T13:51:08Z")

</div>

> [@JurjenRoels](#):
>
> The output is not HTML in the JSON.

If you want to display a property in HTML you need to use the `display()` API on a Document object.

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [February 17, 2020, 1:52pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/18 "2020-02-17T13:52:12Z")

</div>

> [@JurjenRoels](#):
>
> Which I want to display as HTML in the livetable.

If you want the LT to display a column as HTML you need to tell the LT that the content is HTML. See [https://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro#HParameter24columnsProperties](https://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro#HParameter24columnsProperties)

---

<div class="post-metadata">

**Author:** ![JurjenRoels](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jurjenroels/32/2126_2.png) [@JurjenRoels](https://forum.xwiki.org/u/JurjenRoels)\
**Post date:** [February 17, 2020, 2:26pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/19 "2020-02-17T14:26:49Z")

</div>

Could you provide me with an example code on code above?

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [February 17, 2020, 2:29pm UTC](https://forum.xwiki.org/t/livetable-query-parameters/6063/20 "2020-02-17T14:29:12Z")

</div>

Can you paste how you use the livetable macro?

[Next page](https://forum.xwiki.org/t/livetable-query-parameters/6063.md?page=2)
