The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
		
			|  | 
			
		
			|  | 
				
					| Sync Server Error  Posted: 02 Feb 07 8:00 AM
 |  
					| fiogf49gjkf0dHello to all! I run an agent in the sync ( a script that import data automatically ) and it shows an error like this: ...Variable Undefined: Application, at line...
 The lines affedted are:
 -Application.GetNewConnection
 -Application.GetIdFor..
 -Etc
 The script executed by the Click Event of a button in the Client works normally!
 
 Could anybody help me? Thanks.
 
 Rodrigo.
 |  
					|  |  | 
			|  | 
				
					| Re: Sync Server Error  Posted: 02 Feb 07 8:27 AM
 |  
					| fiogf49gjkf0dWhen a script is run from an Agent it is run in a special stripped down environment as a detached process.  I have found that is is very fussy about syntax.  When I debug a script I start small then build it up in steps until I find the problem area. 
 Check to make sure there a no message boxes.  Also make sure all you variables are defined.
 
 BTW, I used to have use complex scripts to do imports.  I have converted them all to VB6 programs.
 
 |  
					|  |  | 
			|  | 
				
					| Re: Sync Server Error  Posted: 26 Feb 07 2:04 AM
 |  
					| fiogf49gjkf0dHi Rodrigo what do you select in the action field by create an Agent?
 
 Why my question is: I'll import too any data over the agent but it will not work.
 I dont get any error messages. What I see in the syncLog-file is that the agent are started
 but nothing happens in the database.
 
 have you mor information about this?
 
 regards
 Frank Kress
 |  
					|  |  | 
			|  | 
				
					| Re: Sync Server Error  Posted: 26 Feb 07 8:06 AM
 |  
					| fiogf49gjkf0dHi Frank, I had the following problem:
 I don´t know exactly why but the sync didn´t recognize me some functions like Application.BasicFuntions.GetNewConnection, A.B.GetIdFor, etc so I had to make my own functions similar to these and it worked. That´s the way I solved it, creating a new ADODB connection and a function that receives a table and returns an ID. If you have the same problem and need some code, let me know.
 
 Kind regards,
 Rodrigo.
 |  
					|  |  | 
			|  | 
				
					| Re: Sync Server Error  Posted: 27 Aug 07 3:34 PM
 |  
					| Rodrigo, I am facing the same problem and would be interested in some sample code, could you please post it here?
 
 Thank you!
 Ian
 |  
					|  |  | 
			|  | 
				
					| Re: Sync Server Error  Posted: 30 Aug 07 12:28 PM
 |  
					| Instead of Application.GetNewConnection you can use: 
 Function GetAgentConnection
 Dim SLXConnectionString
 
 SLXConnectionString = "Provider=SalesLogix OLE DB Provider;Integrated       Security=""""
  assword=USERPASSWORD  ersist Security Info=False;User ID=USERNAME;Initial Catalog=DATABASENAME;Data Source=SERVERNAME;Extended Properties=""PORT=1706;LOG=ON;CASEINSENSITIVEFIND=ON;"";Location="""";Mode=ReadWrite" 
 
 Set oConection = CreateObject ("ADODB.Connection")
 
 
 oConection.ConnectionString = sConnectionString
 oConection.Open
 
 Set GetAgentConnection = oConection
 End Function
 
 
 And Instead of Application.BasicFunctions.GetIDFor you can use:
 
 Function ObtenerNuevoID (byVal tabla, byVal PrimerCaracterID)
 
 Dim oConnection
 Set oConnection = GetAgentConnection
 Dim strSQL
 Dim campo
 Dim oRecordSet
 Dim ID
 Id =""
 Dim caracteres(36)
 
 campo = tabla & "ID"
 strSQL = "Select " & campo & " From " & tabla & " where " _
 & "createDate = (Select max(CreateDate) From " & tabla & ")"
 
 OpenRecordSet oRecordSet, oConnection, strSQL
 
 If not oRecordSet.EOF Then
 Id = oRecordSet.Fields(0).Value
 End If
 
 If (Id = "") OR (isnull(Id)) Then
 Id = PrimerCaracterId & "00000000000"
 ObtenerNuevoId = Id
 Exit Function
 End If
 
 Caracteres(1) = "0"
 Caracteres(2) = "1"
 Caracteres(3) = "2"
 Caracteres(4) = "3"
 Caracteres(5) = "4"
 Caracteres(6) = "5"
 Caracteres(7) = "6"
 Caracteres(8) = "7"
 Caracteres(9) = "8"
 Caracteres(10) = "9"
 Caracteres(11) = "A"
 Caracteres(12) = "B"
 Caracteres(13) = "C"
 Caracteres(14) = "D"
 Caracteres(15) = "E"
 Caracteres(16) = "F"
 Caracteres(17) = "G"
 Caracteres(18) = "H"
 Caracteres(19) = "I"
 Caracteres(20) = "J"
 Caracteres(21) = "K"
 Caracteres(22) = "L"
 Caracteres(23) = "M"
 Caracteres(24) = "N"
 Caracteres(25) = "O"
 Caracteres(26) = "P"
 Caracteres(27) = "Q"
 Caracteres(28) = "R"
 Caracteres(29) = "S"
 Caracteres(30) = "T"
 Caracteres(31) = "U"
 Caracteres(32) = "V"
 Caracteres(33) = "W"
 Caracteres(34) = "X"
 Caracteres(35) = "Y"
 Caracteres(36) = "Z"
 
 Dim Id2(12)
 Dim i
 Dim Salir
 
 For i=1 to 12
 Id2(i) = Mid (Id,i,1)
 Next
 If Id2(12) <> "Z" Then
 Salir = False
 For i=1 to Ubound(Caracteres)
 If Id2(12) = Caracteres(i) and Not (Salir) Then
 Id2(12) = Caracteres(i+1)
 Salir = True
 End If
 Next
 Else
 Salir = False
 
 Dim y
 For y = 11 to 2 Step -1
 If Id2(y) <> "Z" Then
 For i=1 to Ubound(Caracteres)
 If Id2(y) = Caracteres(i) and Not(Salir)  Then
 Id2(y) = Caracteres(i+1)
 Id2(y+1) = 0
 Salir = True
 End If
 Next
 End If
 Next
 
 End If
 
 Id = ""
 For i=1 to Ubound(Id2)
 Id = Id & Id2(i)
 Next
 ObtenerNuevoId = Id
 
 End Function
 
 You could improve this function by checking and updating  the SITEKEYS table.
 
 
 
 |  
					|  |  | 
			|  | 
				
					| Re: Sync Server Error  Posted: 03 Sep 07 8:37 AM
 |  
					| | | Originally posted by Rodrigo Ginyaume 
 Instead of Application.GetNewConnection you can use:
 
 Function GetAgentConnection
 Dim SLXConnectionString
 
 SLXConnectionString = "Provider=SalesLogix OLE DB Provider;Integrated       Security=""""
  assword=USERPASSWORD  ersist Security Info=False;User ID=USERNAME;Initial Catalog=DATABASENAME;Data Source=SERVERNAME;Extended Properties=""PORT=1706;LOG=ON;CASEINSENSITIVEFIND=ON;"";Location="""";Mode=ReadWrite" 
 
 Set oConection = CreateObject ("ADODB.Connection")
 
 
 oConection.ConnectionString = sConnectionString
 oConection.Open
 
 Set GetAgentConnection = oConection
 End Function
 
 
 And Instead of Application.BasicFunctions.GetIDFor you can use:
 
 ......
 
 End Function
 
 You could improve this function by checking and updating  the SITEKEYS table.
 
 
 
 | 
 | 
 
 Since you are creating a connection via the provider I'd highly recommend you call the special SalesLogix procedure "slx_DBIDS" and not try to make up your own. It's very dangerous to mess w/SITEKEYS.
 
 EX: (Not tested.. but should work)
 
 
 Function CreateIDFor(strTableName)
 Dim cnnSLX
 Dim rstDBID
 Dim strRecordID
 
 strRecordID = ""
 Set cnnSLX = GetAgentConnection
 Set rstDBID = cnnSLX.Execute("slx_DBIDs('" & strTableName & "',1)")
 If Not rstDBID.EOF Then
 strRecordID = rstDBID.Fields(0)
 End If
 rstDBID.Close
 cnnSLX.Close
 Set rstDBID = Nothing
 Set cnnSLX = Nothing
 
 CreateIDFor = strRecordID
 End Function
 
 
 --
 rjl
 |  
					|  |  | 
			|  |