Querying/filtering a struct

I'm trying to filter a cfoutput query by a string in a struct
in
BlogCFC. Here's a link to the test page:
http://tinyurl.com/35ozjv
This page contains the first query, returning posts from all
categories,
along with dumps of the getCategory and getEntries functions.
The getEntries struct contains a categoryid and categoryname.
I would
like to filter the results by one category, "Articles" to
return the
blog post title and body.
Ray posted this in his forum:
"You pass in a struct of options. So make a struct, add
maxentries=10 to
it, and then pass the struct to getEntries. Then to filter by
category,
get the UUID value first, you can find them by calling
getCategories,
and then pass it in the struct by using the key, byCat. You
can't pass
the category name. You have to get the UUID value and use
that."
The problem is I have no idea how to pass the UUID to the
struct using
the key byCat.
Here's my unworking code:
<!--- Make a struct and add maxentries=10 to it --->
<cfset passthrough = StructNew()>
<cfset passthrough.maxentries=10>
<!--- Pass the struct to getEntries --->
<cfset posts =
application.blog.getEntries(passthrough)>
<!--- Then to filter by category, get the UUID value first
--->
<!--- You can find them by calling getCategories --->
<!--- Articles UUID is:
5D279AED-3048-72D5-0466F6D049A3D4B5 --->
<cfset theCategory = application.blog.getCategories()>
<!--- Then pass it in the struct by using the key, byCat
--->
I'm lost at this point. Any help is greatly appreciated.

cf_dev2 wrote:
>> What am I doing wrong?
>
> <cfquery dbtype="query" name="GetCategory">
> SELECT CategoryName
> FROM categoryInfo
> WHERE CategoryName = 'Articles'
> </cfquery>
>
> 1. Your QoQ needs to select the UUID column not
CategoryName. Besides that
> the QoQ looks good
> 2. You ran the QoQ to get the uuid for "Articles", but
then you didn't do
> anything with the query. You need to add the UUID value
to the structure of
> filters that get passed to getEntries(). So the
getEntries() function knows it
> should only return "Articles".
Perfect. It's much better using the QoQ WHERE instead of hard
coding the
Category ID. Thanks for thinking of that.
I've updated the test page with this new code
http://tinyurl.com/35ozjv
<!---- get all categories --->
<cfset qAllCategories =
application.blog.getCategories()>
<!---- find the UUID for the Articles category --->
<cfquery dbtype="query" name="GetArticlesCategory">
SELECT CategoryID
FROM qAllCategories
WHERE CategoryName = 'Articles'
</cfquery>
<!--- Make a new struct to pass the category and entries
to --->
<cfset filters = StructNew()>
<cfset filters.byCat = GetArticlesCategory.CategoryID>
<cfset filters.maxentries =10>
<cfset posts = application.blog.getEntries(filters)>
<!--- Query the last 10 Articles --->
<cfoutput query="posts">
<h3>
<a href="#application.blog.makeLink(id)#">
#Title#
</a>
</h3>
<p>
#body#
</p>
</cfoutput>

Similar Messages

  • Date object doesn't work in query filters

    I'm trying to create a universe object called Next Biweekly Pay End Date.  Some background: there is an end date for our biweekly payrolls every 14 days, and the logic behind the object is basically that if there was a biweekly pay end date 7 days ago, the next one is 7 days from today (that is, sysdate + 7), etc.</p>
    I have it working so that it displays the correct date when used in a WebI report.  However, when I use it in a query filter in a WebI report (like, Pay End Date = Next Biweekly Pay End Date), I don't get an error, but I also don't get any data.  Somehow my object doesn't work in a query filter.  The purpose of the object is for use in query filters, so I need to get this to work.</p>
    My best guess about why it doesn't work in a query filter is due to some issue with the data type.  Pay End Date has a data type of date in the universe.  I gave Next Biweekly Pay End Date a data type of date also, but the query filter still doesn't work; I get "no data to fetch."</p>
    We're using XI 3.1.6 and Oracle 10.  Any ideas about how to get this to work?</p>
    If it helps, here is the definition of Next Biweekly Pay End Date.  The logic is that it takes today's date, subtracts Oct. 31, 2009 (a biweekly pay end date), divides by 14, and looks at the remainder.  If the remainder is 0, then today is a pay end date and the next one is 14 days from now.  If the remainder is 1, yesterday was a pay end date and the next one is 13 days from now, etc.</p>
    case</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 0 then (sysdate + 14)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 1 then (sysdate + 13)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 2 then (sysdate + 12)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 3 then (sysdate + 11)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 4 then (sysdate + 10)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 5 then (sysdate + 9)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 6 then (sysdate + 8)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 7 then (sysdate + 7)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 8 then (sysdate + 6)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 9 then (sysdate + 5)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 10 then (sysdate + 4)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 11 then (sysdate + 3)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 12 then (sysdate + 2)</p>
      when mod((trunc(sysdate)) - (to_date('31/10/2009')),14) = 13 then (sysdate + 1)</p>
    end

    Thanks for the suggestions.
    I did some more testing, and there seems to be something more complicated going on.  I ran the following code in SQL*Plus:
    SELECT distinct M_PYDW1.PYSTATUS.DW_OWNER,
    case
    when to_date(sysdate, 'dd/mm/yyyy hh24:mi:ss') >= to_date('01/01/2010','dd/mm/yyyy hh24:mi:ss') then To_Date((sysdate - 2),'dd/mm/yyyy')
    else to_date(sysdate +2, 'dd/mm/yyyy')
    end
    FROM M_PYDW1.PYSTATUS
    The condition should be true, because the sysdate (today is Jan. 20) is greater than 1/1/2010, so I should get a result of sysdate - 2 (Jan. 18).  But the result I get is Jan. 22 (sysdate +2).  It seems that the comparison is failing even though I'm formatting both sysdate and 1/1/2010 as dates with a timestamp.  What could cause that?
    One more mystery: when I run the same code as above in a WebI report (using custom SQL), I get the error ORA-1830, date format picture ends before converting entire input string.

  • Displaying Query filters on a report to print

    I would like to display the query filters that I have used in my query filters display on the report, is there any way to do this? Are you able to create a variable and populate it with the query filters?

    yes
    you can use a function called
    UserResponse
    =UserResponse("My Filter Text here")
    or if you have more than one query
    =UserResponse([Query 1];"My Filter Text here")

  • Structure data in the spreadsheet using BEx Query filtered by year

    Hi,
    I´m making a Balanced Scoredcard using Xcelsius and extracting data from SAP BI.   The customer asked to see a few KPI´S (Return on assets and profit margin) filtering data from the dashboard by year,  month and region.
    The problem I´m facing is how to structure the data in the spreadsheet using a query filtered by year variable. 
    Regards,
    Diego

    Hi,
    I´m making a Balanced Scoredcard using Xcelsius and extracting data from SAP BI.   The customer asked to see a few KPI´S (Return on assets and profit margin) filtering data from the dashboard by year,  month and region.
    The problem I´m facing is how to structure the data in the spreadsheet using a query filtered by year variable. 
    Regards,
    Diego

  • WIS 00015 error- Multiple Query Filters contain a prompt with same name

    Hi
            I am working BOXIR2 environment. I created two prompts at Universe level- one of Date field and one on agency name field.
    syntax for the prompts is
    customerInfo.RSRCE_NAME =  @Prompt('Enter value(s) for AgencyName ','A' , , ,)
    datetable.STARDATE =datetable.STARDATE.STARTDATE =  @Prompt(' 'Enter value(s) for StartDate:','D' , , ,)
    When I include even one of  the prompts in the report I am getting an error WIS 00015 Multiple Query Filters contain a prompt with the same text, but the prompts use a different operand type.
    If I try to change text of one of the prompts in Universe selection statement, then I see the prompt two times in the report.
    Please let me know how to overcome this issue.

    Ok, I've simplified the case.
    Here is the real case :
    Object filter =
    Based on object =
    .[LEVEL01]
    Object filter =
    Based on object =
    .[LEVEL01]
    In WBI query result I take these objects :
    .[LEVEL01]
    .[LEVEL01]
    .[4IUX93YJGXQEHGLX0T0GPNA9Y]
    In query filters, my 2 filters with same text :
    1.
    I run the query.
    Answer to question 'Single Year Period ?' = Period 06 2010
    ==> MDX error
    A database error occured. The database error text is: Echec de l'exécution de la requête MDX SELECT  { .[4IUX93YJGXQEHGLX0T0GPNA9Y] }  ON COLUMNS , NON EMPTY CROSSJOIN( .[LEVEL01].MEMBERS, .[LEVEL01].MEMBERS ) DIMENSION PROPERTIES MEMBER_CAPTION ON ROWS FROM SAP VARIABLES INCLUDING .[Z12010006] INCLUDING .[Z12010006] avec l'erreur Invalid MDX command with . (WIS 10901)
    And you can see that the value sent to both filters is the same and come from the first filter .[Z12010006] instead of applying the value to each filter .[Z12010006] for the first one and .[Z12010006] for the second one.
    Please, notice that if I change the order of this 2 filters in the WBI query, the MDX generated become :
    SELECT  { .[4IUX93YJGXQEHGLX0T0GPNA9Y] }  ON COLUMNS , NON EMPTY CROSSJOIN( .[LEVEL01].MEMBERS, .[LEVEL01].MEMBERS ) DIMENSION PROPERTIES MEMBER_CAPTION ON ROWS FROM SAP VARIABLES INCLUDING .[Z12010006] INCLUDING .[Z12010006]
    Thanks for your help.
    G.OM.

  • Query filters in QueryListener

    How to get the query filters in the Query Listener .
    For eg. I have a serach component having name and email id as filters. I want to get these values in my QueryListner.
    Thanks
    Suneesh

    Hi,
    see sample #30 at http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html
    Frank

  • Query Filters not working in webi report.

    Hi all,
    I have a bex query where i have some filters on Key figures but when i run that query on webi report i dont get exact data as in bex...
    There are no other filters i have applied in webi, but i am not able to see the exact data..?
    what may be the issue....

    Thanks for the earliest reply.......
    I am using Business object XI 3.1 SP 1 FP 0.882.
    In webi i can see all the values i.e I have applied filter on key figure TARGET GI QUANITY which brings only that quantity which has missing parts.
    But i get all the quantity in my webi report.
    so what can be the issuse....?

  • Query Filters problem!

    HI,
    I have a query which has the filters
    ex: Project profile filter on ZP025,ZPDS014,ZP016,ZP018,ZP019
    the query is not producing any result.But when i remove the filter for ZP025 and ZPDS014 it is producing result.
    What whould be the reason for this behaviour.Why the query is not producing anz result with particular filters.
    thank you
    venkat

    Venku,
        Looks like your cube only has information for project profiles ZP025 and ZPDS014. Make sure you have data for other profiles too if you are expecting to see some values with the ZP025,ZPDS014,ZP016,ZP018,ZP019 filter.
    Hope this helps...

  • Crystal Reports for Enterprise - cannot change operator in query filters

    Hi,
    I am trying to apply multiple filters in a query for a Crystal Report (for Enterprise), but I can only use the default AND operator, whereas I need the OR operator. Supposedly you can change the operator by double clicking it, but it just didn't work with me.
    Ýour help is highly appreciated,
    Victoria

    Hello Victoria,
    You can try out Toolbar->Data->Formula->Record Filter. Here you can just type in your filter and the operators are available on the left hand side. (If they are not, then check on the top left. You might see a button to switch to "Advanced" formula workshop). On the ledt hand side drill down the operator->Boolean->AND(x and y).
    Hope this helps.
    Regards,
    arjun

  • XML Query filtering by child table column

    Hello,
    If anyone can help with this one... it would be nice. I need to make the output of an query to be in the format of XML, but the problem is that the initial filtering needs to be done in the child table.
    Example:
    CREATE TABLE PRIMARY(
    ID NUMBER(19,0),
    CODE_PRIMARY VARCHAR2(32));
    CREATE TABLE SECONDARY(
    ID NUMBER(19,0),
    IDPRIMARY(19,0),
    CODE_SECONDARY VARCHAR2(32));
    INSERT INTO PRIMARY(ID,CODE_PRIMARY)
    VALUES (1,'A');
    INSERT INTO PRIMARY(ID,CODE_PRIMARY)
    VALUES (2,'B');
    INSERT INTO SECONDARY(ID,IDPRIMARY,CODE_SECONDARY)
    VALUES (1,1,'C');
    INSERT INTO SECONDARY(ID,IDPRIMARY,CODE_SECONDARY)
    VALUES (2,1,'D');
    INSERT INTO SECONDARY(ID,IDPRIMARY,CODE_SECONDARY)
    VALUES (3,2,'E');
    Now what we need is to build an XML tree like the following, INNER JOINING PRIMARY and SECONDARY tables with this condition in the where clause -> WHERE SECONDARY.CODE IN ('C','D')
    <result>
    <record>
    <id>1</id>
    <code>A</code>
    <childs>
    <child>
    <id>1</id>
    <idprimary>1</idprimary>
    <codesecondary>C</codesecondary>
    </child>
    <child>
    <id>2</id>
    <idprimary>1</idprimary>
    <codesecondary>D</codesecondary>
    </child>
    </childs>
    </record>
    </result>
    In this example only one record is returned since we only have one record in PRIMARY table that has a child having codesecondary=C or D. The ideia is to get many records... but I think that this is enough for the sake of the example. And the solution is the same.
    Thanks in advance!
    GM

    Found the answer. Used distinct keyword instead of grouping the output table columns. This way XMLAgg didn't broke up the result:
    SELECT
    XMLElement("Processos",
    XmlAgg(XMLElement("Processo",
    XMLForest(T.ID as "Id",T.CODIGO as "Codigo",T.DESCRICAO as "Descricao"),
    XMLElement("Funcionalidades",
    SELECT
    XMLAgg(
    XMLElement("Funcionalidade",F2.ID)
    FROM TWBASEDB.LISTA_UNICA_FUNCIONALIDADE F2
    WHERE F2.ID_processo=T.ID
    and f2.ACTIVIDADE IN ('1_ACTC1','1_ACTC2','1_ACTC3','2_ACTC1')
    from
    select distinct P.ID,P.CODIGO,p.DESCRICAO
    FROM TWBASEDB.LISTA_UNICA_PROCESSOS P
    INNER JOIN TWBASEDB.LISTA_UNICA_FUNCIONALIDADE F ON P.ID=F.ID_PROCESSO
    WHERE ACTIVIDADE IN ('1_ACTC1','1_ACTC2','1_ACTC3','2_ACTC1')
    order by p.id
    ) T

  • [UNSOLVED] Event Log Custom XML Query Filtering Help

    I've looked at a few different posts but I must be missing something because what I'm constructing isn't working.
    Here's the XML code of an example event:
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
    <Provider Name="ERAS WCF" />
    <EventID Qualifiers="0">0</EventID>
    <Level>4</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2014-07-09T20:32:51.000000000Z" />
    <EventRecordID>899070</EventRecordID>
    <Channel>Application</Channel>
    <Computer>server.f.q.d.n</Computer>
    <Security />
    </System>
    - <EventData>
    <Data>User [email protected] has submitted 'Get BIOS Information' operation from servername to computername.f.q.d.n.</Data>
    </EventData>
    </Event>
    This is my query:
    <QueryList>
    <Query Id="0">
    <Select Path="Application">*[EventData[Data and (Data='computername' or Data='ip.add.re.ss')]]</Select>
    </Query>
    </QueryList>
    I always get 0 results, even if I take stabs in the dark:
    *[System[(Level=1  or Level=2 or Level=3 or Level=4 or Level=0 or Level=5)]]
    *[EventData[Data and (Data='*computername*')]]
    *[EventData[Data and (Data='%computername%')]]
    I used this post as my guide for filtering based on content: http://blogs.technet.com/b/askds/archive/2011/09/26/advanced-xml-filtering-in-the-windows-event-viewer.aspx
    Also:
    I hope this is the right place for this question.  This said to post in the server
    forums, but in
    the server forums, it said to post here.
    I happen to be doing this on a server, but it could just as easily be a desktop.

    Hello,
    Thanks for posting question to this forum. Since this forum is related with XPath, what I can do is to help you validate your XPath query. With your query, I tested them with my computer, however, all of them could load event record correctly:
    Query:*[EventData[Data and (Data='Office12AssertTimer' or Data='6.3.9600.17031')]]
    Result:
    Query:*[System[(Level=1  or Level=2 or Level=3 or Level=4 or Level=0 or Level=5)]]
    Result:
    So your XPath query is ok. Do you have a try to use the same query to filter the event log to check if there are records with another computer? I am wondering if there is something wrong with your current computer.
    And since the XPath is ok, I would like suggest you posting it to the server forum to see if there are others looking into it.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Query filtering rows in the ViewObject but works fine when run in sql

    Hello,
    The below query returns 8 rows when run in SQL Plus but the same query when used in the viewobject, its only returning 4 rows. I tried in all possible ways but not sure what's happening.
    SELECT
    tt.assignment_number,
    tt.tab_name,
    tt.old_value,
    tt.new_value,
    tt.oracle_value
    FROM TestTable tt
    WHERE tt.ppa_id = :1
    AND ((:2 IS NULL) OR (:3 = tt.old_col))
    AND ((:4 IS NULL) OR (:5 = tt.new_col))
    Any suggestions are appreciated.
    Thanks
    --KK                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Try this
    OAViewObject OAViewB = (OAViewObject)OAAppl.findViewObject("DisplayDetailsVO");
    OAViewB.setWhereClauseParams(null);
    OAViewB.setWhereClauseParam(0,Integer.parseInt(Pid));
    OAViewB.setWhereClauseParam(1,Changes_Flag);
    OAViewB.setWhereClauseParam(2,Changes_Flag);
    OAViewB.setWhereClauseParam(3,Oracle_Flag);
    OAViewB.setWhereClauseParam(4,Oracle_Flag);
    OAViewB.setMaxFetchSize(-1);
    OAViewB.executeQuery();
    Thanks
    Shree

  • Use of  "findByMultipleParameters" for   "OR " between two Query Filters

    Hi,
    I am also working in CE7.1 .I have  a query regarding the use of  "findByMultipleParameters" .
    That is how to use "OR " between two Query Filter condition,because if we add multiple queries into Query Filter List it will by default taking "AND " .
    For an example, I have to pull data from a table/BO with a condition col A = 10 OR ( col B > 100 AND col c = "XYZ") .
    My code snippet looks like given below.......
    List queryFilters = new ArrayList();
    QueryFilter queryFilterOne = QueryFilterFactory.createFilter("ROLLUMBER",Condition.EQ, rollNumber);
    QueryFilter queryFilterTwo = QueryFilterFactory.createFilter("NAME",Condition.EQ, "123");
    queryFilters.add(queryFilterOne);
    queryFilters.add(queryFilterTwo);
    List students = studentServiceLocal.findByMultipleParameters(queryFilters, false, "xyz");
    I have tried all these and found all of them deprecated,Please suggest something appropriate.Your quick response will help a lot.
    //queryFilterOne.setAction(QueryFilter.OPERATION_OR);
    //QueryFilterFactory.createBoolOperator(queryFilterOne.OPERATION_OR);
    //queryFilters.add(QueryFilter.OR);
    //queryFilters.add(queryFilterOne.setOperation(QueryFilter.OPERATION_OR));
    My another Query is what is the role of implCheck(Boolean),findByName(String) in "findByMultipleParameters()" ?
    Thanking you for your help in advance.
    Regards,
    Sonali
    Edited by: Sonali Das on Sep 14, 2010 2:32 PM

    Hi Praveen/Harris,
    As Mr Bhanu said , we can get the result by using formula variable defined on attribute with replacement path as processing type.
    There is document in https://websmp101.sap-ag.de/bi
    in infoindex->How to Calculate with attributes
    To findout the difference between formula variable and current date, define one more formula variable with processing as custoemr exit.And fill this variable with sy-datum or something else.
    with rgds,
    Anil Kumar Sharma .P

  • Incomplete query, filtering with a null field

    Hi Experts,
    Very new in the forum and SAPB1 in general and very week in SQL queries. I have the below query
    SELECT T0.[ItemCode], T1.[ItemName],T0.[U_PKGS],T0.[U_InvNo],  T0.[U_File_Number],T0.[LotNumber] AS Garden,T0.[U_Sale_Number],T0.[CreateDate],T0.[U_GROSSWT], T0.[U_Net_Weight], T0.[U_TareWT]  FROM OBTN T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode where LEFT(T0.Itemcode,2)='T1' and T0.[LotNumber]=[%0]
    and I need all records where the field U_Sale_Number is null to be part of the query, I have tried the empty space("") but its not working.
    I also want an int variable declared to cater for number of days between the T0.[CreateDate] field and the current date or system date, I know you can use a DATEDIFF function to get the number of days between the 2 dates but I don't know how to go about it. Kindly assist.
    Patrick.

    Hi Patrick........
    Welcome to SAP Forum......
    SELECT T0.ItemCode, T1.ItemName,T0.U_PKGS,T0.U_InvNo, T0.U_File_Number,T0.LotNumber AS Garden,T0.U_Sale_Number,T0.CreateDate,T0.U_GROSSWT, T0.U_Net_Weight, T0.U_TareWT FROM OBTN T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode where LEFT(T0.Itemcode,2)='T1' and T0.LotNumber='[%0]' And T0.U_Sale_Number Is Null
    Regards,
    Rahul

  • Converting A Query To A Struct

    Been working on this for a while now with no breakthrough.  The query returns all the colors; the cfset structColors (commented out) held the colors previously.  I still want to use structColors but how would I use it with the query.   Please see image below.
    Any help would be greatly appreciated.                                                                                                                                                                                                                                       

    OK, a couple things related to that code block:
    1) I still see a number of colors still referenced by structColors.COLORNAME e.g. structColors.orange or .white
    Although this won't give you an error because there is no space in the name, it will make your life a LOT easier down the road if you consistently refer to your variables in a standardized format.  6 months from now, you are not going to remember that you need to refer to your you names with spaces with the braket syntax and the ones with spaces without.  I recommend that you switch all your references to use the bracket syntax.
    2) It looks like you are comparing a value in your arguments scope to a specific value (e.g. 1) that I'm assuming you want to replace with the data stored in your new structure. 
    Use a Switch/case statement to set the different cases for dealing with the value of your arguments.type variable and reference you job details using:
    <cfset jobName = structJobStatus["#arguments.type#"]> (note the use of quotation marks and pound signs)
    In the future, it would be helpful to copy/past the data from the pastebin into the comments in the forum so we can view your code without having to follow and external link.

Maybe you are looking for