Run custom button on multiple stores.

Run custom button on multiple stores.

Hello,
I am trying to make a custom button that can run on multiple records.
I am using a custom function.

The problem is that instead of running the function on each store,
it is passing all the stores into one function.

For example if I have a parameter in the function for the storeId when click the button it will pass all the store Id's that I have selected into one parameter in form 330xxxxxxxxxxxx40|||330xxxxxxxxxxxx21|||330xxxxxxxxxxxx30.
I tried to replace the ' ||| ' separator it gives me with a coma but could not get it to work.
Is there any way to do a "for each" on something that is separated with |||.


A test:






Any help will be greatly appreciated.
Tanks