BuyerSellerType

Discussions related to SoftPro Select user interface development.

Moderator: Phil Barton

Post Reply
bandorganman
Posts: 64
Joined: Tue Mar 03, 2020 5:23 pm

BuyerSellerType

Post by bandorganman »

How is the BuyerSellerType enum entered? I have the following code but it gives a cast error on trying to set the property.

Code: Select all

IOrderItem newby1 = ((IOrder)o).CreateNew("Buyer");
                        contacts.Add(newby1);
                        if (buy.BUYTYPE == "1")
                        {
                            newby1.SetProperty("BuyerSellerType", "Individual"); // This line causes an error.
                            IOrderItem Individual1 = (IOrderItem)newby1.GetProperty("Individual1");
                            Individual1.SetProperty("FirstName", buy.BFIRST1);
                            Individual1.SetProperty("LastName", buy.BLAST1);
                            IOrderItem add = (IOrderItem)Individual1.GetProperty("Address");
                            add.SetProperty("Address1", buy.STREET1);
                            add.SetProperty("City", buy.CITY1);
                            add.SetProperty("State", buy.STATE1);
                            add.SetProperty("Zip", buy.ZIP1);
                            Individual1.SetProperty("Phone", buy.PHONE1);
                            Individual1.SetProperty("SSN", buy.SSN1);
                            sBuyers = buy.BFIRST1 + " " + buy.BLAST1;
BobRichards
Posts: 1150
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: BuyerSellerType

Post by BobRichards »

Open a typical order then open the Field Code Browser (FCB). Now open the Order.Buyers collection, look for the "BuyerSellerType" property. Click on it and you will see the property Type in the bottom panel of the screen. It shows that the type is "BuyerSellerType". If you look up this type in the SoftPro Select SDK Documentation Help (installed when you install the Select SDK and located in Start -> SoftPro Select SDK -> SoftPro Select SDK), you will see the following information.
2021-11-09_13-44-49.png
2021-11-09_13-44-49.png (54.97 KiB) Viewed 374 times
To use it in a COR, you must include the assembly that holds the BuyerSellerType information at the top of the COR file. Then you must set the property to a value that is of type BuyerSellerType (not with a string type as you originally did). You got the error because you were passing a string to the property - not a BuyerSellerType object that it was expecting.

Code: Select all

from SoftPro.OrderTracking.Client.Orders import *
...

newby1.SetProperty("BuyerSellerType", BuyerSellerType.Individual); // This line used to cause an error.
Bob Richards, Senior Software Developer, SoftPro
bandorganman
Posts: 64
Joined: Tue Mar 03, 2020 5:23 pm

Re: BuyerSellerType

Post by bandorganman »

Thanks, that worked. Now, for the same code above, I get an error when trying to enter the state into an address. How do I enter the state? Cannot find the information in the SDK.
BobRichards
Posts: 1150
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: BuyerSellerType

Post by BobRichards »

Unfortunately the SDK will never have all the information. I wish it did. You can search this DevForum for keywords also. You might find clues where others have asked similar or even unrelated questions - the same way you did it in September: HUD Section 1200 See how "search.State" was set by looking up the State abbreviation.

(How did I find it?) Since "state" is too common a word, I looked in the FCB and saw that "state" was of type "IState". When I searched on "IState" in the DevForum, I found multiple examples. As always, it's about figuring out what keyword to search for.
Bob Richards, Senior Software Developer, SoftPro
BobRichards
Posts: 1150
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: BuyerSellerType

Post by BobRichards »

To clarify, if you know the state and want to set an Address object with it, use the example below. First I get the IState object that represents the state you are looking for. In this case I am searching for Texas. Next I get a contact as an example of an object with an Address and set the state.

Code: Select all

// Get IState object.
IEnumManager enumMgr = ss.GetService<IEnumManager>();
IState state = enumMgr.GetEnum<IState>().Values.Where(t => t.Code == "TX").First();

// Get first settlement agent and set the state to TX
IOrderItem settlementAgent = ((IList)order.GetProperty("SettlementAgents"))[0] as IOrderItem;
IOrderItem address = settlementAgent.GetProperty("Address") as IOrderItem;
address.SetProperty("State", state);
Bob Richards, Senior Software Developer, SoftPro
bandorganman
Posts: 64
Joined: Tue Mar 03, 2020 5:23 pm

Re: BuyerSellerType

Post by bandorganman »

Thanks Bob, it took some digging and analyzing but I finally figured that out. I now have a good understanding of how to communicate with the API. Everything seems to have fallen into place and is making sense. I had one other question though and have entered it in a new post.
BobRichards
Posts: 1150
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: BuyerSellerType

Post by BobRichards »

I'm glad to hear it. I really does take a while for the order model to click and make sense.
Bob Richards, Senior Software Developer, SoftPro
Post Reply