ClaytonFirthD3

Count Number of Items Returned By List SmartObject

Jump to solution

I have been asked if is possble to conditionaly perform an action depending on the number of results returned after executing a smart object. i.e if one result transfer values to controls ELSE display a subform with all results.

 

Obviously to do this need be able to count the number of items returned from the smart object.I cannot see any native way to do this so i've started to look for work arounds.

 

I've looked at creating an expression and using the List Affregators - List Count operator. This worked on a List view but not on an item view. I have tried using this expression against a drop-down-list data source but it hasn't worked.

 

Is anyone able to assit, or should I abandon all hope?

 

Regards,

Clayton

0 Kudos
Reply
7 Replies
PeterH
Apprentice

Re: Count Number of Items Returned By List SmartObject

Jump to solution

Hi,

 

You could try using an advanced conditon to check against a trasnfered value.

 

Take a look at this link, might give you an idea  of how to create a condtion based on the number of results returned:

 

http://help.k2.com/onlinehelp/K2smartforms/UserGuide/1.0.7/default.htm#SF_-_Rule_Designer_-_Conditio...

 

Regards

0 Kudos
Reply
JohanL
Apprentice

Re: Count Number of Items Returned By List SmartObject

Jump to solution

Hi,

 

One way to do this is to create a list view which displays your list and then have a list aggregator count the results.

Set it to asynchronously execute the GetList method.

Then in the form where you want to use the count, add this view but hide it and then in your rules you will have access to the controls on this hidden view and so also the count value. You can then use this in an expression.

 

Hope this helps!

Regards,

JohanL

Reply
s0m3one
Apprentice

Re: Count Number of Items Returned By List SmartObject

Jump to solution

Write a stored procedure and expose that throough the SQL Server Service and generate a smartobject. That would be the quickest solution.

0 Kudos
Reply
ClaytonFirthD3

Re: Count Number of Items Returned By List SmartObject

Jump to solution

Thanks all, @JohanL's suggestion has acheive the result I need..

 

@s0m3one unfortunatley the results are coming from a 3rd party Web Service so a stored procedure is not the answer to this question.

0 Kudos
Reply
vds
Novice

Re: Count Number of Items Returned By List SmartObject

Jump to solution

The answer marked Solution here is clever, but ridiculous.  2018, there should be a better way than to have to create an entire view.

Reply
kcaddell
Novice

Re: Count Number of Items Returned By List SmartObject

Jump to solution

It's 2019 now and still ridiculous. This should be bare bones functionality.

Reply
k2noob10
Novice

Re: Count Number of Items Returned By List SmartObject

Jump to solution

You can use expressions for semi-colon delimited values in “Data Label” in my case as below:

If ( Length ( Data Label ) = 0, 0, Length ( Data Label ) - Length ( Replace ( Data Label, ;, (Empty String) ) ) + 1 )
0 Kudos
Reply