The Shipping Director is an "evaluation engine"

The Shipping Director is an "evaluation engine".  Each row is evaluated based on "Order".  (Some old school VB developers may notice the numbering scheme in the example screen below. :)  The "Type" of each row is either a variable (String, Boolean, etc.), an Error, or a shipping Option.  For Variables, the "Expression" field should evaluate to the type of the declaration.  For Error and Option, the "Expression" field is a 'condition' that should evaluate to a boolean - if true, the additional expressions are evaluated (rate, surcharge, etc.), and if false, the next row is examined.  You can specify whether the rows continue to evaluate, or "Exit" when matched - ErrorExit, OptionExit.  Additionally, there is (not shown below) a global setting: "Evaluate All" vs. "EvaluateFirstMatchOnly", whereby a plain Exit or Option will exit if EvaluateFirstMatchOnly is set.

Below are some sample expressions in context of the Configure screen.   (Note that NameExpression and DescriptionExpression must evaluate to strings - if you just have text, be sure to enclose it in double quotes.)

Sample Expressions

Tags :  GettingStarted
Leave your comment
Created on: 10/29/2019 11:16 PM
Hi,  I am trying to use Shipping Director to execute a SQL Stored Procedure that returns a Boolean value in order to offer a certain shipping option.  Here are my evaluation rows:

Order  Active  Type  Name  Expression  RateExpression  SurchargeExpression  NameExpression  DescriptionExpression

0  True  Int32  CustomerId  Customer.Id        

5  True  Boolean  IsContiguous  "AK,HI".Contains(State)        

10  True  Boolean  CheckShipCriteria  EXECUTE CheckShippingCriteria @CustomerId; [CustomerId]        

20  True  OptionExit  Shipping to Hawaii/Alaska  [IsContiguous] AND [CheckShipCriteria]  15.95      

30  True  Option  Flat Rate Shipping  true  12.95  

When I test it out I get the following error:

Error -; Record=5: 10 CheckShipCriteria; Expression=EXECUTE CheckShippingCriteria @CustomerId; [CustomerId]; Error=EvaluateQueryExpression - Field:CheckShipCriteria, Expr=EXECUTE CheckShippingCriteria @CustomerId; 252158, Error=Must declare the scalar variable "@CustomerId".

I am declaring the variable properly in my stored procedure so I am not sure why it si erroring out.  Here is my stored procedure code:

ALTER PROC [dbo].[CheckShippingCriteria]
@CustomerId int,

    IF EXISTS (SELECT CustomerId FROM ShoppingCartItem WHERE CustomerId = @CustomerId AND ProductId = 3764)
      SET @Result = 1
      SET @Result = 0


    --Capture errors if they happen
    EXEC [dbo].[usp_StoredProcedureErrorLog]


Any guess as to why this is happening?