Skip to main content
Contributor
June 4, 2020

Technical Note: [FortiSOAR / Cybersponse Tricks'n'Tips] Testing whether Steps variable is Empty before setting it

  • June 4, 2020
  • 0 replies
  • 856 views
Description

I am trying to find a record using some conditions from the emails module


image



In the retrieve email body step I am trying to set the variable this way


image


Testing whether the value includes anything and hence setting its value otherwise doing nothing.


I am facing this error


image


I think is caused by not finding the Required emailm however isn't the defined condition in the if condition supposed to avoid this issue?





Instead of using 'is defined' simply use this way {% if vars.steps.Copy__of_Find_Emails%} {{vars.steps.Copy__ofFind_Emails[0]}} ...... 


for. eg - {%if vars.result.asset_iri %} {{vars.result.asset_iri}}{%else%}None{%endif%}  



Looking at this it tells that vars.steps.Copy__of_Find_Emails  is defined and it's is dict not list as we are expecting it to be list by using vars.steps.Copy__of_Find_Emails[0] . 


However, to understand what is going on, setting any dict in the if clause automatically sets it as a condition to if its Null or Not