Creating SL Sales Orders and having SL automatically handle pricing for Catalina’s SOAP based API for Dynamics SL

Creating SL Sales Orders and having SL automatically handle pricing for Catalina’s SOAP based API for Dynamics SL

There are many times where you want to be able to import sales orders into Dynamics SL and have SL automatically price the order items for you (instead of you manually setting it).  This is easy to do in REST, because you can omit fields like CurySlsPrice and then the RESTful API will see that as a null and then ask SL to price for you.  But SOAP isn’t as simple since passing nulls isn’t as easy.

We have a simple way of handling this by a secret number.  Yes, I said that right.  We use a secret number (-999876 to be exact).  This is a very unlikely number to ever have a price set as in SL.  So, if you set the sales price of a line item to -999876, the Catalina API will then ask SL to automatically price it for you.  If you pass any other number, the Catalina API will use that number for pricing override.

Here is an example: (NOTE:  see the setting of the orderItems array, both the CurySlsPrice and CuryCost is getting set to -999876.  This tells the Catalina API that it is to use the SL sales price for the customer and follow all pricing rules setup against the customer, price class, quantity ordered, etc.

// Test placing an order with the bare minimum
ctDynamicsSL.orders.order oOrder = new ctDynamicsSL.orders.order
{
 SOTypeID = "SO", // set your order type (must be a valid soTypeID)
 CustID = "C300", // which customer are you creating an order for (must be a valid CustID)
 ShipViaID = "BEST", // how are you shipping it (ust be a valid shipViaID)
 ShiptoID = "DEFAULT", // Which ShipToID for the customer are you shipping to (must be a valid shipto address for the customer)
 AdminHold = true, // for kicks, we are going to put it on admin hold
};

// create an array of orderItems with the bare minimum (this allows SL to price)
List<ctDynamicsSL.orders.orderItem> orderItems = new List<ctDynamicsSL.orders.orderItem>();
orderItems.Add(new ctDynamicsSL.orders.orderItem
{
 InvtID = "0RCRANK", // which invtID are you sending this to? (must be a valid InvtID)
 CurySlsPrice = -999876, // -999876 is a secret number that will tell the web services to allow SL to price the item
 CuryCost = -999876, // if you want to price this yourself, just put in the amount you want to price
 Taxable = 1
});
oOrder.orderItems = orderItems.ToArray();

// lets place the order using placeOrder()
var placedOrder = OrderService.placeOrder(oOrder);

// if there is a value in the errorString property of the returned object, then there was an error
if(placedOrder.errorString.Trim() != "")
{
 Console.WriteLine("An Error Occurred: " + placedOrder.errorString.Trim());
}
else
{
 Console.WriteLine("Order Created: " + placedOrder.OrdNbr);
}

You can see the full example on GitHub here: https://github.com/CatalinaTechnology/ctAPIClientExamples/tree/master/TestSLConsole

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s