Page 1 of 1

Automatically set "My Screens"

Posted: Thu Jan 22, 2015 6:57 pm
by mlevi
We'd like to implement code that once an order is opened, if certain criteria (based on order data) are met, the code should set the Screen to display for that order.

Do shell packages have the ability to automatically set the "My Screen"?

Thanks

Re: Automatically set "My Screens"

Posted: Tue Feb 10, 2015 12:35 pm
by Pradeepa
You can open a screen by doing something like this:

Code: Select all

SelectServer sps = GetService<SelectServer>();
IShell shell = GetService<IShell>();

IOrderStore orderStore = sps.GetService<IOrderStore>();
IOrderInfo oi = orderStore.Orders.Where(o => o.Number == "2015020001").FirstOrDefault();

Uri orderUri = new Uri(string.Format(String.Format("{0}://./{1}?id={2}#target={3}&name={4}&contextid={5}", "sp-select", "ordertracking/order", oi.Identifier.Guid, "Screen", "SPExpressOrderEntry", oi.Identifier.Guid)));
shell.OpenStandardEditor(new OrderUri(orderUri, OrderKind.Order));
Just use the appropriate order number and replace "SPExpressOrderEntry" with the name of the screen you want to open.

Re: Automatically set "My Screens"

Posted: Tue Feb 10, 2015 7:00 pm
by mlevi
Thank you.

Just to clarify, we trying to do something different. When an order is open in the GUI, the ribbon has a button that says "My Screens". A user can go ahead, click that button which brings up a dialog to select a new screen, and once the user clicks "OK", the document layout changes according to that screen selection.

Can that be done programmatically from a shell package?

Re: Automatically set "My Screens"

Posted: Wed Feb 11, 2015 11:50 am
by Pradeepa
Yes. Just pass in the required screen layout in the code below.

Code: Select all

ISecurityManager secMgr = sps.GetService<ISecurityManager>();
ISecurityUser user = secMgr.GetUser(sps.AuthenticatedUserID);
IScreenManager screenMgr = sps.GetService<IScreenManager>();

List<IScreenLayoutInfo> screenLayoutInfos = screenMgr.ScreenLayouts.AssociatedTo(user).ToList();
screenMgr.ChangeCurrentUserDefaultScreenLayout(screenLayoutInfos[0].ID);
I hope this answers your question!

Re: Automatically set "My Screens"

Posted: Wed Feb 11, 2015 4:14 pm
by mlevi
Yes it does. Thank you very much.

Can this be executed on a per order tab basis? We really want to set the layout based on some order data once a user opens a order. Is that possible at all?

Right now we are using the IWindowManager.ActiveDocumentChanged event to examine the order data, and then running the code provided. It appears to set the default screen, but not reset the layout of the tab that has been opened.

Is it possible to reset the layout of the opened tab at that point?

Re: Automatically set "My Screens"

Posted: Thu Feb 12, 2015 11:30 am
by Pradeepa
We don't support this currently, but will log a suggestion for future release.

Re: Automatically set "My Screens"

Posted: Fri Feb 13, 2015 10:57 am
by mlevi
Ok, thanks so much for your help.