Page 1 of 1

Order Number Prefix Questions

Posted: Wed Nov 20, 2019 3:49 pm
by dlerickson
Hi, we have a scenario in which a Title order needs to be transferred between office branches, and possibly Select profiles. In doing so, the user wants to be able to reset the order number with a different prefix which corresponds to the new profile/area.

1) Is it possible to retrieve a list of the Order Number Prefixes for a given Profile using the API? If so, can you provide a snippet?
2) Is it necessary to also switch the order's Profile if resetting the order number with a new prefix from a different profile?

Thanks.

Re: Order Number Prefix Questions

Posted: Wed Nov 20, 2019 6:13 pm
by BobRichards
1) Is it possible to retrieve a list of the Order Number Prefixes for a given Profile using the API? If so, can you provide a snippet?

You can enumerate the list of Order Numbering groups to find much information.

Code: Select all

var numMgr = ss.GetService<IOrderNumberingManager>();
var group = numMgr.OrderNumberingGroups.Where(t => t.Name == "ANumGrpName").FirstOrDefault();
var prefixes = group.AvailablePrefixes.ToList();
var suffixes = group.AvailableSuffixes.ToList();
var profiles = group.Profiles.ToList();
2) Is it necessary to also switch the order's Profile if resetting the order number with a new prefix from a different profile?

I don't quite understand. Changing the profile for an order will not change the order name.

Re: Order Number Prefix Questions

Posted: Thu Nov 21, 2019 5:45 pm
by dlerickson
OK, that was what I needed. BTW, disregard question 2; it did indeed turn out to be irrelevant.

But now, I have another problem. On the order, the properties "Prefix", "Number", and "BaseNumber" are all read-only for an order that has been created in a previous session. Is there any way of getting around this? Ideally, I'd only need to update the "Number" field.

Re: Order Number Prefix Questions

Posted: Thu Nov 21, 2019 5:51 pm
by BobRichards
Once the order is saved, Select does not maintain it as separate parts (prefix, number, suffix) - just as a string with a maximum of 30 characters. You can rename an order if you wish (assuming it does not conflict with another order) but you have to figure out the prefix/suffix parts on your own.

Re: Order Number Prefix Questions

Posted: Thu Nov 21, 2019 6:05 pm
by dlerickson
I'm a bit confused here - when you say "rename an order," what field are you referring to specifically? I've tried setting the "Number" field, but it's showing as read-only, and any attempts to set it are failing, as expected. Is there another field I should be setting instead?

Re: Order Number Prefix Questions

Posted: Fri Nov 22, 2019 12:00 pm
by dlerickson
OK, I see the "Rename Order" function in the Select client itself, and that's basically the same thing that I'm trying to do programmatically. I'm pulling the prefixes per profile, as this tool seems to be doing, and attempting to reset the "Number" property on the order itself. Is there another way to mimic the "Rename Order" functionality this way?

Re: Order Number Prefix Questions

Posted: Fri Nov 22, 2019 4:33 pm
by BobRichards
The process is to open the order, rename it, then save the new order.

Code: Select all

// Get the orginal order.
IOrderStore os = ss.GetService<IOrderStore>();
IOrderInfo orderInfo = os.Orders.Where(t => t.Number == "OldNumber").First();
using (IOrder order = os.OpenOrder(orderInfo, OrderEditMode.ReadWrite))
{
    // Create a new name for the order.
    var spec = new OrderCreationSpec() { BaseNumber = "NewNumber" };
    
    // Set the new name then save it.
    order.RenameOrder(spec);
    os.ApplyChanges(order);
}

Re: Order Number Prefix Questions

Posted: Fri Mar 29, 2024 11:39 am
by dlerickson
Hey Bob, I found this old thread from a while ago, and now need a good reliable way to get from a specific Profile to the available order prefixes for that Profile via querying the database directly. I've found what seems to be kind of a hacky way to do it, by joining SelectDb.core.NumberingGroup to SelectDb.pf.OrderNumberingGroup, which pairs up the Numbering Group name to the Order Numbering Group's AvailablePrefixes column. I can then pull the Profile with the included LocationState ProfileItem data, and build a string {ProfileItem.Value}-{Profile.Name} to query against that joined Numbering data.

I'd much prefer to do more solid joins via the GUIDs associated with these, for obvious reasons. There doesn't seem to be a reliable dependency path to do this, though. BTW, this is within a web app, and so far, I've tried to avoid pulling in the Select DLLs and using the API and all that extra overhead, hence the need for direct database pulls.

Any insights on this? Thanks.

Re: Order Number Prefix Questions

Posted: Fri Mar 29, 2024 11:46 am
by dlerickson
Update to the last: I just found pf.OrderNumberingGroupView, which already does the join, so would query against this instead of joining the tables manually.