Contents
- 1 Action signatures
gn:act_forEach
- Description
- Used exclusively with variables of
rows
,rowsColumn
,assignments
,pictures
,email
datatypes, to repeat the execution of commands, for each element in the list parameter
- Action returns
- void
- Controlling action
gn:act_break
is used to stopgn:act_forEach
action execution
- 35218
Using showProgressDialog and changeProgressDialog may lead to unexpected behavior, please use only if absolutely necessary. Currently there is no global solution for showing UI changes during action execution but there is a ticket where this is planned: ##38048. What was done in scope of this ticket is that we added additional signature to forEach which will internally show progress dialog during iterations. However it comes with some limitations, more information about new signature at wiki.
create zip and attach to ticket wiki : https://wiki.ginstr.com/index.php?title=gn:act_forEach&action=edit§ion=1
Action signatures
Full signature
[gn:act_forEach]|[source,column,progressDialogMessage,progressDialogStyle,callbackWidgetWhenForEachIterated,callbackWidgetActionSet;ACTIONS]
Parameter Description source
source from where the while action is using value as expression parameter - Valid sources:
rows
rowsColumn
pictures
email
hardcoded
- number of times to repeatforEach
column
column name which will be internally added as parameter to source reference names in actions which will be executed in for each action. - e.g.
[gn:act_getRow]|[@variable/employee_allowedDivisions, @variable/divisionIndex;;@variable/currentDivisionText]
- to
[gn:act_getRow]|[@variable/employee_allowedDivisions(divisionName), @variable/divisionIndex;;@variable/currentDivisionText]
- Valid sources:
- hardcoded
progressDialogMessage
(optional)if message is defined then progress bar dialog will appear when for each starts executing. Progress dialog will take source
over which for each is iterating. Size of elements insource
will represent total number in dialog, while 0 is beginning iteration number. i.e. 4-50 in progress bar would mean 4th element insource
is being processed from total of 50 elements- Valid sources:
Warning! When using progress dialog
forEach
must not be called in a trigger which at calling point has more actions that need to be executed after that trigger, those actions will be ignored. In addition, all actions AFTERforEach
will be ignored. In order to execute actions afterforEach
you must definecallbackWidgetWhenForEachIterated
withcallbackWidgetActionSet
and put actions that follow there.progressDialogStyle
(optional)defines the progress dialog type. By default it's HORIZONTAL
Can be:
SPINNER
HORIZONTAL
callbackWidgetWhenForEachIterated
(optional)target on which is defined callbackWidgetActionSet
- Valid sources:
widgetId
callbackWidgetActionSet
(optional)event action set name which will be fired after all iterations of for each loop have been executed - Valid sources:
hardcoded
ACTIONS
list of actions which will be executed continuously until all rows are iterated - Valid sources:
Repeat the execution of commands based on list source
[gn:act_forEach]|[source;ACTIONS]
Example
variable/listId
- list used for iterationvariable/listId(rowColumnName1)
- retrieving value fromrowColumnName1
column of iterated row
- ⤷
[gn:act_forEach]|[variable/listId;[gn:act_rawWriteValues]|[tableId;column1,column2;variable/listId(rowColumnName1), +id/listRow]]
- ⤷
Repeat the execution of commands based on list source with defined column name
[gn:act_forEach]|[source,column;ACTIONS]
Example
@variable/employee_allowedDivisions
- list used for iterationdivisionName
- column name[gn:act_getRow]|[@variable/employee_allowedDivisions,@variable/divisionIndex;;@variable/currentDivisionText]
- action
- ⤷
[gn:act_forEach]|[@variable/employee_allowedDivisions,divisionName;[gn:act_getRow]|[@variable/employee_allowedDivisions, @variable/divisionIndex;;@variable/currentDivisionText]]
- ⤷
Repeat the execution of commands based on list source with defined column name and progress dialog with actions to post execute
[gn:act_forEach]|[source,column,progressDialogMessage,progressDialogStyle,callbackWidgetWhenForEachIterated,callbackWidgetActionSet;ACTIONS]
Example
@variable/allEmployeesRows
- source_id
- column@string/progressMessage
- progressDialogMessageHORIZONTAL
- progressDialogStyle@+id/exampleFrame
- callbackWidgetWhenForEachIteratedgn:act_set1
- callbackWidgetActionSet
<FrameLayout android:id="@+id/exampleFrame" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" gn:act_set="[gn:act_forEach]|[@variable/allEmployeesRows,_id,@string/progressMessage,HORIZONTAL,@+id/exampleFrame,gn:act_set1; [gn:act_setVariable]|[@variable/colorIndex,@variable/redIndex] ];" gn:act_set1="[gn:act_getVariableToWidget]|[@variable/employeesLastLogins,@+id/employeesLastLogins], [gn:act_showWidgets]|[@+id/lastLoginEmployeesToday_refresh]," />