Clarity

 View Only
  • 1.  How to create a boolean filter in a custom portlet

    Posted Feb 18, 2016 12:13 PM

    I am working on creating a custom portlet to display high level information about programs and I can't seem to get a boolean filter to work. I am returning an "is_active" flag as a number so that I can display it as an icon in my grid. When I put the "is_active" flag in the filter and make it a dropdown, it appears as I would expect (a dropdown with the options for "All", "Yes", and "No") but when I try to filter on any option other than "All" my grid doesn't display any data.

     

    I have tried returning a yes or no and then casting that as a boolean but when I do that I was unable to display that as an icon in my grid. I've looked at the way the Active filter is set up on the projects list page and it appears to be a number return type cast as a boolean so I have tried that and it doesn't work for me either.

     

    Does anyone have any ideas about how I might be able to fix this?



  • 2.  Re: How to create a boolean filter in a custom portlet
    Best Answer

    Posted Feb 18, 2016 12:30 PM

    Had various issues with "flags" ; not sure that the exact scenario you describe would be a symptom of any of the following, but worth checking...

     

    NSQL based portlets ; under SQL-Server (not Oracle) I find I have to convert BOOLEAN attributes in the SQL with code like "CASE WHEN isnull(my_flag) = 0 THEN 0 ELSE 1 END my_flag" in order for them to work. (so not cast-ing really, convert-ing).

     

    Under both SQL and ORACLE, I'll nvl / isnull all boolean flags in the returned SQL ; since I'm just not convinced Clarity handles the flag being NULL correctly. - actually this might be your scenario?



  • 3.  Re: How to create a boolean filter in a custom portlet

    Posted Feb 18, 2016 12:39 PM

    Could you include the column in your query results twice, one as integer with an alias indicating it's for the image indicator, and another as a boolean indicating it is for the filtering?



  • 4.  Re: How to create a boolean filter in a custom portlet

    Posted Feb 18, 2016 02:57 PM

    What I normally do is add something like

    AND

    (@WHERE:PARAM:USER_DEF:INTEGER:z_act@ = inv.is_active OR @WHERE:PARAM:USER_DEF:INTEGER:z_act@ is null)

    to the filter section of the query and then assocate the param_z_act with the Yes No All lookup which is of type

     

    <staticLookup autoSuggestEnabled="true" autoSuggestMaxSuggestions="10" code="Z_YES_NO_ALL" hiddenAttributeName="lookup_enum" sortStyle="alphanumeric" source="niku.com" status="active" update="true"><nls description="" languageCode="en" name="Yes No All"/>

     

     

    <lookupValue code="0" enum="0" sortOrder="0" status="active"><nls description="" languageCode="en" name="No"/>

     

     

    <lookupValue code="1" enum="1" sortOrder="0" status="active"><nls description="" languageCode="en" name="Yes"/>