Forums / Setup & design / list_count problem

list_count problem

Author Message

Michel Houtermans

Tuesday 10 February 2004 8:17:47 am

I have a class with an attribute that is based on a object relation. Now in a folder I want to count the number of objects of that class where the attribute is equal to a certain string.

numWon=fetch('content',
'list_count',
hash( parent_node_id, $node.node_id,
class_filter_type, include,
attribute_filter, array( 181, '=', 'Closed: Won' ) ) )

It does not count them though. Does this not work when an attribute is an object relation?

Tore Skobba

Tuesday 10 February 2004 9:19:14 am

Hi

I think you need an array more for attribute filter, i.e.:

attribute_filter,array(array(181,'=','Closed: Won'))

Try it, does it work?

Cheers
Tore

Michel Houtermans

Tuesday 10 February 2004 9:54:45 am

Hi, that did not do the trick.

Tore Skobba

Wednesday 11 February 2004 2:32:13 am

Hmm well then do some debug output. Is attribute 181 really stored as 'Closed: Won'? For instance EZSelections are stored as numbers (check the database or print out the content).

hmm you are talking about an object relation, but fecthing from $node.node_id. Think I need some more info in order to understand the specific case you are dealing with.

Cheers
Tore

Michel Houtermans

Thursday 12 February 2004 12:17:46 am

Hi Tore,

I have a class (Trade) with an attribute (Remark) that is an object relation to another class (Trade Remark).

Now I have a folder with objects of class Trade. I want to count the number of objects in this folder where the Remark attribute is "Closed: Won".

Now I noticed that the Closed: Won" has object ID 66 and the attribute Remark has attribute ID 181. So I also tried this:

attribute_filter, array( 181, '=', '66' )

and this

attribute_filter, array( 181, '=', 66 )

But neither give me a count.

Tore Skobba

Thursday 12 February 2004 2:00:19 am

Well, as I can see you are fetching all Trade nodes, I.e. numWon=fetch('content',
'list_count', hash( parent_node_id, $node.node_id. Then trying to count all Trade objects having attribute 181 equal to 'Closed:Won'. I.e. class_filter_type, include,
attribute_filter, array( 181, '=', 'Closed: Won' ) ) ).

However, as I understand you it is the Trade Remark class which has the attribute 181? So in order to count the attribute 181 you will need to fetch objects of class Trade Remark, i.e.

Loop: For each trade object
Fetch the Trade Remark object and check and count number Close: Won.

Michel Houtermans

Thursday 12 February 2004 3:02:41 am

Sorry, i must have written it down confusingly.

Class Trade has ID 21. The class Trade has an attribute Remark with ID 181. This attribute is an object relation to a Class called Trade Remark.

Now in the folder I have several objects of the class Trade. I want to count the objects where the attribute 181 equals "Closed: Won".

Now the "Close: Won" object has Object ID: 66. So could this be the expression:

attribute_filter, array (181, '=', 'Close: Won')

or is this how it works:

attribute_filter, array (181, '=', 66)

or may be this:

attribute_filter, array( array (181, '=', 66) )