cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Script Error for a Specific Report

ngurjar
Retired

Hello All,

For one of my customer there is a report which i generate.

As you can see in the screenshot when i click on "Application Overview Report" there is a macro in the background that gets called (ZF Generate Application Manager.macro) and generates an RTF report. I have attached the code and the screenshot.

Now the issue is i get a script error on this Macro only in the Productive Infrastructure and not in the QA Infrastructure. The Macro Code is the same in the QA and Productive Infrastructure. Customer has these two infrastructures completely separate from each other. I compared both the macro codes and there is no change whatsoever.

Furthermore i though it might be due to the RTF conversion. So i carried out RTF Converstion as well on the Environment in the Productive Infrastructure. The same report can be generated in the RTF format without any issue via the thick client (Mega.exe) in the productive infrastructure.

My question to you is:

1) Have you encountered such issues in the past? If yes how did you resolve this issue?
2) Are there any options related settings which i need to modify in the option settings?

3) Do i have to restart the IIS or the  Hopex Webservices or the SSP after the RTF conversion has been carried out?

 

APM  Script Error by generating Application Overview Report.png

'MegaContext(Fields,Types)
Option Explicit


'-----------------------------------------------------------------------------
' FUNCTION : CmdInit
' Function called when the command is triggered.<br>
' Example : click on a menu.
' 
' @param mgobjSource
'            MegaObject on which the command is applied.
' @param intCmdNumber
'            Number identifying the command among all the commands
'            implemented by this class.<br>
'            Each command correspond to the commandNumber used in CmdInit
'            function.<br>
'            Useful if CmdCount indicates more than one command.
'-----------------------------------------------------------------------------
Sub CmdInvoke(mgobjSource as MegaObject, intCmdNumber as Integer)
 Dim  oMegaUtilitiesMacro, root, MyDocumentTemplate,oCurEnv,strLang 
  root =  mgobjSource.getroot()
	 Set oCurEnv = root.CurrentEnvironment
	 strLang = oCurEnv.GetCurrentLanguageName
 Dim strDate,strSecond,strMinute,strHour,strDay,strMonth,strYear,strToday,fileName 
'Gestion des Date
	 strDate = CDate(Now)
	 strSecond = DatePart("s", strDate)
	 strMinute = DatePart("n", strDate)
	 strHour = DatePart("h", strDate)
	 strDay = DatePart("d", strDate)
	 strMonth = DatePart("m", strDate)
	 strYear = DatePart("yyyy", strDate)
	 strToday = strYear & strMonth & strDay & "_" & strHour & strMinute & strSecond
'select case intCmdNumber
 'Case 4
    Set MyDocumentTemplate = root.getObjectFromId("~2CeWHL8MM52M[<ZF> Application Overview report]")
	fileName = root.getobjectfromid("~Ic)uPsknM1BP[Application overview]").getprop("~Z20000000D60[Short Name]") & "_" & mgobjSource.getProp("~Z20000000D60[Short Name]") & "_" & strToday & ".rtf"
     GenerateDoc mgobjSource,MyDocumentTemplate,getValidFileName(fileName)
'End Select   
End Sub
Sub GenerateDoc(Source as MegaObject, DocumentTemplate As MegaObject, fileName)
		Dim MyDocument
    Set MyDocument = Source.NewDocument(DocumentTemplate.GetProp("~210000000900"),fileName) 
    MyDocument.RefreshDocument()
    Dim documentPath
    documentPath= MyDocument.getProp("~(zcMngbSnS00[Report <MS Word> path] ")&"\"& MyDocument.getprop("name")
    Source.getroot.CurrentEnvironment.Toolkit.ExecCmd documentPath , "?Open"
End Sub


'To implement if the command manage more than 1 menu item
'Sub CmdCount(Source as MegaObject,CmdCountReturned as Integer)
 'CmdCountReturned = 7
'End Sub

'Must be implemented if CmdCount returns more than 1



'May be implemented if you want to define the order of the menu item inside his category


'May be implemented if you want to redefine the style of the menu (for exemple if you want to implement a popup command)


'Implements this method to insert a submenu in a popup menu. The popup menu must belong to the list of defined commands and is designed by his number


'Return a valide file name for saving file
Function getValidFileName(strFileName)
	Dim objRegEx
	Set objRegEx= New RegExp
	objRegEx.Global = True   
	objRegEx.IgnoreCase = True
	objRegEx.Pattern = "[^a-z \d\.]"
	getValidFileName = objRegEx.Replace(strFileName,"_")
End Function 

'-----------------------------------------------------------------------------
' FUNCTION : CmdCount
' To be implemented if the command manages more than 1 menu item.<br>
' Each menu item is identified by its command number. For example,
' if there are 3 menu items, their command numbers are 1, 2 and 3.<br>
' Properties of each menu item is defined by implementing the following functions:
' <ul>
' <li>CmdInit   : to define menu item name displayed
' <li>CmdCheck  : to control when the menu item is hidden/disabled/checked
' <li>CmdBitmap : to associate a bitmap to the menu item
' <li>CmdOrder  : to define the menu item order in its category (or in the sub menu of a popup menu item)
' <li>CmdStyle  : specifies the style of the menu item (for example, if style equals 1, the menu item will be a popup menu and can have sub menus)
' <li>CmdPopup  : specifies the parent popup menu item
' </ul>
'
' @param mgobjSource
'          MegaObject on which the command is applied.
' @param intCmdCountReturned
'          Number of commands implemented by this class.
'-----------------------------------------------------------------------------
'Sub CmdCount(mgobjSource as MegaObject, intCmdCountReturned as Integer)
'End Sub


'-----------------------------------------------------------------------------
' FUNCTION : CmdInit
' To be implemented in order to specify name and category of each menu item
' defined by the command.<br>
' This function is called once per menu item as defined with CmdCount function.<br>
' 
' @param mgobjSource
'            MegaObject on which the command is applied.
' @param intCmdNumber
'            Number identifying the command initialized among all the
'            commands implemented by this class.
'            The command number is a number from 1 to the number of commands 
'            as specified by CmdCount (if there are 3 menu items, their command numbers are 1, 2 and 3).
' @param strNameReturned
'            Displayed name of the command.<br>
'            Example : name of the menu item.
' @param intCategoryReturned
'            Identifier of a command category.<br>
'            Common categories :
'            <ul>
'            <li>DESCRIPTION (0x0010) : Commands for entering a description
'            of the object (Open, Zoom, Flowchart...).
'            <li>ENTRY (0x0020) : Commands for entering characteristics of
'            the object (Attributes, Processes, Navigability->,
'            Cardinality->).
'            <li>ACTION (0x0004) : Action/activation commands for the
'            object (Generate, Derive, Prototype, Quantify...).
'            <li>DOCUMENTATION (0x0040) : Commands for
'            Publishing/Documenting the object (Document, Reference,...).
'            <li>DISPLAY (0x0002) : Commands for displaying the object
'            (View, Format, Draw).
'            <li>CONTAINER (0x0080) : Commands concerning the container
'            (Add to favorites, delete)
'            <li>ADMIN (0x0008) : Administration commands for the object
'            (Explore, Delete, Compare...).
'            <li>LINK (0x0200) : "Connect" menu commands.
'            <li>NEW (0x0100) : "New" menu commands
'            </ul>
'-----------------------------------------------------------------------------
'Sub CmdInit(mgobjSource as MegaObject, intCmdNumber as Integer, strNameReturned as String, intCategoryReturned as Integer)
'End Sub


'-----------------------------------------------------------------------------
' FUNCTION : CmdCheck
' Can be implemented if you want to manage the appearance of the menu items.<br>
' This function is called each time the appearance of the menu item has to be evaluated.
' It can be each time the menu of the source object is displayed.
' So performance issues have to be considered when implementing this function.<br>
' 
' @param mgobjSource
'            MegaObject on which the command is applied.
' @param intCmdNumber
'            Number identifying the command initialized among all the
'            commands implemented by this class.
'            The command number is a number from 1 to the number of commands 
'            as specified by CmdCount (if there are 3 menu items, their command numbers are 1, 2 and 3).
' @param intStatusReturned
'            Value returning the status of the command :
'            <ul>
'            <li>CHECKED (0x00000100) : The command is checked.
'            <li>HIDDEN (0x00000200) : The command is not visible. For example, can be used to hide the command available on objects matching some features.
'            <li>DISABLED (0x00000400) : The command is visible but cannot be invoked. As a result, corresponding menu item is grayed.
'            </ul>
'-----------------------------------------------------------------------------
'Sub CmdCheck(mgobjSource as MegaObject, intCmdNumber as Integer, intStatusReturned as Integer)
'End Sub


'-----------------------------------------------------------------------------
' FUNCTION : CmdBitmap
' Can be implemented if you want to define the bitmap of the menu item.
' This function is called each time the appearance of the menu item has to be evaluated.
' It can be each time the menu of the source object is displayed.
' So performance issues have to be considered when implementing this function.<br>
' 
' @param mgobjSource
'            MegaObject on which the command is applied.
' @param intCmdNumber
'            Number identifying the command initialized among all the
'            commands implemented by this class.
'            The command number is a number from 1 to the number of commands 
'            as specified by CmdCount (if there are 3 menu items, their command numbers are 1, 2 and 3).
' @param varPictureID
'            The command bitmap MEGA identifier. Must be the MEGA identifier
'            (IdAbs) of a MetaPicture.                 
'-----------------------------------------------------------------------------
'Sub CmdBitmap(mgobjSource as MegaObject, intCmdNumber as Integer, varPictureID as Variant)
'End Sub


'-----------------------------------------------------------------------------
' FUNCTION : CmdOrder
' Can be implemented if you want to define the order of the menu item
' inside its category.<br>
' If the menu item is a sub menu item of a popup menu item, this function
' defines the order in the sub menu.
' 
' @param mgobjSource
'            MegaObject on which the command is applied.
' @param intCmdNumber
'            Number identifying the command initialized among all the
'            commands implemented by this class.
'            The command number is a number from 1 to the number of commands 
'            as specified by CmdCount (if there are 3 menu items, their command numbers are 1, 2 and 3).
' @param intOrder
'            The command order.
'-----------------------------------------------------------------------------
Sub CmdBitmap(mgobjSource as MegaObject, intCmdNumber as Integer, varPictureID as Variant)

  Dim root
  root = mgobjSource.GetRoot
  'If intCmdNumber = 2 Or intCmdNumber = 7 Or intCmdNumber = 8 Or intCmdNumber = 6 then 
   		'varPictureID = root.getobjectfromid("~e)YFI85)FTMP[StaticDoc_XLS]").getId()
  'Else If intCmdNumber = 5 then 
   		'varPictureID = root.getobjectfromid("~b8oXSgO2GfwK[StaticDoc_PPTX]").getId()
  'Else
   		varPictureID = root.getobjectfromid("~ok1VXo7jrK10[Document]").getId()
  'End If
  'End If			
 
End Sub


'-----------------------------------------------------------------------------
' FUNCTION : CmdStyle
' Can be implemented if you want to redefine the style of the menu item.<br>
' Example : intStyle should equals 1 if the command is a popup command.
' 
' @param mgobjSource
'            MegaObject on which the command is applied.
' @param intCmdNumber
'            Number identifying the command initialized among all the
'            commands implemented by this class.
'            The command number is a number from 1 to the number of commands 
'            as specified by CmdCount (if there are 3 menu items, their command numbers are 1, 2 and 3).
' @param intStyle
'            Must return 1 to indicate that the menu item launches
'            a popu menu.  
'-----------------------------------------------------------------------------
'Sub CmdStyle(mgobjSource as MegaObject, intCmdNumber as Integer, intStyle as Integer)
'End Sub


'-----------------------------------------------------------------------------
' FUNCTION : CmdPopup
' Implements this method to insert a submenu in a popup menu.<br>
' The parent popup menu item must belong to the list of defined commands and is
' identified by its command number (referenced by intPopupNumber in this function).
' 
' @param mgobjSource
'            MegaObject on which the command is applied.
' @param intCmdNumber
'            Number identifying the command initialized among all the
'            commands implemented by this class.
'            The command number is a number from 1 to the number of commands 
'            as specified by CmdCount (if there are 3 menu items, their command numbers are 1, 2 and 3).
' @param intPopupNumber
'            Identifier of the parent popup menu item. The CmdStyle
'            function indicates that the style of the parent popup menu item is 1.<br>
'            The parent popup menu item is a number from 1 to the number of commands 
'            as specified by CmdCount (if there are 3 menu items, their command numbers are 1, 2 and 3).
'-----------------------------------------------------------------------------
'Sub CmdPopup(mgobjSource as MegaObject, intCmdNumber as Integer, intPopupNumber as Integer)
'End Sub
   

 I would be really grateful if you can provide me any info or any leads.

 

Thank you and Greetings,
Nik

 

 

4 Replies

Hi Claudio,

The issue has been resolved. On the Server there was no MS Office (Word) installed as a result we received those errors.

Nevertheless appreciate the time taken by you to answer my questions.

Thank you & Greets
Nik

For this reason is important to understand what the problem is.

With the "messageboxes" you will get a visual clue if all the objects are good.

 

Be aware that if you try to generate a file on the web, you may fail to save it, because the path will never be accessible.

 

You need to generate it in the correct place (depending on the context), and then use the "?open" to actually download it.

Claudio Pucci

Hi Claudio,

Thank you for your answer.

The code can be excuted without any issue when i hit the execute button on the Macro. I can generate this report without any problem on the Thick Client. Its only on the webclient that i am facing this issue.

Greets
Nik

cpucci
MEGA
MEGA

Go to the line 43 of your code:

 

Set MyDocument = Source.NewDocument(DocumentTemplate.GetProp("~210000000900"),fileName)

 

You may have different problems: the fileName contains illegal characters for a file, or the source is empty, or the DocumentTemplate is empty.

 

Add a line just before, for debugging purposes:

 

root.callMethod "messagebox", "Source = " & Source.getID

root.callMethod "messagebox", "DocumentTemplate= " & DocumentTemplate.getID

root.callMethod "messagebox", "fileName= " & fileName

 

Then try again, and check if you find what the actual problem is.

 

Claudio Pucci