Forum Discussion

arnantoakbar's avatar
arnantoakbar
Contributor
9 years ago

How to get latest Idea based on Status using LIQL?

Hi Guys,

 

I want to create some widget that retrieve list of latest Ideas based on their statuses using LIQL.

So I start with this query to begin:

 

SELECT subject, view_href, status.name FROM messages WHERE board.id='Idea-Center' and depth=0 ORDER BY post_time DESC LIMIT 2

 

and here's what I get:

 

{
  "status" : "success",
  "message" : "",
  "http_code" : 200,
  "data" : {
    "type" : "messages",
    "list_item_type" : "message",
    "size" : 2,
    "items" : [ {
      "type" : "message",
      "view_href" : "/t5/Idea-Center/uat-test/idi-p/2077",
      "subject" : "[uat] test",
      "status" : {
        "type" : "message_status",
        "name" : "Untuk Masa Depan"
      }
    }, {
      "type" : "message",
      "view_href" : "/t5/Idea-Center/uat-test/idi-p/2073",
      "subject" : "[uat] test",
      "status" : {
        "type" : "message_status",
        "name" : "Baru"
      }
    } ]
  },
  "metadata" : { }
}

 

Then, I want to shortlist the result based on the status.name = 'Baru'. So, here's my updated LIQL:

 

SELECT subject, view_href, status.name FROM messages WHERE board.id='Idea-Center' and depth=0 and status.name='Baru' ORDER BY post_time DESC LIMIT 2

 

But, I get an error like this:

 

{
  "status" : "error",
  "message" : "invalid query syntax for SELECT subject,view_href,status.name FROM messages WHERE board.id = 'Idea-Center' AND depth = 0 AND status.name = 'Baru' ORDER BY post_time DESC",
  "data" : {
    "type" : "error_data",
    "code" : 604,
    "developer_message" : "'status.name' is not a valid constraint for the object 'messages'. in: SELECT subject,view_href,status.name FROM messages WHERE board.id = 'Idea-Center' AND depth = 0 AND status.name = 'Baru' ORDER BY post_time DESC",
    "more_info" : ""
  },
  "metadata" : { }
}

 

As you can see in http://community.lithium.com/t5/Community-API-v2/Message-resource/ta-p/113091 article, the status.name is part of messages. So, why can't I use it like board.id?

 

Thanks Guys,

arnantoakbar

  • arnantoakbar yes, status.name is part of messages, but you can't use it as a constraint (e.g. in a WHERE clause). The only workaround I can think is to loop through your result and do what you have to do when status.name = 'Baru'

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)

    arnantoakbar yes, status.name is part of messages, but you can't use it as a constraint (e.g. in a WHERE clause). The only workaround I can think is to loop through your result and do what you have to do when status.name = 'Baru'