Force profile based on order

Discussions related to SoftPro Select user interface development.

Moderator: Phil Barton

Post Reply
mlevi
Posts: 53
Joined: Mon Dec 01, 2014 2:33 pm

Force profile based on order

Post by mlevi »

We'd like to have our shell package check at the time that a user opens an order, and based on various criteria, force that user into a specific profile. We're having a couple of issues.

1. How can we detect from a shell package when an order is being opened?
2. How to examine the order details, to determine whether the criteria are met for forcing a particular profile?
3. How to set the current profile for the shell?

Thanks
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Force profile based on order

Post by BobRichards »

You must be very careful with your approach. I would review the SDK topic on the Active Profiles. If the user creates an order, the order's Owning Profile will be the one the user has when they press the "New Order" button. The active profile determines what orders the user can search for and which orders can be opened. Typically, changing the Active Profile is something the user does by clicking on the bottom right corner of Select (where it says Current Profile).

Perhaps I could be of more help if I knew your specific use case.

1. How can we detect from a shell package when an order is being opened?

You can subscribe to the IRunningDocumentsManager2.DocumentOpened event to determine when an order is opened by a user in the Select Client application. You can determine an order/template was opened and its name - but not much else. The order data is not available to you at this point. The order has already been created and the Order Ownership Profile is set the the user's current profile.

2. How to examine the order details, to determine whether the criteria are met for forcing a particular profile?

To determine the order that the Select Client user is modifying (since the user could have multiple orders open), subscribe to the IWindowManager.ActiveDocumentChanged event. As the user moves between orders, you can use this to examine the current order. See the SDK topic "Cookbook -> Shell Packages -> How do I get the Active Order" for an example of getting the order in the event implementation.

3. How to set the current profile for the shell?

This code will change the Active Profile.

Code: Select all

// Get profile manager.
SelectServer ss = GetService<SelectServer>();
IProfileManager profileMgr = ss.GetService<IProfileManager>();

// Lookup desired profile.  If it exists, make it the active one.
IProfileInfo info = profileMgr.Profiles.Where(t => t.Path == "Default\\A").FirstOrDefault();
if (info != null)
{
	profileMgr.ActiveProfile = profileMgr.GetProfile(info.ID);
}
Bob Richards, Senior Software Developer, SoftPro
mlevi
Posts: 53
Joined: Mon Dec 01, 2014 2:33 pm

Re: Force profile based on order

Post by mlevi »

Thanks for the quick response.

As per your advice, we will rethink our approach with regard to forcibly setting the active profile.

The answer to point 2 is exactly what we were looking for.

We did read the SDK topic "Cookbook -> Shell Packages -> How do I get the Active Order", however the article doesn't clarify where that code will go. We tried running that code from the IRunningDocumentsManager2.DocumentOpened event, but that gave us the previous document, not the document that the user is attempting to open. Perhaps that article can clarify what events will pick up the order that the user is navigating to, as that will probably save other developers lots of time.

Appreciate all the help,

Thanks
kwesterlage
Posts: 73
Joined: Thu May 21, 2015 2:28 pm

Re: Force profile based on order

Post by kwesterlage »

This approach works for the Shell, is there a way to do this same thing in a server package?
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Force profile based on order

Post by BobRichards »

If you mean, "How do I change the user's profile from a Server Package based on the active document?", I am not aware of any way to do it. The server has no way of knowing what the active document is - or even if there is one.
Bob Richards, Senior Software Developer, SoftPro
Post Reply