Customising the Company Login window series Part 3 – Dexterity

David Meego - Click for blog homepageThis is a reposting of an article I originally wrote on my Developing for Dynamics GP blog.

GP Power Tools – Administrator Tools Module can provide this functionality without needing customizations. (http://WinthropDC.com/GPPT)

Following on from my previous posts: Customising the Company Login window series Part 1 – Introduction and Customising the Company Login window series Part 2 – Visual Basic for Applications, here is the method to create a solution using Dexterity.

As discussed in the earlier posts, the problem we are trying to overcome is that the company drop down list on the Company Login window is not wide enough to show a long company name. This can make it difficult to select the correct company when the company names are long and differ only by some characters at the end of the name.

Below is a screenshot of the original window from Microsoft Dynamics GP 2013.

 

Following are the step by step instructions on how to use Dexterity code to “modify” the window:

  1. Open a clean Dynamics.dic in your development environment. If you have not set up a development environment have a look at the Knowledge Base (KB) article I wrote on the topic:
    How to set up the development environment when you use Dexterity in Microsoft Dynamics GP (KB 949622)
  2. Create a Workset to keep all the changes you have made grouped together. I called mine “Company Login”.
  3. While in the workset, create the MBS_Switch_Company_PRE global procedure (using script below), then click Compile and Close. Creating the resource while you are in the workset automatically adds the script to the workset.
  4. Now create the Startup global procedure (using script below), then click Compile and Close. The global procedure Startup is a special script name which is executed when the Dexterity runtime starts and the dictionaries are first loaded. It runs before any other script and before any form is opened. Its purpose is to be used to register triggers on the desired events within Dynamics.Note: you cannot access any SQL data from the Startup script as the client has not yet logged into SQL Server.
  5. From the menus select Debug >> Test (or press Ctrl-T) and login. You should now see that the Company Login window has been changed. Press Ctrl-T to return to the development mode.
  6. You can now create a chunk file of the customisation using the Product ID provided by Microsoft. For more information on creating chunk files and Product IDs see the KB articles I wrote below:
    How to create a chunk file in Dexterity in Microsoft Dynamics GP (KB 894700)
    Description of product IDs for Dexterity in Microsoft Dynamics GP (KB 914899)
  7. The resulting chunk file can now be deployed into live environment and included on next login.

 

Here is a screen shot of the window with the full 230 pixel adjustment:

 

Below is the code used:

MBS_Switch_Company_PRE Global Procedure Code

local integer l_adjust, h_pos, v_pos, h_size, v_size;
default form to 'Switch Company';
default window to 'Switch Company';
l_adjust = 230;
Field_GetPosition('(L) Company Names', h_pos, v_pos);
Field_GetSize('(L) Company Names', h_size, v_size);
move field '(L) Company Names' to h_pos - l_adjust, -1;
resize field '(L) Company Names' to h_size + l_adjust, -1;
move field '(L) RememberMe' to h_pos - l_adjust, -1;
resize field '(L) RememberMe' to h_size + l_adjust, -1;
move field '(L) SQL Server' to h_pos - l_adjust, -1;
resize field '(L) SQL Server' to h_size + l_adjust, -1;
move field 'User ID' to h_pos - l_adjust, -1;
resize field 'User ID' to h_size + l_adjust, -1;
move field '(L) Number of Users In' to h_pos - l_adjust, -1;
{resize field '(L) Number of Users In' to h_size + l_adjust, -1;
}
move field 'Max Number User In System'[1] to h_pos - l_adjust, -1;
{resize field 'Max Number User In System'[1] to h_size + l_adjust, -1;
}

Note: This code only reads the horizontal position and size once and then reuses those values for all fields, the vertical position and size is left unchanged by using the value of -1 in the move and resize commands.

 

Startup Global Procedure Code

{Turn off the warning for literal strings}
pragma(disable warning LiteralStringUsed);
if Trigger_RegisterFocus(anonymous(form 'Switch Company'),
    TRIGGER_FOCUS_PRE, TRIGGER_AFTER_ORIGINAL, script MBS_Switch_Company_PRE) <> SY_NOERR then
  warning "Switch Company PRE focus trigger registration failed.";
end if;
{Turn the literal string warning back on}
pragma(enable warning LiteralStringUsed);

The Dexterity source file of the scripts for this customisation are attached to the bottom of this article.

 

Hope you find this useful and educational.

David

07-Aug-2014: Updated Startup script to register trigger on FORM_PRE instead of WIN_PRE so that the shifting of the fields does not happen again when the restart form command is issued.

global procedures.zip

This article was originally posted on the Developing for Dynamics GP Blog and has been reposted on http://www.winthropdc.com/blog.

One thought on “Customising the Company Login window series Part 3 – Dexterity

Please post feedback or comments

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.