OIS300 Sorting Order 8 – Remember the Responsible

This morning I was down in my export staffs office looking in to an issue when I noticed that one staff member was going in to OIS300 (sorting order 8) and entering in their username to the responsible field.

It turns out that they almost exclusively use this specific view AND have to type in their username each time – each and every day, so say at least 220 times per year (4 weeks annual leave, 5 day working week + some extra days off) over the last 9 years!

That just seemed wrong to me. We have the power, we have the technology – let us show the users we care 🙂

A quick twenty minute hack and we have a solution, a little wee script which will set the responsible to the username.

I deploy to a couple of the staff and get their feedback, and they would also like the high status set to 44 (how quickly they become demanding :-)). I also noticed that the initial cut of the script would always set the responsible to their username – so if they changed the responsible and pressed enter, their username would populate the responsible again even though they had the other persons records.

Another quick hack and testing and we have a script that sets the responsible and sets the high status when the username newly enters OIS300. I’m sure there will be some further tweaks to this wee script but it’s certainly made a couple of staff pretty happy.

Anyways, here’s the script – as per usual – well, actually it’s probably a little more verbose than usual – commented extensively:

// OIS300 Default the Responsible to the current user when in sorting order 8
// and set the high status to 44
import System;
import System.Windows;
import System.Windows.Controls;
import MForms;
import Mango.Services;

package MForms.JScript
{
    class OIS300_DefaultResponsible_002
    {
        var gController = null;
        var gstrInstanceCacheName = "OIS300_DefaultResponsible";
        public function Init(element: Object, args: Object, controller : Object, debug : Object)
        {
            var content : Object = controller.RenderEngine.Content;
            gController = controller;

            // how much code can we fit on one line??
            // check the sorting order, username and check to make sure we are entering this for the first time
            // note the instancecache portion, this ensures that we only fire our script
            // when we enter OIS300 Sorting Order 8 once during the lifespan of this instance
            if((null != controller.PanelState) && (false == String.IsNullOrEmpty(controller.PanelState.SortingOrder)) && ("8" == controller.PanelState.SortingOrder) && (false == String.IsNullOrEmpty(ApplicationServices.UserContext.UserName)) && (false == InstanceCache.ContainsKey(gController, gstrInstanceCacheName)))
            {
                // the textbox that we will populate with the users name
                var tbResponsible : TextBox = ScriptUtil.FindChild(content, "W1OBKV");
                // the combobox with the status that we shall change
                var cmbHighOrderStatus : ComboBox = ScriptUtil.FindChild(content, "WTORST");
                if(null != tbResponsible)
                {
                    // set the name of the user to the responsible field
                    tbResponsible.Text = ApplicationServices.UserContext.UserName;
                    // set it so the contents are selected, we do this
                    // so it means they can just start typing to get
                    // rid of their name if they are after another persons orders
                    tbResponsible.SelectAll();
                    // we want to keep track of whether we are a new instance
                    // if not, we don't run (see the if statement earlier)
                    // If we don't do this then each time the user changes the responsible
                    // manually and presses enter, their name will appear in the responsbile
                    InstanceCache.Add(gController, gstrInstanceCacheName, "1");
                    // we want to guarauntee our cache is clear, it should clear when we
                    // close, but...
                    controller.add_Requested(OnRequested);
                    // now we set our high status
                    if(null != cmbHighOrderStatus)
                    {
                        cmbHighOrderStatus.SelectedValue = "44";
                    }
                }
            }
        }

        public function OnRequested(sender: Object, e: RequestEventArgs)
        {
            // we are closing so lets be doubly sure and manually delete our
            // flag saying that we have run
            if( (e.CommandValue == MNEProtocol.KeyF03) || (e.CommandValue == MNEProtocol.KeyF12))
            {
                InstanceCache.Remove(gController, gstrInstanceCacheName);
            }
            // remove the request event subscription
            gController.remove_Requested(OnRequested);
        }
    }
}

This entry was posted in Development, M3 / MoveX. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s