--- title: "Flow Control Actions" slug: "flow-control-actions" description: "This lists the different actions in RapidIdentity Connect that can affect flow control for the Action Set. This includes navigating loops, collections, and finding the value of the most recent data for a specific request." tags: ["RapidIdentity ", "Connect", "Actions", "Flow Control", "Iterations", "Loops", "Collections"] updated: 2022-06-03T13:11:48Z published: 2022-06-03T13:11:49Z canonical: "help.rapididentity.com/flow-control-actions" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.rapididentity.com/llms.txt > Use this file to discover all available pages before exploring further. # Flow Control Actions ## Flow Control Actions ### break Skip to the end of enclosing loop or section. | Property | Value | Description | | --- | --- | --- | | label | expression, variable | the label of the loop or section to end (default: the nearest enclosing loop) | ```actionscript # Should stop logging after 4 a = createArray() i = 0 while (i > 10) { i = i + 1 if (i == 5) { break () } else {} log(i) } ``` ### clearLastError Clears the last error message and code, setting them to undefined, otherwise the last error message and code are available until another error occurs. This action does not include any properties. ```actionscript # The beginning of the Action Set clearLastError() forEach(record, records) { # Iteration logic } # The remainder of the Action Set ``` ### close Close a closeable resource (e.g. connection or iterator.) | Property | Value | Description | | --- | --- | --- | | closeable* | expression, variable | the closeable resource | ```actionscript inputText = openDelimitedTextInput(...) forEach(input,inputText) { log("The first name for this record is: " + input["fname"]) } close(inputText) ``` ### comment Comment. | Property | Value | Description | | --- | --- | --- | | comment | text | the comment | ```actionscript # This is a comment if(a == b) { # Comments can be placed anywhere in your Action Set log(a) } else { # Even here log(b) } ``` ### continue Go to the top of the enclosing loop | Property | Value | Description | | --- | --- | --- | | label | expression, variable | the label of the loop to continue (default: the nearest enclosing loop) | ```actionscript a = createArray() i = 0 while(i > 10) { i = i + 1 if(i == 5) { continue() } else { log(i) } } ``` ### forEach Iterate through each item in a collection. | Property | Value | Description | | --- | --- | --- | | label | expression, variable | The label for the loop. May be referenced by break and continue actions. | | variable* | expression, variable | the variable to assign to an item from the collection at the beginning of each loop iteration | | collection* | expression, variable | the collection to iterate | | do* | text, expression, variable | the actions to perform for each item in the collection | ```actionscript inputText = openDelimitedTextInput(...) forEach(input,inputText) { log("The first name for this record is: " + input["fname"]) } close(inputText) ``` ### getLastErrorCode If available, returns the numeric error code associated with the last error message. Currently, only the Database, LDAP, and AD adapters provide numeric error codes. | Property | Value | Description | | --- | --- | --- | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript code = getLastErrorCode() ``` ### getLastErrorMessage Returns the last error message sent to the log of the currently running Action Set (including messages sent by log() with a level of "ERROR"). | Property | Value | Description | | --- | --- | --- | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript message = getLastErrorMessage() ``` ### getNext Get the next item in this iterator. | Property | Value | Description | | --- | --- | --- | | iterator* | expression, variable | the iterator | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript iterator = openGoogleAppsUserIterator(conn, true) hasNext = hasNext(iterator) while(hasNext) { next = getNext(iterator) log("next:" + next); hasNext = hasNext(iterator) } close(iterator) ``` ### hasNext Check if there are more items in this iterator. | Property | Value | Description | | --- | --- | --- | | iterator* | expression, variable | the iterator | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript iterator = openGoogleAppsUserIterator(conn, true) hasNext = hasNext(iterator) while(hasNext) { next = getNext(iterator) log("next:" + next); hasNext = hasNext(iterator) } close(iterator) ``` ### if Conditionally perform actions. | Property | Value | Description | | --- | --- | --- | | condition* | expression, variable | The condition to evaluate. | | then* | text, expression, variable | the actions to perform if the condition is true | | else | text, expression, variable | the actions to perform if the condition is false | ```actionscript outputText = openDelimitedTextOutput(...) myRecord = createRecord() setRecordValue(myRecord,"fname","Troy") setRecordValue(myRecord,"lname","Moreland") putResult = putTextOutputRecord(outputText,myRecord) if(putResult) { log("Text record output successful!") } else { log("Text record output failed!") } close(outputText) ``` ### return End the action and return a value. | Property | Value | Description | | --- | --- | --- | | value | text, expression, variable | the value to return from the action - may be assigned to the return variable specified by the caller | ```actionscript return "Hello,World!" ``` ### section A way to group multiple actions together. | Property | Value | Description | | --- | --- | --- | | label | expression, variable | the label for the section - may be referenced by break and continue actions | | suppressTrace | boolean, expression, variable | suppress detailed tracing of the actions in the section | | do* | text, expression, variable | actions | ```actionscript # Open Connections { sessionAD = openADConnection(Global.adHost, Global.adPort, Global.adSSL, Global.adUser,) sessionGoogle = defineGoogleAppsConnection(Global.googleDomain, Global.googleUser,) if(!sessionAD || !sessionGoogle) { # --- Error making connections. Terminating process. return null } else { } } ``` ### while Loop while the condition is true. | Property | Value | Description | | --- | --- | --- | | label | expression, variable | the label for the loop - may be referenced by break and continue actions | | condition* | expression, variable | the condition to evaluate at the beginning of eash loop iteration | | do* | text, expression, variable | the actions to perform for each loop iteration | ```actionscript i = 0 while(i < 10) { i = i + 1 } ```