Forum Discussion

Akenefick's avatar
Akenefick
Genius
3 years ago

Can You Get Author Roles From A Messages Subquery

Hello

I'm building my own top solution author component and would like to exclude anyone with the employee role. I'm using the following JSON with a subquery.

[
  {
    "messages":{
      "fields":[
        "author.view_href",
        "author.avatar",
        "author.login",
        "author.solutions_authored.count(*)",
        "author.kudos_received.sum(weight)",
        "author.messages.count(*)",
        "author.roles"
      ],
      "constraints":[
        {
          "board.id":"PTCMathcad",
          "is_solution":true
        }
      ],
      "limit": 50,
      "subQueries":{
        "roles":{
          "fields":[
            "name"
          ],
          "limit":50
        }
      }
    }
  }
]

 

I get the following error:

"developer_message": "no field definition found for the field 'roles' (in the object 'message'"
 
I've also tried replacing roles with author.roles in the subquery but get the same error. Is this possible without making a separate API call for each author?
 
Thanks
  • JavidH's avatar
    JavidH
    Khoros Staff

    Currently, you cannot fetch the author.roles from messages sub-query and you need to make a separate call to get the role details.

    • Akenefick's avatar
      Akenefick
      Genius

      Ok thanks for the confirmation. I found another way to go about excluding employees. We have employee versions of all our ranks that require the employee role. I can get author.rank from the messages query and compare that to a list of those rank ids.