Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GP 9.0 - Integration Manager: Specifying Source Location

Status
Not open for further replies.

oCoder

Programmer
Jul 3, 2007
1
US
Hi all,
I'm having trouble Changing the path to the source file in an integration. I can't get the script to run without the source file in its default place, and when it is, assigning a new value to Query.OverrideFileLocation does not work. Details and code below.


I'm working on an integration with an Excel spreadsheet that will be generated weekly by another program. As this is made new every week, I'm not sure where the users are going to drop the file each time it is generated.

I saw in the IM script library that it is possible to override the default location of the source file at the beginning of the integration, so I wrote a script that checks for the file in the default location and brings up a browse dialog if it's not there. This works fine as a stand-alone .vbs file. When placed in the "Before Integration" and "Before Query" script, however, IM chokes and does not even reach the Before Integration script if the source file is not in the default location.
I understood from the IM Users' Guide that the Before Integration script runs before the source is queried, so I thought that I should be able to set the path to the source ahead of time.

If I leave the source file in the default location, the integration runs using that file instead of the one to which I browsed. I've checked every step of the way that the path is being returned correctly from the browse dialog, assigned to a global variable, and has the right value before being passed to Query.OverrideFileLocation.

Google has been no help thus far, nor have I seen anything similar to this upon searching this forum. Relevant code is posted below, and any help is much appreciated.

-----------------------------------------------
Before integration script
Code:
Dim myFSO
Dim myPath

Set myFSO = CreateObject("Scripting.FileSystemObject")

If Not myFSO.FileExists("C:\source.xls")
	Dim sBrowsePath, sBrowseFilter, oBrowseDialog
	sBrowseFilter = "Excel Files|*.xls"
	Set oBrowseDialog = CreateObject("UserAccounts.CommonDialog")
	oBrowseDialog.Filter = sBrowseFilter
	oBrowseDialog.InitialDir = sBrowsePath
	oBrowseDialog.Flags = &H80000 + &H4 + &H8
	oBrowseDialog.ShowOpen
	myPath = oBrowseDialog.FileName
	If myPath = "" Or Not myFSO.FileExists(myPath) Then
		CancelIntegration "Invalid path. Please run the integration again."
	End If
End If

SetVariable "myPath", myPath
-----------------------------------------------------
Before Query Script
Code:
Query.OverrideFileLocation=GetVariable ("myPath")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top