nav-left cat-right

Setting default values in GP Windows

Sometimes, we need to enter a value in textbox or check on a checkbox every time (or most of the times) we use a window. Sometimes, we want to set a default value in a field to avoid users accidentally missing it.

In this post, I am going to discuss following options that  you can use to set default values in GP windows.

1.  VBA

2. VS Tools

3. Extenders

4. Support Debugging Tool

I am going to use the Paid Transaction Removal Window as an example. I will discuss options to check off the “Checks” checkbox in this window, so that checks are not automatically selected for transaction removal. I want the user to select the “Checks” options specifically, if they actually want to remove checks.



1. VBA: If you have license for site modifier, you can write couple of lines of code to set the default values.

First of all, you will need to add the Window and Fields to Visual Basic Editor using the “Add Current Window to Visual Basic” and “Add Fields to Visual Basic” Options from Tools>> Customize menu of the window you want to modify.


Then, you can easily write code on window AfterOpen event to set the value of the field

Private Sub Window_AfterOpen()
Remove.Value = False

Me.Changed = false

End Sub

Here, Remove is the name “Checks” checkbox (named remove in VBA since it is part of the Remove section ) in Paid Transaction Removal Window.


a. VBA code needs to be deployed on each client workstation.

b. It will work in all companies. If you want to use it specific company only, you can apply check for the company name.

2. VS Tools: You can write the code similar to VBA using the VS tools as well

static RmPaidTransactionRemovalForm.RmPaidTransactionRemovalWindow rmWindow;


rmWindow = Dynamics.Forms.RmPaidTransactionRemoval.RmPaidTransactionRemoval;

rmWindow.OpenAfterOriginal += new EventHandler(rmWindow_OpenAfterOriginal);

Handle the event

void rmWindow_OpenAfterOriginal(object sender, EventArgs e)


rmWindow.LocalChecksCb.Value = false;

rmWindow.IsChanged = false;


You can deploy the add-in on all client machines. You don’t need a site modifier license for using the VS Tools

3. Extender: Using extender with macro is pretty simple. If you have license for Extender, you can link a macro with window events. Record a macro to set the default values in the window. Don’t include the step to open window in the macro. Add an extender macro using the Microsoft Dynamics GP>> Tools>> Extender>> Macros, click New. Enter the Macro ID and description

Enter the path of macro you created for setting default values.

In Attach Type select “Window Open” to automatically run the macro when the window is opened.

Select the Form and Window with which you want to attach the macro.

The macro extender works on all client workstation. You don’t need to deploy it separately on client workstations. You can enter a shared location in macro path to ensure macro runs successfully on all workstations

4. Support Debugging Tool: You can use the Triggers in Support Debugging Tool to write simple code to set default vale in the window.

Open the Support Debugging Tool Setup window from Microsoft Dynamics GP>>Tools>> Support Debugging Tool >> Options Button >> Setup Automatic Debugger Mode

Enter the Trigger ID and Description.

Select “Focus Event” in Trigger Type and “Window Pre” in Trigger Event

Enter the Form and Window name with which you want to set the trigger. You can also use the Lookup button next to Form Name to select the Form and Window

You can write the code to set the Script section to set the default value.

out boolean OUT_Condition;

OUT_Condition = false;

if isopen(form RM_Paid_Transaction_Removal) then

OUT_Condition = true;

‘(L) Checks CB’ of window ‘RM_Paid_Transaction_Removal’ of form ‘RM_Paid_Transaction_Removal’= false;

end if;

Most of the code is automatically generated. You just need to write the Code for setting the default value in the IF section. In above example I just wrote one line code

‘(L) Checks CB’ of window ‘RM_Paid_Transaction_Removal’ of form ‘RM_Paid_Transaction_Removal’= false;

Refer to following blog article for further details about creating trigger in Support Debugging Tool

To enable the trigger every time GP is started check on Start Trigger Automatically on login

The advantage of using the trigger is you can specify the users and companies for which you want to enable the trigger. Isn’t that fantastic!!!  Click the Users button on top section and select the users and comp

Download links and other information related to Support Debugging Tool is available at


For windows involving key fields, you might need to value changed event instead of window open.


11 Responses to “Setting default values in GP Windows”

  1. Tina says:

    Very helpful!!

  2. Hi Rubal

    This a great article.

    The only thing that I would add is that for the VBA method, you need to add the line

    Me.Changed = false

    To reset the window’s change flag back to false.

    Also, worth mention that the Support Debugging Tool Portal is located at

    Developing for Dynamics GP

  3. Rubal says:

    Great to see you here, am a big fan ! I have updated the post with your note.
    Thank you

  4. Raouf says:

    Great post. I wounder how can I get the current company ID so I can apply different codes to different companies.

  5. Eva says:

    Hi Rubal,

    Just wanting to confirm, apart from VBA, are all the other tools mentioned above work with the GP2013 Web Client?


  6. Eva says:

    Hi Rubal,

    Just wanting to confirm, apart from VBA, will all the other tools mentioned above work with the GP2013 Web Client?


  7. Rubal says:

    Hi Eva,
    Yes, Apart vba, other tools will work with GP2013 Web Client.
    Please refer to following post for further details:

  8. Mike says:

    Hi Rubal,

    First off thanks for a great article! I am trying to use vba in GP to do something very similar to your first example but am having problems. I am trying to force the GL Account Maintenance window in GP to always mark the “Inactive” checkbox when adding new records only.

    I have been able to use code similar to your example to successfully check the checkbox upon opening the window, but I am not familiar with a way in GP to first validate whether the record being added is a new record or an existing record. Do you know if a way to accomplish this?

    My goal is to create a quasi-approval process by forcing new account additions to be “Inactive” accounts only. Then use Field Level Security to ensure that only certain users can change that field and activate the account.

    Other suggestions to solve the bigger problem are also welcome if something comes to mind outside of VBA.


Leave a Reply