Showing results for 
Search instead for 
Did you mean: 
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. 

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

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,676)