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

  • Creator
    Topic
  • #4112
    Anonymous

      We have an applet that inserts a block of text (as a bolded header) into every message on the SEND event. Occassionally, instead of inserting the text at the top of the message as expected, it will insert it in the middle. This occurs randomly and infrequently and is a terrible nuisance as this header is used to ID and filter our mail through our systems.

      For the past year we have been having this problem and we’ve tried several tactics to ensure that the text is always inserted in the message body of the active view, at the TOP of each message (please see the code sample below). I’ve spoken to Advansys support and no one seems to have heard of this happening to anyone else.

      We are using Formativ 1.6 and are in the process of upgrading to Formativ 2.0. I realize this could be a bug within the runtime or the language itself, but I would appreciate it if someone verified our code and gave us some advice on how to make absolutely sure that we’re doing everything we can to avoid this problem.

      Thanks for your help.

      <<SAMPLE CODE>>
      headerText = “This is the header text to be inserted at the top of each message”

      query = true
      counter = 0

      Do

      Utilities.DoEvents ‘<— COULD DOEVENTS BE CAUSING CONFLICTS?

      If Groupwise.EnvCurrentViewName() = “Mail” or Groupwise.EnvCurrentViewName() = “Message” _
      or Groupwise.EnvCurrentViewName() = “Meeting” or Groupwise.EnvCurrentViewName() = “Reunion” _
      or Groupwise.EnvCurrentViewName() = “Task” or Groupwise.EnvCurrentViewName() = “Tache” _
      or Groupwise.EnvCurrentViewName() = “Phone Message” or Groupwise.EnvCurrentViewName() = “Message telephonique” _
      or Groupwise.EnvCurrentViewName() = “Mail (simple)” or Groupwise.EnvCurrentViewName() = “Message (simple)” _
      or Groupwise.EnvCurrentViewName() = “Reminder” or Groupwise.EnvCurrentViewName() = “Note” Then

      Call Groupwise.focusSet(fcsMessage, “”)
      Call Groupwise.PosTextTop()
      Call Groupwise.fontbold(true)
      Call Groupwise.TypeText(headerText)
      Call Groupwise.fontbold(false)

      query = false

      Exit Do

      Else

      query = true

      End If

      counter = counter + 1

      Loop Until query = false Or counter > 20

      If query = true Then

      MsgBox “Error: PA Macro Line 271 – Query focus timed out! Message will be sent without header.”

      End If

    • Author
      Replies
    • #7133
      Support 1a
      Participant

        Thank you for your posting. I’ll ask an engineer to take a look at your code, though from a glance it looks OK.

        All the commands you use in this code are direct wrappers over the top the native GroupWise tokens. This infers a native GroupWise token is failing, as opposed to anything in the language.

        I’ll defer a full commentary until an Engineer takes a look, but I would probably move the Utilities.DoEvents() down to after the ‘Call Groupwise.focusSet(fcsMessage, “”)’ line, as this seems to be the area where the process fails. It could be that the Windows message queue is not being flushed, and thus the focus is not being reset, or the PosTextTop() command is not working.

        In any case, we’ll respond any additional suggestions here.

        Regards,

        Advansys Support

        #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

          #7136
          Anonymous

            Thanks for the suggestions. I will give it a try…

            And you’re right about querying the view name. Not sure why I felt we needed that since only the valid message types are integrated with the applet.

            Re: Utilities.DoEvents… in your sample, it doesn’t matter whether we place it before or after the ThrowToken block?

            #7134
            Support 1a
            Participant

              No – it shouldn’t really matter. Feel free to move it to after the ThrowToken calls if the tokens appear to be failing.

              Regards,

              Advansys Support

            Viewing 4 replies - 1 through 4 (of 4 total)
            • You must be logged in to reply to this topic.