Use Dynamics GP Lookups Using VS Toolkit

While searching for performing such operation, I have created a small sample that worked perfectly!!

This method uses Form.Open method to load lookup form and AddHandlers to handle the selection events, below steps I used to fulfill this request, in the example below, I am developing a customer and vendor statements for one of my clients:

1. Create the form that will load the lookup, the form will look like the below:

image

2. Add the needed form to the Customer Maintenance form as a menu:

image

This could be done by adding the following lines of code in the AddIns file under “Sub Initialize()”:

‘Customer Statement
Dim CustomerStatementMenu As New System.EventHandler(AddressOf CustomerStatement_Menu)
Dynamics.Forms.RmCustomerMaintenance.AddMenuHandler(CustomerStatementMenu, “Customer Statement”)

3. We need add handler to the “Select Button” on the customer lookup form just below the above lines:

‘Customer Lookup
AddHandler Dynamics.Forms.CustomerLookup.CustomerLookup.SelectButton.ClickBeforeOriginal, AddressOf CustomerLookup_Handler

4. Handling the menu item for customer will call Customer Statement Menu sub as the below, make sure to define the customer statement form public to get the access later on:

Dim CustomerStatementForm As New CustomerStatement

Private Sub CustomerStatement_Menu(ByVal sender As Object, ByVal e As System.EventArgs)
    CustomerStatementForm.Show()
End Sub

5. Now we will need to handle the Select button event to get the selected customer, we’ll need to add two global variables, one as a Boolean to make sure that the lookup called by our application called “CalledByApplication” and the other to specify from where the lookup called and where to return the result –From or To-:

Private Sub CustomerLookup_Handler(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
     If CalledByApplication Then
         If CalledBy = “From” Then
             CustomerStatementForm.CustomerFrom.Text = Dynamics.Forms.CustomerLookup.CustomerLookup.CustomerNumber.Value
         ElseIf CalledBy = “To” Then
             CustomerStatementForm.CustomerTo.Text = Dynamics.Forms.CustomerLookup.CustomerLookup.CustomerNumber.Value
         End If

         CalledByApplication = False
         CalledBy = “”
     End If
End Sub

6. Now in our form at the lookup button event, add the following lines of code:

CalledByApplication = True
CalledBy = “From”
Dynamics.Forms.CustomerLookup.CustomerLookup.Open()

Viola, your application will call the GP lookup! Hope that helps.

Regards,

Mohammad R. Daoud – CTO
MVP, MCP, MCBMSP, MCTS, MCBMSS
+962 – 79 – 999 65 85 
mohdaoud@gmail.com
mohdaoud.blogspot.com

Advertisements

About Mohammad R. Daoud
Mohammad R. Daoud has been working as a Microsoft Dynamics GP consultant since 2004. His career path started with version 7.5; he studied every single tip of the application technicalities and did allot of successful implementations that includes functional consultations, analysis, and custom development projects. He holds a graduate degree in Computer Science and currently he is pursuing MBA degree in Accounting. In January 2007 he was nominated to the Microsoft Most Valuable Professional (MVP) certificate and was certified in April 2008 due to his online contributions in the Dynamics Community (Dynamics GP Newsgroups, Forums, User Groups and his blog: http://mohdaoud.blogspot.com). Worth to mention that he was also listed as one of the Microsoft Dynamics Top 100 Most Influential People in 2009 by DynamicsWorld. And more... • Demonstrated Passion for MS Products through participating in beta testing for some product versions, an effective member of Microsoft Connect. • Talented in securing strong high quality relationships with premier customers, partners and sales teams passionately and profitably. • Dedicated to meeting the expectations and requirements of internal and/or external customers • Problem Solver – Uses systematic approach to uncover true problem(s) and practical solution and can marshal resources to solve problem! • Proven record of effective account management, including Account Planning, Opportunity Management, and Business Management Excellence and working as part of a larger virtual team • Successful in delivering high quality technical engagements in the enterprise Dynamics GP implementations area according to customer requirements. • Dedicated, Committed, Self Motivated, Creative and highly focused with excellent communication, Negotiation, presentation, Active Listening and Objection Handling skills. • Experienced in Profitable researches and studies including white papers and technical presentations.

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

%d bloggers like this: