SQL Script To Set Budget Transaction History To Be Kept In All Companies

Microsoft Dynamics GPWe recently upgraded a client with well over a hundred companies from Microsoft Dynamics GP 10 to GP 2015; one of the new pieces of functionality they wanted to start using was the Budget Transactions.

One problem is that the keep history checkbox for Budget Transactions in General Ledger Setup (Financials » Setup » General Ledger) is unmarked.

Enabling it for this many companies was going to take a substantial amount of time (even if we generated a macro to do this in automatically) as the client has over 120 companies in Dynamics GP. It is a simple setting in one table which needs to be updated, so instead of using a macro I created a SQL script containing a cursor to loop through all of the databases attached to the system database and enable this setting.

As with all scripts which change data, please make sure you have a good backup of your database (or in this case all of your company databases) before running the script.

DECLARE @IntercompanyID VARCHAR(5)
DECLARE @SQLStatement AS VARCHAR(2000)

DECLARE
	cursor_InterID CURSOR 
FOR 
	SELECT
		INTERID
	FROM
		DYNAMICS..SY01500
	INNER JOIN
		master..sysdatabases
	ON
		name = INTERID
	
	OPEN cursor_InterID

	FETCH NEXT FROM
		cursor_InterID
	INTO
		@IntercompanyID
	WHILE (@@FETCH_STATUS <> -1)
		BEGIN
		IF (@@FETCH_STATUS <> -2)
			SET @SQLStatement = 'UPDATE ' + @IntercompanyID + '..GL40000
								SET KPBUDTRXHIST = 1
								WHERE KPBUDTRXHIST = 0'
			EXEC (@SQLStatement)
			FETCH NEXT FROM
				cursor_InterID
			INTO
				@IntercompanyID
		END
	CLOSE cursor_InterID
DEALLOCATE cursor_InterID

You will need to amend the script if your System Database is not called DYNAMICS.

SQL View For Remittance Enabled

Microsoft Dynamics GPWant an easy way to see which vendors are configured for remittances to be emailed? Plug this view into SmartList Designer, or SmartList Builder, and you’ll have that easy way.

CREATE VIEW uv_AZRCRV_VendorRemittanceEnabled AS
SELECT 
	EmailCardID AS VENDORID
	,CASE WHEN EmailDocumentEnabled = 1 THEN 'Yes' ELSE 'No' END AS 'Remittance Enabled'
 FROM 
	SY04905
WHERE
	EmailSeriesID = 4
AND
	MODULE1 = 19
AND	
	EmailDocumentID = 6
GO

GRANT SELECT ON uv_AZRCRV_VendorRemittanceEnabled TO DYNGRP
GO

SQL View For Vendor Email Addresses

Microsoft Dynamics GPI produced this view to return vendor email address for a client a while ago; I don’t typically use this view by itself, but instead combine it with GP tables to produce a larger SmartList report using either SmartList Designer or SmartList Builder.


CREATE VIEW uv_AZRCRV_VendorInternetAddresses
AS
SELECT
	['Internet Addresses'].Master_ID AS 'Vendor ID'
	,['Internet Addresses'].ADRSCODE AS 'Address Code'
	,['Internet Addresses'].EmailToAddress AS 'Email To Address'
	,['Internet Addresses'].EmailCcAddress AS 'Email Cc Address'
	,['Internet Addresses'].EmailBccAddress AS 'Email Bcc Address'
	,['Internet Addresses'].INET1 AS 'Email'
FROM
	SY01200 AS ['Internet Addresses']
WHERE
	['Internet Addresses'].Master_Type = 'VEN'
GO

GRANT SELECT ON uv_AZRCRV_VendorInternetAddresses TO DYNGRP
GO

SQL View For Customer Item Link From SOP Transaction Line

Microsoft Dynamics GPThis one came up from a query a client had about linking a sales order transaction line to the customer item in SmartList Builder. The problem is that to join two tables together, you need all of the key fields to be on the same table; unfortunately, with the SOP Transaction table, this isn’t the case when you want to link to the customer item.

SOP10100 (Sales Transaction Work) holds the CUSTNMBR (Customer Number), but SOP10200 (Sales Transaction Amounts Work) holds the ITEMNMBR (Item Number) which are both needed to link to SOP60300 (Sales Customer Item Cross Reference) which holds the customer item number and description.

While there may be a way to do this in SmartList Builder I’ve not been able to work it out (other than using two calculated fields), it is easier, quicker and more reusable, to create a simple SQL View which returns the relevant information.

In this case the view I created works only for transactions which are at a status of work:

CREATE VIEW uv_PI_SOPCustomerItemLink
AS
	SELECT
		SOP101.CUSTNMBR
		,SOP102.ITEMNMBR
		,SOP603.CUSTITEMNMBR
		,SOP603.CUSTITEMDESC
	FROM
		SOP10200 AS SOP102
	INNER JOIN
		SOP10100 AS SOP101
			ON SOP101.SOPNUMBE = SOP102.SOPNUMBE
				AND SOP101.SOPOwner = SOP102.SOPOwner
	INNER JOIN
		SOP60300 AS SOP603
			ON SOP603.CUSTNMBR = SOP101.CUSTNMBR
				AND SOP603.ITEMNMBR = SOP102.ITEMNMBR
GO

GRANT SELECT ON uv_PI_SOPCustomerItemLink TO DYNGRP
GO

The SQL above includes the Grant statement used to add select permissions for the DYNGRP.

My MVP Renewed for 2015 and David Musgrave Awarded

Microsoft MVPWell, I received the notification email yesterday afternoon that I had been awarded the Microsoft Most Valuable Professional award for the third year running. It’s really niec to receive the award as it shows I am still contributing in a meaningful way to the Dynamics GP community.

There was another new MVP for Dynamics GP added to the roster this month as well; David Musgrave. Previously David was ineligible for the award as he worked directly for Microsoft, but as of October last year he has been independent again and running Winthrop Development Consultants (the company responsible for GP Power Tools, formerly known as the Support Debugging Tool).

David has always been a great contributor to the Dynamics GP community and I’m delighted to see that this has been officially recognised by Microsoft with his MVP award.

Insert Inventory User Categories From CSV

Microsoft Dynamics GPI have had this script for quite a while and have used it a number of times for different clients when implementing the Inventory Control module in Microsoft Dynamics GP.

One client who was using Inventory was entering a lot of user categories, mistakenly entered the description into the Image field. In that case I did not know that they were populating the User Categories or I would have offered this script to them to save time.

To use the script you need a CSV file with four columns: User Category Value (the ID of the item you want to load), User Category Number (which of the user categories into which the row is to be loaded), Image URL and Description:

CREATE TABLE #UploadData
	(USCATVAL VARCHAR(100)
	,USCATNUM VARCHAR(1)
	,Image_URL VARCHAR(300)
	,UserCatLongDescr VARCHAR(300))
GO

BULK INSERT
	#UploadData
FROM
	'c:\temp\UserCategories.csv'
WITH
	(FIELDTERMINATOR = ','
	,ROWTERMINATOR = '\n')
GO

INSERT INTO IV40600
	(USCATVAL
	,USCATNUM
	,Image_URL
	,UserCatLongDescr)
	
	(SELECT
		LEFT(UD.USCATVAL, 10)
		,LEFT(UD.USCATNUM, 1)
		,LEFT(UD.Image_URL, 254)
		,LEFT(UD.UserCatLongDescr, 254)
	FROM
		#UploadData AS UD
	WHERE (SELECT
			COUNT(IV.USCATVAL)
		FROM
			IV40600 AS IV
		WHERE
			IV.USCATVAL = UD.USCATVAL
		AND
			IV.USCATNUM = UD.USCATNUM) = 0)
GO

DROP TABLE #UploadData
GO

You will need to change the highlighted line to the location of your CSV file. As always before running a script on live, test it in a test company first and have a good backup of your database.

hMailServer: Connecting Outlook

Microsoft Dynamics GPOver the last three posts, I have shown how to install and configure hMailServer for use so it can be used to send emails for Microsoft Dynamics GP’s Workflow 2.0 module. in this, the final post in the series I’m going to show how to configure one of the created email accounts in Microsoft Outlook.

To create the new account, click the File tab and then on the + Add Account button:

Account Information

Continue reading “hMailServer: Connecting Outlook”

hMailServer: hMailServer Administrator Configuration

Microsoft Dynamics GPIf you followed the last post you should have the Connect window on screen. If not start the hMailServer Administrator from the start menu.

Select the server you want to connect to and click Connect

Connect

Continue reading “hMailServer: hMailServer Administrator Configuration”

hMailServer: Database Configuration

Microsoft Dynamics GPIn the last post I showed the installation of hMailServer; in this one I’m going to cover the database setup.

If you followed the last post you should have the hMailServer password window on screen. If not start the hMailServer Database Setup utility from the start menu.

Enter the admin password configured during the installation and click OK:

hMailServer password

on the Welcome step, click Next:

hMailServer Database Setup - Step 1 of 7: Welcome

Choose the database server Owner; as I am installing this on a Dynamics GP test system which has a full SQL Server installation, I have selected the Use external database engine (MSSQL, MySQL or PostgreSQL) radion button. Click Next:

Setup - hMailServer: Select database server Owner

This is a new installation of hMailServer so leave the Create a new hMailServer database and click Next:

hMailServer Database Setup - Step 2 of 7: Select option

Leave the Microsoft SQL Server option selected and click Next:

hMailServer Database Setup - Step 3 of 7: Select database server Owner

Enter the Database server address (this can be either the Server Name or IP Adress), enter a Database name and choose your Authentication method.

During an installation, I typically select Use server authentication and enter the sa username and password. I do this to ensure the user I am using has all of the necessary permissions to create a database and all objects.

Click Next to proceed:

hMailServer Database Setup - Step 4 of 7: Enter sever connection information

You can then configure the hMailServer service dependency if the mail server is the same machine as the SQL Server (which in this example it is not).

Click NMext to proceed:

hMailServer Database Setup - Step 5 of 7: Set hMailServer service dependency

On the Finish stage, click Next to start the installation:

hMailServer Database Setup - Step 6 of 7: Finish

Once the installation is complete, click Close:

hMailServer Database Setup - Step 7 of 7: Completed

A final step allowing the hMailServer to be run will be displayed:

Setup - hMailServer Database Setup: Completing the hMailServer Setup Wizard

I’ll be covering the hMailServer Administrator in the next post in this series.

hMailServer: Installation

Microsoft Dynamics GPhMailServer is a small, lightweight mail server with POP3 and SMTP. I have been using it for a while on test or demo systems where I either don’t have access to the company Exchange server or don’t want to use it as the demo system may not be connected to the company network when I am out of the office.

To install hMailServer, download and run the installer.

On the Welcome step, click Next:

Setup - hMailServer: Welcome to the hMailServer Setup Wizard

Continue reading “hMailServer: Installation”