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)