Developing for Dynamics GP

by David Musgrave (Perth, WA, Australia) and the Microsoft Dynamics GP Developer Support Team (Fargo, ND, USA)

Customising the Company Login window series Part 3 - Dexterity

Customising the Company Login window series Part 3 - Dexterity

Rate This
  • Comments 13

David Meego - Click for blog homepageFollowing 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.

Attachment: global procedures.zip
  • Thanks for the info and code, David!

    Could you do me a favor and please add the error number to warnings in your Startup scripts? When they do not register, it is very helpful to have the specific error info and far too many leave it out.  I know this blog article is only intended as an example, but lots of production code starts out from examples.

    Cheers :)

  • Should this same method work on the login screen?  I tried it and it worked in debug but not when the chunk file was dropped.  Thanks for the code, we have had the issue and really wanted to fix it in Dexterity.

  • Hi Bernie

    This concept should work for the Login window as well. You cannot have an alternate version of the Login or Company Switch windows, so if you made changes to the window layout, they will work in Debug, but not in runtime environment.

    If you use only code in triggers and not modifying the window, it works for runtime.  This is why I have written this series, to highlight the issue and show that code be used to modify a window.

    David

  • Hi Emily

    I know what you are saying, but I rarely have trigger registration issues and when I do, I usually can grab the error from the Dex environment.

    I might just have to start displaying the code, it just means creating another variable and moving the registration to its own line before the if statement. Too many lines.... :-)

    David

  • Posting from Mark Polino on DynamicAccounting.net

    mpolino.com/.../customising-company-login-window-series-part-3-dexterity-developing-dynamics-gp-site-home-msdn-blogs

  • I got it to work.  Somehow I touched the Login form and dexterity thought it was new.  Exported my scripts and started with a clean Dynamics.dic and it works great.  I can think of some other places to us it.  Thanks again.

  • Hi Bernie

    Glad you like the technique.

    Thanks

    David

  • I found one interesting side effect of using this code on the Login screen.  If the user mistypes their password, the trigger fires again and the fields move to the left again.  I put some code in to check for the h_pos > 0.

  • Hi Bernie

    Good find. Try changing the trigger to use the Form Pre event instead of Win Pre.

    Form Pre only fires once and is not called when restart form is issued.

    David

  • Much better.  I just don't think in triggers as much as I should.  Thanks.

  • Hi Bernie

    I have updated the post to use FORM_PRE instead of WIN_PRE. Thanks for letting me know.

    David

  • When will another dexterity class be available. I am just learning and would like to have some training instead of by guess and golly.

  • Hi Kevin

    Hopefully we will have some training at the #reIMAGINE2014 conference in November in Fargo.

    Make sure you check out my article:

    blogs.msdn.com/.../how-to-get-started-with-dexterity.aspx

    David

Page 1 of 1 (13 items)
Comments Information

PLEASE READ BEFORE POSTING

Please only post comments relating to the topic of this page.

If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.

Leave a Comment
  • Please add 8 and 1 and type the answer here:
  • Post