SPS API - Creating New Orders with Joint Buyers/Seller

Discussions related to order tracking development with the ProForm module.

Moderator: Phil Barton

Post Reply
sanjay.mittal
Posts: 94
Joined: Mon Dec 28, 2009 3:43 pm

SPS API - Creating New Orders with Joint Buyers/Seller

Post by sanjay.mittal »

Do you have a sample code for how to save a new order usins SPS API that has a joint buyer/seller? The following piece of code doesn't save buyer/seller information and I don't know what is wrong in the code.


IBuyer oBuyer = order.Buyer.CreateNew();
oBuyer.Type = "Joint";
gBuyerID = oBuyer.ID;
bNextSpouse = true;
oBuyer.IndivName1First = xmlContact.Attributes["FIRSTNAME"].Value;
oBuyer.IndivName1Last = xmlContact.Attributes["LASTNAME"].Value;
oBuyer.IndivName1Middle = xmlContact.Attributes["MIDDLENAME"].Value;

oBuyer.CurrentAddress1 = xmlContact.Attributes["ADDRESS_1"].Value;
oBuyer.CurrentAddress2 = xmlContact.Attributes["ADDRESS_2"].Value;
oBuyer.City = xmlContact.Attributes["CITY"].Value;
oBuyer.State = xmlContact.Attributes["STATE"].Value;
oBuyer.Zip = xmlContact.Attributes["ZIPCODE"].Value;
oBuyer.IndivName1CurrentWork = xmlContact.Attributes["PHONE"].Value;
oBuyer.IndivName1CurrentFax = xmlContact.Attributes["FAX"].Value;
oBuyer.IndivName1CurrentEmail = xmlContact.Attributes["EMAIL"].Value



if (bNextSpouse == true)
{
try
{
bNextSpouse = false;
IBuyer oBuyer = order.Buyer[order.Buyer.Count - 1];
oBuyer.IndivName2First = xmlContact.Attributes["FIRSTNAME"].Value;
oBuyer.IndivName2Last = xmlContact.Attributes["LASTNAME"].Value;
oBuyer.IndivName2Middle = xmlContact.Attributes["MIDDLENAME"].Value;

oBuyer.IndivName2CurrentWork = xmlContact.Attributes["PHONE"].Value;
oBuyer.IndivName2CurrentFax = xmlContact.Attributes["FAX"].Value;
oBuyer.IndivName2CurrentEmail = xmlContact.Attributes["EMAIL"].Value;
}
Thanks

Sanjay
Hadi Chemaly

Re: SPS API - Creating New Orders with Joint Buyers/Seller

Post by Hadi Chemaly »

Sanjay,

Using shortcut properties such as "IndivName1First" seems to expose a flaw in our current API. As a workaround, try using the "BuyerSellerPerson" collection off of the IBuyer object:

Code: Select all

IBuyer buyer = order.Buyer.CreateNew();
buyer.BuyerSellerPerson[0].FirstName = ...
buyer.BuyerSellerPerson[0].LastName = ...
...
buyer.BuyerSellerPerson[1].FirstName = ...
buyer.BuyerSellerPerson[1].LastName = ...
Thanks for reporting this to us. I will log a bug against it for our next release.
sanjay.mittal
Posts: 94
Joined: Mon Dec 28, 2009 3:43 pm

Re: SPS API - Creating New Orders with Joint Buyers/Seller

Post by sanjay.mittal »

Thanks Hadi,

Actually setting the value in of BuyerSellerPerson[0] property works fine to save the values in the first name and the last name, but it doesn't autopopulate the same value to the "Name" field. So it doesn't display the Joint first name and last name on the Exprss Order Entry Screen. What do I need to do to persist the values in the "Name" field?

Regards,

Sanjay
Phil Barton
Posts: 54
Joined: Wed Sep 24, 2008 2:37 pm
Location: Raleigh, NC
Contact:

Re: SPS API - Creating New Orders with Joint Buyers/Seller

Post by Phil Barton »

Sanjay,

The "Name" property on the IBuyer is automatically populated through business rules unless there exists a user-entered value within that property. The following code populates the people of a joint buyer. It properly updates the "Name" property of the IBuyer and appears properly on the Express Order Entry screen in Select:

Code: Select all

                    IBuyer buyer = order.Buyer.CreateNew();

                    buyer.Type = @"Joint";
                    buyer.BuyerSellerPerson[0].FirstName = @"First1";
                    buyer.BuyerSellerPerson[0].LastName = @"Last1";
                    buyer.BuyerSellerPerson[1].FirstName = @"First2";
                    buyer.BuyerSellerPerson[1].LastName = @"Last2";

                    Assert.AreEqual(buyer.Name, @"First1 Last1 and First2 Last2", @"The buyer name is not correct");
NOTE: The Assert.AreEqual(...) method is part of the NUnit framework.
Phil Barton
Software Architect
SoftPro
Post Reply