On-Screen Action - Iterate Task

In the easy and simple no-code way of building code logic area of Action flow, now you have the action of Iterate Tasks. With everyday development, there are several actions we come across, which are required to be repeated for certain data/input. To make this task of iteration, DronaHQ Studio has introduced Iterate Action Task. With the Iterate task in action flow, you get the option to group together the tasks which you want to iterate under certain conditions.

Setting up Iterate Tasks

  1. Go to the Actions of any control, and select an action.

    action

  2. It will open up the action flow area, click to add an action or connector. Search for Iterate in On-Screen Actions under the Utility group.

  3. It will ask you to select a control or keyword from a dropdown list consisting of all the in-use controls and keywords available presently in your app. The iteration will work on selective controls and keywords like datastore, multi-select, and others which return responses in list type.

    The Iterate Tasks supports several items for iteration in keywords such as:

  1. Click on Finish and then the iterate task will be added for the selected control.

NOTE: Only up to 100 iterations can be performed.

Configuring iteration of a task

After setting up the loop for desired controls or keywords, the next is to set up the actions or tasks under the loop which need to be iterated. You can simply add other tasks or server-side actions as well as perform nested iterations between ITERATE TASKS START and ITERATE TASKS END.

  1. Here we are using a datastore control, consisting of an object with many keys and values in it.

    image

    Data in datastore:

  2. Setup an iterate task of Iterate and select the datastore on the action of a button.

  3. Now in between the task start and end, add the desired task under on-screen action and server-side action, which you want to iterate. Here we are using the Toast under Dialogs of on-screen action.

  4. Next is to select the keywords for the toast from the datastore selected in the loop. These keywords will be used as parameters for the number of iterations required.

    It will read the number of times the title and message data are available in the datastore and toast data will be displaying the same number of times.

    With keywords, you can select any attribute of the object, exclusively.

    NOTE: By default Iterate Tasks provide two keywords-

  • < Iterate Task Name>.INDEX: On choosing .INDEX keyword from the iterate task can be used to get the index of the item from the data. It starts from 0 and goes up to length-1 of the data. The number of iterations, as well as the data being iterated, is determined by selecting their index.

    image

  • < Iterate Task Name>.VALUE: If you choose the .VALUE keyword from the iterate task will have the whole object/string of that index. If you have an iterated array of objects, then it will return the whole object of that index.

    image

  1. Click on Continue and Finish.

Iteration in Server-side action

You can also add server-side action tasks to the iterate tasks. It would require a variable to store the data coming from the server. The order of data getting received from the server throughout the iteration might not be in the correct sequence due to the differences in request time. To make it sequentially correct, the user can use custom JavaScript code.

Nested Iteration

You can even add multiple iterations in a nested form. There might be cases where data is available in a multi-dimensional array of objects, requiring iteration in each object. In that case you can nest the iterations one inside another along with distinctive actions and tasks.

Iteration in action

With the click of a button, the iteration of the toast action is taking place. The number of iterations of the task is the same as the number of indexes and values available in the datastore.

NOTE: Whichever list type (Array of JSON objects) keyword you bind, when you access that Keyword.KeyName in any other task within iterate scope will have that particular index’s Key value instead of the entire array value.

So, in the above image, if you choose the name or email, or others, it will iterate through that particular key-value only.