Can we execute rules for each listItem in smartForm?


Badge +3

Hello,

 

 

I need to start a workflow process for each item in my listview when a button clicked.

Can anyone tell me how can we achieve this?

 

 

Thank you,

 

Hasyim


9 replies

Userlevel 1
Badge +3

Hi Hasyim,

 

Yes, you can publish your process with an extra option (in K2 Studio: Process tab > Associations > Checkbox: Create Workflow SmartObjects) so that the process will also be deployed as a smartobject with a Start method.

 

Then you can use the "for each item changed / added execute a smo method" rule.

 

Regards,

 

Peter

Badge +3

Thank you for your reply,

 

 

Almost there.. 

 

 

Is it possible to call the smartObject method for each list item when items is being populated?

I want to start a workflow for each listview  item with only 1 user action. For example when cliking on a button.

 

 

Thanks,

Badge +10

HI,

 

I think if you want to execute a method for each item nt he list you can use the 'Execute "this method" for all items that are in a spefic state. YOu can choose from items that have been "Added","Removed","Changed" etc etc. How ever I dont think the default out of the box "start workflow" method is selectable in that "this method". So you may have to create a custom smartobejct that starts a workflow.

 

Which is fairly straight forward. I cannot find the guide to write custom service objects currently but maybe one of the guys can give you a link if you want to go down this route. I can provide a indepth way of write a service object that starts a process if you decide to do it this way.

 

Another way of doing this, is to let the user save everything on the form and submit. After submit, in the workflow itsself, you can read the list from the database and then create a activity with an IPC event which then starts a process for each item in the list. Just need to configure the destiantion on that activity so that it runs for each item in the list. If you do it this way you should not have to write any code.

 

Hope this helps a little.

 

 

 

Badge +3

Thanks for your help,

 

 

Lets me make it simple,

 

 

I want to execute startProcess method  of SmartObject from process that already deployed as instructed by pblommendaal  when listItem is being populated.

So, when I execute list view  method with a filter that return 10 rows, it will create 10 processes automatically.

 

The purpose of this way is : To make user very easy, no need to select one by one the Item that need to start flow.

 

Is there any way to achieve this?

 

 

Thanks,

 

Hasyim

 

Badge +3

Hello,

 

 

Any other solution to achieve this?

 

From my last try, I found in debug mode only list event trigerred, no onChange/ Add Item event called. So no smartObject can be executed when list items populated.

 

 

 

13111i352318D621153BE7.png

 

 

Thanks,

 

Hasyim

Userlevel 1
Badge +3

You need to trigger a changed event for all list items. The only way I know of is a small hack from a colleague:

 

1. add a column you don't need to the list view, this column will load the data on initialize;

2. set an expression for that column that changes the value, just make sure it's really different; for instance the ID field, change it to 0, you know for sure that each record you loaded won't have an ID set to 0, so when using an expression that changes it to 0 the row is changed.

3. You can then utilize the execute this method for all items that are in a spefic state rule.

 

The column can be hidden.

 

Cheers,

 

Peter

 

 

Badge +3

 

Hello Peter,

 

 

Thanks for reply,

 

Please correct me if I was wrong.

 

I tried your way, add a column, than map it to a smartObject field, than set it's expression. 

 

then I tried to catch the event :

 

 

When loginname Data Label1 is Changed

then show a message to the user(configure)

 

 


But the message not appear. It mean the on aViewControl is Change event not work with this way.

Any other solution ?


Thanks a lot in advance,

Hasyim

 

 

 

 

Userlevel 1
Badge +3

Hi Hasyim,

 

Catching that event wont work, that doesn't change.


You need to add the following action to the On Initalize event, right after the get list method:

 

then using Smartbox.Test.Companies, execute the Save for all the items that have been Changed (configure):

 

14178i4213A79BC576C4F4.png

 

Cheers,

 

Peter

 

 

Badge +3

 

Thank you Peter !

 

 

It works perfectly. Nice to meet you.

 

 

 

Thanks,

 

Hasyim

Reply