Copy Posting Report Configuration Between Companies

Microsoft Dynamics GPI wrote the first version of this script a long time ago, but recently had cause to return to it. A client I am working with has configured the posting reports in one company and wanted to copy the same configuration to the other companies.

This script allows you to do this, on a one by one basis. Set the first highlighted parameter to the source company, and the second to the destination company.

/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (https://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
DECLARE @SQLStatement VARCHAR(8000)
DECLARE @SourceCompany VARCHAR(5) = 'T16R2'
DECLARE @DestinationCompany VARCHAR(5) = 'P16R2'

SET @SQLStatement = 'UPDATE
				[''''Destination Posting Journal Destinations'''']
			SET
				PRNTJRNL = [''''Source Posting Journal Destinations''''].PRNTJRNL
				,ASECTMNT = [''''Source Posting Journal Destinations''''].ASECTMNT
				,PRTOPRNT = [''''Source Posting Journal Destinations''''].PRTOPRNT
				,PRTOFLNT = [''''Source Posting Journal Destinations''''].PRTOFLNT
			FROM
				' + @DestinationCompany + '.dbo.SY02200 AS [''''Destination Posting Journal Destinations'''']
			INNER JOIN
				' + @SourceCompany + '.dbo.SY02200 AS [''''Source Posting Journal Destinations''''] ON [''''Source Posting Journal Destinations''''].SERIES = [''''Destination Posting Journal Destinations''''].SERIES
					AND [''''Source Posting Journal Destinations''''].TRXSOURC = [''''Destination Posting Journal Destinations''''].TRXSOURC
					AND [''''Source Posting Journal Destinations''''].PTGRPTNM = [''''Destination Posting Journal Destinations''''].PTGRPTNM'
EXEC (@SQLStatement)

As always with an SQL script, please make sure you have a good backup before running it.