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

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (94,651)