How to get the count of smartobject get list method in workflow


Userlevel 3
Badge +9

I tried to get the return the count of smartobject getlist method with lists- Cont function but it gives runtime error "A list can only be used in an expression if it contains exactly one value."

attached is screenshot.


14605i326ECFBB1D6FF328.png

2 replies

Userlevel 1
Badge +8

Hi YPawar

 

Unfortunately there is no Count function available for List methods (would be a welcome improvement).

 

If you can create your own custom method (e.g. a stored procedure in SQL to return a count value) then you can do that, otherwise you can use an Activity to loop through the list and do an incremental count. This method will only work if at least one row is returned (it will error if 0 rows are returned), and I would not recommend it for large list counts (>100)

 

  1. Create a workflow level integer data field (e.g. ListCount)
  2. Add an activity and open the Destination Rule
  3. Click back and select the Advanced Mode
  4. Select "Plan per slot (no destinations)"
  5. Select the "Select a list field to determine how many slots should be created"
  6. Drop the smartobject list method into the field
  7. Configure the list methods Input Mapping and Filter as required
  8. Select a return property such as the ID property (choose a property that will have a unique value)
  9. In the Activity add a Data Event and select "Transfer Data"
  10. Click Assign 
  11. In the Destination add the ListCount data field
  12. In the Source add an expression ListCount + 1
Userlevel 3
Badge +9

Thanks for reply.. I thought of this solution to loop trough the activity and use process datafield to increment the counter but I need to get the count for 3 smartobjects. It will make the workflow complex.

 

I cose another approach, to add code server event and code to get the count, I can achive this in 1 activity for all 3 smartobject.

Reply