Order numbering, templates, and CreateOrder

Discussions related to custom development with Select.
Post Reply
joe.mag
Posts: 122
Joined: Thu Aug 04, 2011 3:11 pm

Order numbering, templates, and CreateOrder

Post by joe.mag »

I am creating an order via the API and selecting a specific profile that has a corresponding order number format that is unique to that profile. I see the order created in the expected profile but the order numbering used is that of the default profile for the user the API is using to log in, not that of the selected profile.

To provide more detail, the API logs into SPS using credentials that map to a default profile of "Test-Training" which has an order numbering of y"R"SSSSSS"-TEST" as set via the Order Numbering Manager. I then create an OrderCreationSpec object and set the OwningProfileID to a different profile whose ID I've obtained from calls made to the ProfileManagement interface. I also add our main default template to the otherwise empty Templates collection of the spec. When I call CreateOrder and then SaveOrder the order is created in the desired profile but the order numbering is that of the Test-Training profile not that of the profile I looked up.

In my first test I left the BaseOrderNumber of the OrderCreationSpec empty and I got an order number of format y"R"SSSSSS"-TEST". Next I tried a fully-specified BaseOrderNumber just to confirm that that worked and it did. Finally I tried using the actual string 'y"A"SSSSSS' thinking maybe that would undergo the expected substitution but instead I got an exception with error message "The order number y\"A\"SSSSSS contains invalid characters." so obviously substitution is not occurring.

So how do I get a profile's order numbering to apply to an order I'm creating? I cannot imagine I should have to have one login per profile so as to get that login's default profile numbering convention!

Here is the code I'm using (with some simplification so it may not compile):

Code: Select all

                    // get the desired profile
                    ProfileManagement pMgr = server.GetService<ProfileManagement>();
                    string strProfilePath = @"\\Default\Production\ADifferentProfile";
                    IProfile targetProfile = pMgr.FindProfile(strProfilePath);  
              
                    //creating order creation spec
                    var spec = new OrderCreationSpec()
                    {
                        //BaseOrderNumber = "hello",
                        //BaseOrderNumber = "y\"A\"SSSSSS",
                        OwningProfileID = targetProfile.ID
                    };

                    spec.Templates.Clear();
                    spec.Templates.Add("Our default template");

                    // creating order
                    order = ot.CreateOrder(spec);

                    ......

                    ValidationMessage[] messages;
                    ot.SaveOrder(order, out messages)
Randy Mellow

Re: Order numbering, templates, and CreateOrder

Post by Randy Mellow »

I'll have to look into this to see what's happening during the order creation, specifically how the functionality uses the owning profile passed in with the spec.
Randy Mellow

Re: Order numbering, templates, and CreateOrder

Post by Randy Mellow »

If a base order number is not supplied with the spec the code uses the numbering manager associated with the active profile to generate the base order number.

Unfortunately, the order numbering manager is not exposed through the API. Your safest option is, as you suggested, to have a login per profile (actually per order numbering manager).

However, it might be possible to use a custom stored procedure to acquire the GUID of the order numbering manager associated with the profile in question. This would allow you to call the GetNextSequenceNumber stored procedure.
joe.mag
Posts: 122
Joined: Thu Aug 04, 2011 3:11 pm

Re: Order numbering, templates, and CreateOrder

Post by joe.mag »

Randy,

Thanks for the prompt reply. Wow, that's bad news.

I'm no expert on licensing in SoftPro--assuming I don't want to share login credentials with a flesh and blood user i'll need to create eight new users for this functionality due to having 8 different profiles with unique order numbering conventions. Won't that require 8 additional licenses?

Joe
Randy Mellow

Re: Order numbering, templates, and CreateOrder

Post by Randy Mellow »

The licensing in Select 2.6 is handled through the UI which means API access will not use up any licenses. However, this is changing in Select 3.0 so you won't want to rely on that. In 3.0 licenses will be consumed by concurrent users. If your program is only planning on logging in with one user at a time you'll only need one license.
joe.mag
Posts: 122
Joined: Thu Aug 04, 2011 3:11 pm

Re: Order numbering, templates, and CreateOrder

Post by joe.mag »

Thanks again, Randy.

I did want to clarify one matter. I was recently informed that there is a difference, when using the user interface, between the concept of the owning profile for an order and the profile used when creating the order. So the user I spoke to wasn't surprised that the order numbering didn't match the OwningProfileID I specified in the OrderCreationSpec. However, the CurrentProfile property of the SelectServer object I use to log into SPS via the API is read-only. Is there any way to set the current user's profile via the API and would that potentially be the more direct route to achieving my ultimate goal?

TIA
Randy Mellow

Re: Order numbering, templates, and CreateOrder

Post by Randy Mellow »

There is currently no API functionality allowing you to change a user's active profile. When a user logs into Select, their current "default" profile will be their active profile. This can only be changed through the UI and when there are no active orders. Your best bet is to create the different users and set their default profile to match the numbering system they represent.
Post Reply