Forum Discussion

kgroneman's avatar
7 years ago

Call to display ideas with a certain status

The issue:  On our idea exchanges, we're using the default "Recently Completed Ideas" widget, but we don't want to show ALL ideas marked completed.   We only want to display ideas that have the "Delivered" status (which is only one of the statuses with the completed component). 

What I need:  We only want to display ideas that have the "Delivered" status (which is only one of the statuses with the completed component) with the name "Recently Delivered Ideas".    I'm looking for an API call to pull a single idea status into a custom component to display on the idea exchange to replace the default "Recently Completed Ideas" component.   I've seen discussions here on how to pull status counts using the API, but not how to pull and actually display an idea like the default widget

Default currently used and why it doesn't work for us: The default widget shows all ideas that have the COMPLETED status.   We have "completed" applied to various statuses:  Delivered, Declined, Already Offered, and Archived.   We need those set to COMPLETED so no more votes can happen. (Yes, I know you can set that on individual ideas, but we have too many to do that manually) but we don't want them all to show in the widget.

I'm not a developer, but I need to have the right api calls before I go to our developer.   Is this possible using either v1 or v2?

Thanks in advance for any help. 

  • Hi kgroneman

    Correct me if I am wrong. After reading over your post a few times, I think you are asking that you want an API v1 or v2 query that can pull ideas that have statuses that may or may not be completed but have a different status key. 

    From that assumption you would be looking for something like the API v2 call below:

     

    SELECT * FROM messages WHERE conversation.style IN('idea') AND depth=0 AND status.key='accepted'

    The conversation style can be written like above or conversation.style='idea'.

    depth=0 means that only the idea (topic) itself is checked against the criteria.

    status.key='accepted' can be customised to the specific status key that you want to get. In your case, you would want to use something like the following:

    • status.key='delivered'
    • status.key='declined'
    • status.key='arichived'
    • status.key='agent'

    Unfortunately, you are unable to get multiple status keys at once. You can, however, may multiple calls using something like below:

     

    <#assign statuses = ['status1', 'status2', 'status3', 'status4', 'statusN'] >
    <#assign apiResults = [] >
    <#list statuses as status >
          <#assign apiQuery = "SELECT * FROM messages WHERE conversation.style='idea' AND depth=0 AND status.key='" + status + "'" >
          <#assign apiResults += rest('2.0','/search?q=' + (apiQuery)?url ) >
    </#list>

     

    Then if you would like to get the results with status.completed=true add the following code:

    <#assign filteredResults = [] >
    <#list apiResults as idea >
          <#if idea.status.completed >
                <#-- if status.completed == true -->
                <#assign filteredResults += idea >
          </#if>
    </#list>

     

    Relevant Links:
    API V2 - messages

  • Hi kgroneman

    Correct me if I am wrong. After reading over your post a few times, I think you are asking that you want an API v1 or v2 query that can pull ideas that have statuses that may or may not be completed but have a different status key. 

    From that assumption you would be looking for something like the API v2 call below:

     

    SELECT * FROM messages WHERE conversation.style IN('idea') AND depth=0 AND status.key='accepted'

    The conversation style can be written like above or conversation.style='idea'.

    depth=0 means that only the idea (topic) itself is checked against the criteria.

    status.key='accepted' can be customised to the specific status key that you want to get. In your case, you would want to use something like the following:

    • status.key='delivered'
    • status.key='declined'
    • status.key='arichived'
    • status.key='agent'

    Unfortunately, you are unable to get multiple status keys at once. You can, however, may multiple calls using something like below:

     

    <#assign statuses = ['status1', 'status2', 'status3', 'status4', 'statusN'] >
    <#assign apiResults = [] >
    <#list statuses as status >
          <#assign apiQuery = "SELECT * FROM messages WHERE conversation.style='idea' AND depth=0 AND status.key='" + status + "'" >
          <#assign apiResults += rest('2.0','/search?q=' + (apiQuery)?url ) >
    </#list>

     

    Then if you would like to get the results with status.completed=true add the following code:

    <#assign filteredResults = [] >
    <#list apiResults as idea >
          <#if idea.status.completed >
                <#-- if status.completed == true -->
                <#assign filteredResults += idea >
          </#if>
    </#list>

     

    Relevant Links:
    API V2 - messages

    • luk's avatar
      luk
      Boss

      And to complete your developer's work, you could then use the @override directive for default components, e.g. <default.component.id>@override, then put some adaption of Jake_N 's code in there that outputs the required HTML.

      • Thanks Jake_N and luk.   I'll take that to my developer and hopefully that will give him what he needs.  MUCH appreciated. - Kim