FortiSOAR Discussions
Fabien1
New Contributor II

For loop and pagination

Hello,

 

In some data ingestion steps that are relying on pagination ( OpenCTI "Get Indicators" action for instance ), while using for loop in playbook step, we need to provide the output  variable of one loop as an input for the next loop to be executed. How can we achieve this?

 

Regards

Fabien

1 Solution
okumbhar

You can create one parent playbook and one child playbook which is self referenced

View solution in original post

9 REPLIES 9
okumbhar
Staff
Staff

You can set variables in a playbook step, use those variables in next steps and then after that you can use decision step to go back to any previous step based on the condition that you define.

Harsukhrpeet

Thank you for your reply.
We tried this but it does not allow us to go back to any previous step again, i.e : one step can be executed only once.

Here is the error message for reference: 
"CS-WF-13: Invalid Playbook. Playbook should always be Directed Acyclic Graph"

okumbhar

You can create one parent playbook and one child playbook which is self referenced

Harsukhrpeet

Hi @okumbhar 

Thank you for the answer.
This helped us for a smaller set of data but for huge data : lets say 2k or more , it gets stuck with error : CS-WF-52: Possible infinite recursion detected. Aborting after a depth of 10 runs referencing the same playbook.

 

okumbhar

I think we need to add a new checkbox parameter 'Fetch All Records' in the action, which will return all records, so the logic of fetching all records can be written in backend code instead of trying to implement it in playbook.

Harsukhrpeet

When can this be implemented. Also is it not possible to implement a feature which  calls a [playbook step]/playbook recursively with a definite number of times which can be defined by the user,  so that it does not assume that it will go to infinite loop

philip_g

https://docs.fortinet.com/document/fortisoar/latest/playbooks-guide/784146/triggers-steps#Loop

The playbook guide mentions how to change the limit of 10:

Similarly, to limit recursion of self-references in playbooks to '10', in release 7.3.1, a 'REF_SELF_PB_LOOP_LEVEL' parameter is added in the /opt/cyops-workflow/sealab/sealab/config.ini file. You can change this value as per your requirement, but do not set it too high.
If you are on a release earlier than 7.3.1, you can add the 'REF_SELF_PB_LOOP_LEVEL' parameter to the the '[application]' section in the /opt/cyops-workflow/sealab/sealab/config.ini file.

Additionally, when running a step in a loop, you might need to access result of the previous item execution in the next iteration. For example, when creating playbook steps using LLMs, you might need to use the previous set of steps generated as input for generating the next step. To do this, add save_iteration_result as an environment variable and set its value to 'true'. The result of the previous iteration can then be accessed using iteration_result_<step_name_with_underscore>. This method is applicable for both sequential 'for each' loops and 'do until' loops.

Anonymous
Not applicable

Thank you for your valuable suggestion! We've taken note of your request and will explore its feasibility for future consideration. Given our current focus on multiple customer priorities, it's challenging to commit to a specific timeframe, but please know we'll diligently pursue this matter.

hmooreamelia
Visitor

FUNDS RETRIEVER ENGINEER prioritizes building trust with its clients through transparent and effective service. The company’s commitment to recovering lost funds and providing high-quality support is evidenced by its extensive experience and successful case history. Clients seeking assistance with fund recovery can rely on the company’s expertise and dedication.