?
Solved

How to expose MS Dynamics GP fields into VS Project

Posted on 2009-12-31
18
Medium Priority
?
1,446 Views
Last Modified: 2013-12-11
I am going to start to develop some VS 2008 projects around MS Dynamics GP 10. Using the Sales Transaction Entry screen (SOP_Entry) how would I pass the value of SOPNUMBE back to my VS project? In may case I have custom software that handles quotes. In my database I have records that tie quotes to orders. I want to expose my quote data to users inside GP w/o having to be in the quote program. So If can grab the value of the order number, I can them pull up information related to the quote from which the order was generated.
0
Comment
Question by:rwheeler23
  • 10
  • 7
18 Comments
 
LVL 11

Expert Comment

by:Patmac951
ID: 26155704
I am not sure if I am missing something here....but within your project define a Global or PUBLIC variable for the SOPNUMBE then query GP and store the SOPNUMBER to the variable you defined.  At that point you should be able to pass that variable to any other code in your project
0
 
LVL 18

Accepted Solution

by:
Steve Endow earned 2000 total points
ID: 26155735
Hi,

If you need a VS windows app to retrieve a value of an open GP window, or even an open data set, you can use Visual Studio Tools for Dynamics GP.

However, VSTools is licensed separately the Dynamics GP Developer's Toolkit, so you would have to have purchased the Developer's Toolkit license to use this method.

Let me know if you have the toolkit license and I can help you with the code to do what you need.

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional

0
 

Author Comment

by:rwheeler23
ID: 26155848
We are a GP reseller and have been issued our own license key. I embed that key into the few VS applications I have written. I had just attached a screen to the SOP Entry screen and was wondering how to capture the value of SOP10100.SOPNUMBE. This is not like Dyanmics VBA where I just add the field to the project. The user will be sitting on that screen with an order open. The question is how to I obtain its value?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:Steve Endow
ID: 26156153
Okay, great, understood. I can send you some sample code for accessing a SOP field.

I'm out right now, but will look for it when I get back.

Steve
0
 
LVL 18

Expert Comment

by:Steve Endow
ID: 26156605
Hi,

Just to clarify, you mention you are embedding a license key.  Are you using GPConnNet.dll?

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional



0
 

Author Comment

by:rwheeler23
ID: 26156744
Yes and this is GP 10. The license key is in my connection routine. SP4 of VS SDK Toolkit.
0
 
LVL 18

Expert Comment

by:Steve Endow
ID: 26156963
Hi,

Thanks, that helps clarify things.  

Okay, a little background so that we can discuss what you need to do, and how you want to do it.

First, GPConnNet.dll essentially allows you to create a SQL server connection using the login info of a user that is logged in to GP.  It gives you access to the SQL server and company databases, but does not give you access to the GP windows, fields, or data in the fields of the GP instance.

If you want to access the data on the GP windows, you need to use either VBA or a GP AddIn developed using the VS Tools SDK.

Based on what you described, my understanding is that you want to allow a GP user to click a button from the SOP Transaction Entry window, which then sends the SOP number to your app, so that you can display the quote that relates to that order.

If this is correct, there are several ways to do this, so you'll need to choose which approach that you think makes the most sense.  Personally, I don't think that you will want to use GPConnNet.dll.

Assuming that you want your quote application to be immediately notified when the user clicks the button in GP, here is one approach that I think would work, and would be pretty slick.

1) Use Modifier to add a custom button to the SOP Transaction Entry window (and possibly also the Transaction Inquiry window). Something like "Display Quote", or whatever makes sense.  You will then add that new custom button, the "SOP Type Database" field (a hidden field), and the SOP Number field to VBA.

http://blogs.msdn.com/developingfordynamicsgp/archive/2009/12/11/determine-sop-type-in-sop-entry-using-vba-or-visual-studio-tools.aspx

2) Using .NET, create a COM accessible class library (DLL) that uses the Windows WM_COPYDATA API.  This allows you to send a message and some data from one app to another.  This is a very cool, and simple, feature for passing data between two applications.

http://boycook.wordpress.com/2008/07/29/c-win32-messaging-with-sendmessage-and-wm_copydata/

3) You will use VBA on your custom GP button to instantiate the COM component and call the SendMessage method to your app.  In the message, you can send the company database INTERID, the SOP Type, and SOP Number as a comma delimited string.

4) You will create a new method in your app to accept the message, which can Split() the comma delimited string and use the parameters to perform whatever action you want. (open a window, pull up the appropriate record, etc.)

To the user, all of this will just look like a single button click from the SOP window.

Let me know if this makes sense, and if it sounds like what you would want to do.  If you have any questions on any of the items, just let me know and we can walk through them with code samples, etc.

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional

0
 
LVL 18

Expert Comment

by:Steve Endow
ID: 26157391
Hi,

I found the topic pretty interesting, so I developed some prototypes and created a blog post on the topic.

http://dynamicsgpland.blogspot.com/2010/01/let-lonely-dynamics-gp-talk-to-your.html

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional


0
 

Author Comment

by:rwheeler23
ID: 26158022
You sir are a gentleman and a scholar! Not only do you provide a solution but you provided sample code. I will certainly give this a try. I am curious, right now I have added my form to under the "Additional" option on the SOP_Entry form. I suppose I could add that to my VBA project but the more I think about that the more I am thinking "What's the difference"? I need something on the GP side to push the value into my .Net Application so a button on the SOP_Entry screen makes more sense, One less click for the user.

Thanks for all your help on this. Great blog post! As soon as things settle down from the family New Yera's Eve party I will get right on this.
0
 
LVL 18

Expert Comment

by:Steve Endow
ID: 26158476
Hi,

Yes, I was thinking about whether an AddIn could work, and I think it could, but as you point out, it won't be as integrated as a button for the user.

The AddIn would have been great, as it would be able to directly communicate with your app instead of using COM, but unfortunately we can't yet customize existing GP forms in .NET.  That would be a nice feature!

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional


0
 
LVL 18

Expert Comment

by:Steve Endow
ID: 26158515
Hi,

One downside to this approach that I thought of, and one possible workaround to get the AddIn to work.

Because it uses Modifier & VBA, the client must have either the full Modifier & VBA license, or a customization site license.

A VSTools AddIn does not require the client to have an additional license.

So, what you could do is just assign a shortcut key to your AddIn.  That allows the user to just press a keystroke instead of clicking on the Additional menu.  Your AddIn could then grab the data off of the form and then send it to your app using SendMessage.

If that sounds more appealing, let me know and I'll go back to my original promise to get you sample code for accessing the SOP fields from an AddIn.

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional



0
 

Author Comment

by:rwheeler23
ID: 26158934
This client does have the customization site license as I have about 4 other customization for them. Since we are talking quotes I was going to use the CTRL-Q button on the Additional Menu drop down. If you do not mind adjusting your code that would be most appreciated.
0
 
LVL 18

Expert Comment

by:Steve Endow
ID: 26159272
Hi,

I have updated my blog to include an AddIn project.

http://dynamicsgpland.blogspot.com/2010/01/let-lonely-dynamics-gp-talk-to-your.html

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional



0
 

Author Comment

by:rwheeler23
ID: 26159656
You have been incredibly helpful. I cannot thank you enough. It is a shame you and I have not run into each other before. I have been with GP since the old DOS days and obviously with Dynamics since day one. You are on the west coast and we are on the east. Maybe we will meet up at Converence this year.
0
 

Author Comment

by:rwheeler23
ID: 26173020
Please excuse my ignorance but in reviewing your code I have two questions:
1) You reference an app name called "Receiving App" - Do I need to replace that with the name of my Visual Studio Application?
2) I do not see you connecting to the database anywhere in your code. Is this omitted as an example or is it hiding someplace else.

I have attached my project. As you can see I am just trying to expose the SOPNUMBE on the form that I call. Once I have that I can call another window to display the quote detail. Would be so kind to give this a quick lookover and let me know what I am missing? If you want to turn this into a little billable work that is fine. You have already provided great assistnace.
0
 
LVL 18

Expert Comment

by:Steve Endow
ID: 26173199
Hi,

Not a problem, I slapped those projects together with no documentation, so questions are fine.

Regarding your questions:

1) "Receiving App" is the name of the application window that you want to send the message to.  So my sample "App B" in the "Send and Receive prototype apps" zip file is the receiving app, with the window title of "Receiving App".

You would change that value to the window title of your app, and then add the WndProc procedure to that particular app window.

2) I am not connecting to the GP database at all in my samples.  By retrieving the values from the open GP SOP Trx window, you can access the data that the user is viewing in GP without having to retrieve any data from the database.

I've pasted the relevant lines of code below.  Let me know if this makes sense, and if suits what you are trying to do--or if you need something different.



And I don't see a project or code attachment to your post. Can you try reposting it?  Or if the site won't let you, just let me know and we can transfer it some other way.


Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional




// These Class level variables create a reference to the Sales 
// Transaction Entry form and window so that we can interact 
//with the window and read field values
static SopEntryForm sopEntryForm = Dynamics.Forms.SopEntry;
static SopEntryForm.SopEntryWindow sopEntryWindow = sopEntryForm.SopEntry;


//The following lines of code in the AddIn example are used to 
//retrieve the field values from the open SOP Trx window:

string interID = Dynamics.Globals.IntercompanyId.Value;
int sopType = sopEntryWindow.SopTypeDatabase.Value;
string sopNumber = sopEntryWindow.SopNumber.Value;
string customerID = sopEntryWindow.CustomerNumber.Value;

Open in new window

0
 

Author Comment

by:rwheeler23
ID: 26173566
I sent the file to you via email off your website. This site rejected the zip file.
Just a followup up question. If you look at my here is what I need to:

1) User goes to the SOP Entry screen and selects an order number.
2) User then presses CTRL-Q to bring up my screen.
3) I need that order number so I can call another screen to display the details from which this order came.
In my example you will see I dropped a text field onto the report. Obviously what I did to get the value of SOPNUMBE is incorrect because the field is blank. I think it have somethng to do with the type of event. So I believe the event I am looking for is Load Form or something like that. When I brought up the forms designer and double clicked on the text field it defaulted to change.
0
 
LVL 18

Expert Comment

by:Steve Endow
ID: 26173614
Hi,

You will need to add the WndProc (and all of the code from my App B project) to your app window.

The WndProc procedure (not sure why the guy called it that) is what gets called when the user presses CTRL+Q in GP.

WndProc receives the message sent from GP, and then you can write a simple procedure to retrieve the text and display it and process it.

It is a bit confusing, so if it isn't obvious from looking at my App B code, I'll take a look at your project tonight.

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional



0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Getting data out of MAS90 doesn’t have to be tedious or time consuming.  With any version of Excel using the included Microsoft Query function, you can access just about any data set or combination of data sets stored in your MAS90 MAS200 Software. …
If you need to import sales transactions from another system into Microsoft Dynamics GP as Sales Order Invoices, you may need to store some additional data related to the customer, the transaction, or the line items.  Even if your company is manuall…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question