cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Error calling SQL Stored Procedure from Condition

Here is the error:

<quote>Flow save failed with code 'InvalidVariableOperation' and message 'The inputs of workflow run action 'Condition' of type 'If' are not valid. The variable 'SP_PAB_Contacts' must be initialized before it can be used inside action 'Condition'.'.</quote>

I'm calling a SQL Stored Procedure (SP1) and parsing its results set in order to populate CDS Account records. I have a condition (Condition 4) that evaluates if the CDS Account exists or not. In this case, when it does not, I want to create it. After the CDS Account is created I need to call another SQL Stored Procedure (SP2) to get other information to populate CDS Contacts. 

The result is the error above and I've been unsuccessful in finding any meaning to the error or guidance for a potential fix. I'm stuck and cannot Save my work in this state. I'm also prevented from moving objects around in order to save my work due to dependencies. 

FLOW_ConditionError.png
1 REPLY 1
Highlighted
Dual Super User III
Dual Super User III

I think your problem is in condition 4.  I assume you are getting the length of the results returned from your check for accounts.  But if it doesn't find any then the result is null.  You can't get the length of a null result.  So the condition is failing.  In Condition 4 add a first check to see if the variable you are taking the length of is null (use the expression tab to input the null value).  The condition will evaluate that clause first and fail if the value is null.   Also switch the length check to Greater than 0 and swap the Yes and no sides of the condition.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (9,637)