Telligent 8.5 API to get and search list of the users based on the value given in custom profile field

Hello,

I have custom requirement to return the List of  users,  based on the values we have set for custom profile field we have created and later need to filter the user based on different values has been set in that custom profile field.

$core_v2_searchResult.List() ; this return users as well but will unnecessary search site wide data and affect the site performance to process tons of data to get the necessary ones.

$core_v2_user.List ()  returning all user and not having any parameter  to filter users based on profile fields values 

Also is there any reference to write normal Solr query to find users by that value at widget level.

Any help on this area would be really appreciated!

Thanks,

Ravinder

Parents Reply Children
  • Hi Ben,

    Can you please point out whats wrong in this query. as per my expectation  i should get min 4 to 5 users because those all are the one which pass in this search criteria, but I am getting 20 users

    #set($filters='')

    #set($searchedProfileFieldValue = 'Test event')

    ## foreach field, add to $filters:

    #set($filters = "${filters}||${profile_ContestOpt-in}::$core_v2_encoding.UrlEncode($searchedProfileFieldValue)")

    #set ($searchListOptions = "%{ Sort = 'date desc' }")

    $searchListOptions.Add("Filters", "type::user${filters}")

    #set ($searchResults = $core_v2_searchResult.List($searchListOptions))

  • Don't wrap profile_ContestOptin in ${}... that is trying to evaluate the variable $profile_ContestOptin instead of using the literal "profile_ContestOptin".

  • Hi Ben,

    how to write a query to check if field is Not Null

    Following query returning nothing

    #set($userFilter = '')

    #set($filters = "${filters}||profile_ContestOpt-in::$core_v2_encoding.HtmlAttributeEncode(!$userFilter)")

    #set ($searchListOptions = "%{ Sort = 'date desc' }")

    $searchListOptions.Add("Filters", "type::user${filters}")

    #set ($searchResults = $core_v2_searchResult.List($searchListOptions))

    Thanks,

    Ravinder

  • I am still looking for input to write efficient query to meet following scenario 

    1. how to write a query to check if field is Not Null

    #set($userFilter = '')

    #set($filters = "${filters}||profile_ContestOpt-in::$core_v2_encoding.HtmlAttributeEncode(!$userFilter)")

    2. also if search string contains spaces receiving Zero result in response, 

    #set($searchedProfileFieldValue = ' Thanks Giving Conteset')

    #set($filters = "${filters}||profile_ContestOpt-in::$core_v2_encoding.HtmlEncode($searchedProfileFieldValue)")

  • #if ($userFilter)

    #end

    would check for null, in your example you are setting the value to an empty string though.

    You can also be more explicit and #set($userFilter = false), if it is not set again after that it will also fail the #if($userFilter) check.

  • Thanks for the repose Mathew. can you please help me correct this query. I am blocked here

    get the list of the user with specific phrase e. g "Thanks Giving Contest" in ContestOpt-in field 

    #set($searchcase = 'Thanks Giving Contest')

    #set($filters = "${filters}||profile_ContestOpt-in::$searchcase")    I think i need to wrap the string in double quote here 

    #set($searchListOptions = "%{ Sort = 'date desc' }")
    $searchListOptions.Add("Filters", "type::user${filters}")

    #set($searchResults = $core_v2_searchResult.List($searchListOptions))

  • I am still waiting for input to to write a query for phrase search. against following query at exception log i noticed that "" quotes has been  removed . plsease suggest.

    #set($searchcase = "Thanks Giving Contest")

    I tried    "\"Thanks Giving Contest\"" as well but throwing error at exception log

    #set($filters = "${filters}||profile_ContestOpt-in::$searchcase")    I think i need to wrap the string in double quote here 

    #set($searchListOptions = "%{ Sort = 'date desc' }")
    $searchListOptions.Add("Filters", "type::user${filters}")

    #set($searchResults = $core_v2_searchResult.List($searchListOptions))

  • I am still waiting for input to to write a query for phrase search. against following query at exception log i noticed that "" quotes has been  removed . please suggest.

    #set($searchcase = "Thanks Giving Contest")

    I tried    "\"Thanks Giving Contest\"" as well but throwing error at exception log

    #set($filters = "${filters}||profile_ContestOpt-in::$searchcase")    I think i need to wrap the string in double quote here 

    #set($searchListOptions = "%{ Sort = 'date desc' }")
    $searchListOptions.Add("Filters", "type::user${filters}")

    #set($searchResults = $core_v2_searchResult.List($searchListOptions))