/ Forums / Advansys Formativ / Creating Solutions with Formativ / Auto-Inserting Text Into Message Body / Reply To: Auto-Inserting Text Into Message Body

#7135
Support 1a
Participant

Isabelle,

An engineer looked at the code, and had the following suggestions:

– Are all the calls to ‘Groupwise.EnvCurrentViewName()’ actually required? Presumably the applet is integrated with the appropriate message types (i.e. email, tasks, notes, etc), so the applet will only be run in response to known message types. If, for a reason we have missed, you do need to query the view name, we suggest you call Groupwise.EnvCurrentViewName() only once and assign the view name to a variable. Carry out your view name evaluation using this variable. The current code calls ‘Groupwise.EnvCurrentViewName()’ 12 times within each run of the loop. I can’t say what impact this might have on the state of the view.

– You can check to see if the calls to FocusSet() and PosTextTop() are actually working by using the ThowToken technique. This approach calls the native GroupWise token directly, and returns a boolean indicating if the token actually worked. As the FocusSet() and/or PosTextTop() are the most likely candidates for failure, we have re-written the code to use this technique. Although the code below doesn’t show this, you could check the return value from the

 if groupwise.ThrowToken("focusSet(10;)", iReturnVal)

lines to see if the appropriate token actually worked.

Sub Main(Client, GWEvent)
  dim x
  dim query
  dim headerText
  dim iReturnVal
 
  query = true
  headerText = "This is the header text to be inserted at the top of each message"
 
  for x = 1 to 20
    Utilities.DoEvents
 
    if groupwise.ThrowToken("focusSet(10;)", iReturnVal) then
      if groupwise.ThrowToken("PosTextTop()", iReturnVal) then
        Call Groupwise.fontbold(true)
        Call Groupwise.TypeText(headerText)
        Call Groupwise.fontbold(false)
        query = false
        exit for
       end if
    end if
  next
 
  If query = true Then
    MsgBox "Error: PA Macro Line 271 - Query focus timed out! Message will be sent without header."
  End If
 
End Sub

We hope this helps.

Advansys Support