Order creation via the API

Discussions concerning general integration topics.

Moderator: Phil Barton

Post Reply
cbigden
Posts: 4
Joined: Fri Oct 03, 2008 11:27 am

Order creation via the API

Post by cbigden »

Can someone explain why we can create a new order via the API with no exceptions thrown or messges being returned from the SaveOrder method and we can see the order in the UI's Search Results window yet the UI will not display the order. Rather a message box is displayed. Please see attached screen shot.
Attachments
Order Display error Screen Shot
Order Display error Screen Shot
OrderCreation_20081003.png (52.23 KiB) Viewed 1759 times
cbigden
Posts: 4
Joined: Fri Oct 03, 2008 11:27 am

Re: Order creation via the API

Post by cbigden »

Additional information: Order was created by extrracting the data from an existing order and then attempting to create a new order from that same data.

We subsequently tried to open the Order via the API and received the following exception:
"Error executing business rule 'SoftPro.BusinessRules.Core.DefaultHudLine'\nInputs:\n\t1. \n\t2. \n\t3. \n\t4. \n\t5. \n"

StackTrace follows:

at SoftPro.BusinessRules.Base.BusinessRuleBase.Execute(Object[] inputs, ExecutionInfo ruleInfo)
at SoftPro.BusinessObjects.Base.Engine.GetRuleDataValue(IBusinessObject businessObject, String ruleInstanceName, Object potentialNewValue)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.FulfillDataItemNormally(Dependency depItem, DataValue sourceItem)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.GetDataValue(String dataItemName)
at SoftPro.BusinessObjects.Base.HUDLineEngine.GetHudItemsFor(IHudLine line, List`1& dependencies)
at SoftPro.BusinessObjects.Base.Engine.GetRuleDataValue(IBusinessObject businessObject, String ruleInstanceName, Object potentialNewValue)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.FulfillDataItemNormally(Dependency depItem, DataValue sourceItem)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.GetDataValue(String dataItemName)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.GetDataItem(String dataItemName)
at SoftPro.BusinessObjects.Base.Engine.ReleaseCalculatedChildRequests()
at SoftPro.BusinessObjects.Core.Order.Load(Guid primaryID, ContextRoot rootContext)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.GetBusinessObject(String contextName, Guid primaryKey, ContextRoot rootContext, Boolean allowDisambiguation, SqlDataReader openReader, Boolean allowLoad, Boolean loadingAsCopy, Boolean acquiringRoot, Guid idForNewObject)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.GetRootObject(String contextName, Guid primaryKey, ContextRoot rootContext, Boolean loadingAsCopy)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.AcquireRootReference(String contextName, Guid primaryKey, Boolean loadAsCopy)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.AcquireRootReference(String contextName, Guid primaryKey)
at SoftPro.OrderTracking.Client.OrderTracking.OpenOrderObject(Guid id)
at SoftPro.OrderTracking.Client.OrderTracking.OpenOrder(Guid id, Boolean readOnly)
at SoftPro.OrderTracking.Client.OrderTracking.GetOrder(OrderQuerySpec spec, Boolean readOnly)
at ConsoleApplication.Program.Main(String[] args) in D:\\IOrderSurrogateTest\\ConsoleApplication\\Program.cs:line 65"
cbigden
Posts: 4
Joined: Fri Oct 03, 2008 11:27 am

Re: Order creation via the API

Post by cbigden »

It appears there must be some sort of dependency on the HUDLine data. We are currently not serializing any HUD data and therefore we are also not writing any HUD data to the newly created order prior to saving. What are the implications of doing this?
Phil Barton
Posts: 54
Joined: Wed Sep 24, 2008 2:37 pm
Location: Raleigh, NC
Contact:

Re: Order creation via the API

Post by Phil Barton »

If you have the latest service pack, then the answer is as simple as doing an overlay. Overlay does a complete copy of any user-entered data from a source order or template into the destination order. Here is some example code of how to use the overlay functionality:

Code: Select all

SelectServer server = new SelectServer(null, new Uri(@"<URI To Select Server>"), new NetworkCredential(@"<user name>", @"<plain-text password>", SoftPro.Select.Client.Constants.SelectDomain));
SoftPro.OrderTracking.Client.OrderTracking ot = server.GetService<SoftPro.OrderTracking.Client.OrderTracking>();
OrderCreationSpec spec = new OrderCreationSpec();	// Use the order numbering manager for the currently logged in user.

spec.Templates.Add(@"<Template Name or Order Number");  // Add the template or order to overlay

using ( IOrder order = ot.CreateOrder() )  // Order is created and the data from the template(s)/order(s) is/are copied to the new order
{
	try
	{
                // Do work on the order

		ValidationMessage[] messages;

		if ( !ot.SaveOrder(order, out messages) )
		{
			// Handle save failure
		}
		else
		{
			// Handle save success
		}
	}
	finally
	{
		ot.CloseOrder(order); // Must be done to ensure proper clean up
	}
}
Phil Barton
Software Architect
SoftPro
cbigden
Posts: 4
Joined: Fri Oct 03, 2008 11:27 am

Re: Order creation via the API

Post by cbigden »

Phil, our intent is not to copy an order inside of Select but rather create a new order in select from data that is recieved from some external source. We were only using select as a source of the data because we can easily serialize that data and then attempt to create a new order from that data. So our question is what dependencies are there among the various classes that would create such a situation. Is there some minimal amount of data and or some related data that must be populated in a newly created order to be able to save that order and then be able to successfully view it.
Phil Barton
Posts: 54
Joined: Wed Sep 24, 2008 2:37 pm
Location: Raleigh, NC
Contact:

Re: Order creation via the API

Post by Phil Barton »

Let me look into this further based off of the stack trace above and I will post an answer to this forum.
Phil Barton
Software Architect
SoftPro
jcreyes
Posts: 8
Joined: Tue Nov 18, 2008 10:44 pm

Re: Order creation via the API

Post by jcreyes »

I'm encountering a "Failed to load the SoftPro business rules for order" exception upon executing the following code lifted from the SDK.

Image

Any help to resolve this issue will be greatly appreciated. Thanks!
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: Order creation via the API

Post by John Morris »

Are you copying our dlls out of the install folder?

Try copying your test program exe into the SoftPro Select client installation folder (C:\Program Files\SoftPro\Select).
John Morris
Sr. Software Architect
SoftPro
jcreyes
Posts: 8
Joined: Tue Nov 18, 2008 10:44 pm

Re: Order creation via the API

Post by jcreyes »

Yes, I'm copying the dlls from the install folder.

Running the program exe in the Select folder did the trick!

Thanks John!
Post Reply