I hope someone can help me.
I have a piece of VBScript code which works on 2 colleague's machines but will not work on mine.
At first we thought it might be because I didn't have Cognos installed on my machine but even after installing Cognos, the script still doesn't work.
Here's the script (basically changed from one of the samples supplied in Cognos). Please ignore the links...They are not meant to be links, just examples of code and/or messages returned. (I don't know how to turn the links off.....my first post)
'*Requirements:
'* 1). install WScript host engine first.
'* 2). Automation Client requires only two dlls: UpfAuto.dll, UpfrontConnectv3.dll.
'*
' Global Variable:
Dim g_FileSysObj
'Create the File Object to output the result:
Set g_FileSysObj = CreateObject("Scripting.FileSystemObject"
UpfAutomation
'********************************************************************************
'* Input: - none
'*
'* Output: - successful publishing of a news item to one newsbox.
'*
'* Description: Publish a file called test.pdf in someone's newsbox
'*
'********************************************************************************
Sub UpfAutomation()
Dim UpfSession, UpfCheck
Dim logonUpf, logoffUpf, serverClick, userClick
Dim xmlNewsBox, xmlNewsItem, NewsBoxID, NewNB
MsgBox "This script will publish a file called test.pdf in someone's newsbox"
'Create Upfront session object:
Set Upfsession = CreateObject("Upfront.UpfrontSession"
logonUpf = Upfsession.Login("myservername", "myuser", "password", "Root User Class"
'Run a describe system command so you can extract out the BaseNewsBoxId,write the result to a file via printmsg and then check the outcome
NewsBoxID = Upfsession.XMLCmd("<DescribeSystem RequestId='System'></DescribeSystem>"
PrintMsg (NewsBoxID)
'Check if the Upfront Session is Initialized
UpfCheck = CheckSession
If UpfCheck = "Fail" then
MsgBox "The Upfront Session is not intialized"
Exit Sub
End if
'extract the id value from the file and assign it to a variable for use later
NewNB = "mynewsboxid"
'Create a newsitem inside the newsbox that you want
xmlNewsItem = Upfsession.XMLCmd("<CreateNewsItem><Name>Test%20file</Name><ParentId>" + NewNB + "</ParentId><ProviderType>Other</ProviderType><DefaultAction>View</DefaultAction><Action><Name>View</Name><URLText>
printmsg(xmlnewsitem)
'log out of Upfront session
logoffUpf = Upfsession.logout()
MsgBox "Logon to Upfront and Select the NewsBox to see the Results"
End Sub
'********************************************************************************
'* Input: - Message: The message to print to a file.
'*
'* Output: - none.
'*
'* Description: This function prints strings to a file
'*
'********************************************************************************
Sub PrintMsg(Message)
Dim fFile, rc
rc = g_FileSysObj.FileExists("C:\xmlresultVBS.txt"
If rc Then
g_FileSysObj.DeleteFile("C:\xmlresultVBS.txt"
End If
Set fFile = g_FileSysObj.OpenTextFile("C:\xmlresultVBS.txt", 8, 1) 'OverWrite
fFile.WriteLine (Message)
fFile.WriteLine (vbCrLf)
fFile.Close
End Sub
'********************************************************************************
'* Input: - none:
'*
'* Output: - error
'*
'* Description: This function check to see if the Upfront session initialized
'*
'********************************************************************************
Function CheckSession()
Dim fileToRead, strInput, oneBigString
Dim pos1, pos2, myId
set fileToRead = g_FileSysObj.OpenTextFile("C:\xmlresultvbs.txt", 1)
oneBigString = fileToRead.ReadAll
pos1 = InStr(1, oneBigString, "ResultCode=", 1)
pos2 = InStr(1, oneBigString, "<Message>", 1)
if pos2 = 0 then
CheckSession = "Success"
Exit Function
End if
myId = Mid(oneBigString, pos1 + 12, pos2 - 2 - pos1 - 12)
CheckSession = myId
End Function
It all works except for the createnewsitem XML command.
I get the following message back when I run it :-
<?xml version="1.0" encoding="windows-1252" standalone="yes"?><Result xmlns=" ResultCode="Fail"><Message>The object of type (NewsItem) cannot be created because it references a non-existing object.
</Message></Standard_Result></Result>.
When it runs properly (ie on a colleague's machine) we get a different message suggesting a resultcode = "success" and a newsitem id which gets created.
I hope this is clear enough for someone to understand (and to help me.....maybe??)
thanks in advance
I have a piece of VBScript code which works on 2 colleague's machines but will not work on mine.
At first we thought it might be because I didn't have Cognos installed on my machine but even after installing Cognos, the script still doesn't work.
Here's the script (basically changed from one of the samples supplied in Cognos). Please ignore the links...They are not meant to be links, just examples of code and/or messages returned. (I don't know how to turn the links off.....my first post)
'*Requirements:
'* 1). install WScript host engine first.
'* 2). Automation Client requires only two dlls: UpfAuto.dll, UpfrontConnectv3.dll.
'*
' Global Variable:
Dim g_FileSysObj
'Create the File Object to output the result:
Set g_FileSysObj = CreateObject("Scripting.FileSystemObject"
UpfAutomation
'********************************************************************************
'* Input: - none
'*
'* Output: - successful publishing of a news item to one newsbox.
'*
'* Description: Publish a file called test.pdf in someone's newsbox
'*
'********************************************************************************
Sub UpfAutomation()
Dim UpfSession, UpfCheck
Dim logonUpf, logoffUpf, serverClick, userClick
Dim xmlNewsBox, xmlNewsItem, NewsBoxID, NewNB
MsgBox "This script will publish a file called test.pdf in someone's newsbox"
'Create Upfront session object:
Set Upfsession = CreateObject("Upfront.UpfrontSession"
logonUpf = Upfsession.Login("myservername", "myuser", "password", "Root User Class"
'Run a describe system command so you can extract out the BaseNewsBoxId,write the result to a file via printmsg and then check the outcome
NewsBoxID = Upfsession.XMLCmd("<DescribeSystem RequestId='System'></DescribeSystem>"
PrintMsg (NewsBoxID)
'Check if the Upfront Session is Initialized
UpfCheck = CheckSession
If UpfCheck = "Fail" then
MsgBox "The Upfront Session is not intialized"
Exit Sub
End if
'extract the id value from the file and assign it to a variable for use later
NewNB = "mynewsboxid"
'Create a newsitem inside the newsbox that you want
xmlNewsItem = Upfsession.XMLCmd("<CreateNewsItem><Name>Test%20file</Name><ParentId>" + NewNB + "</ParentId><ProviderType>Other</ProviderType><DefaultAction>View</DefaultAction><Action><Name>View</Name><URLText>
printmsg(xmlnewsitem)
'log out of Upfront session
logoffUpf = Upfsession.logout()
MsgBox "Logon to Upfront and Select the NewsBox to see the Results"
End Sub
'********************************************************************************
'* Input: - Message: The message to print to a file.
'*
'* Output: - none.
'*
'* Description: This function prints strings to a file
'*
'********************************************************************************
Sub PrintMsg(Message)
Dim fFile, rc
rc = g_FileSysObj.FileExists("C:\xmlresultVBS.txt"
If rc Then
g_FileSysObj.DeleteFile("C:\xmlresultVBS.txt"
End If
Set fFile = g_FileSysObj.OpenTextFile("C:\xmlresultVBS.txt", 8, 1) 'OverWrite
fFile.WriteLine (Message)
fFile.WriteLine (vbCrLf)
fFile.Close
End Sub
'********************************************************************************
'* Input: - none:
'*
'* Output: - error
'*
'* Description: This function check to see if the Upfront session initialized
'*
'********************************************************************************
Function CheckSession()
Dim fileToRead, strInput, oneBigString
Dim pos1, pos2, myId
set fileToRead = g_FileSysObj.OpenTextFile("C:\xmlresultvbs.txt", 1)
oneBigString = fileToRead.ReadAll
pos1 = InStr(1, oneBigString, "ResultCode=", 1)
pos2 = InStr(1, oneBigString, "<Message>", 1)
if pos2 = 0 then
CheckSession = "Success"
Exit Function
End if
myId = Mid(oneBigString, pos1 + 12, pos2 - 2 - pos1 - 12)
CheckSession = myId
End Function
It all works except for the createnewsitem XML command.
I get the following message back when I run it :-
<?xml version="1.0" encoding="windows-1252" standalone="yes"?><Result xmlns=" ResultCode="Fail"><Message>The object of type (NewsItem) cannot be created because it references a non-existing object.
</Message></Standard_Result></Result>.
When it runs properly (ie on a colleague's machine) we get a different message suggesting a resultcode = "success" and a newsitem id which gets created.
I hope this is clear enough for someone to understand (and to help me.....maybe??)
thanks in advance