/ Forums / Advansys Formativ / Creating Solutions with Formativ / Message Reference from Reply

  • Creator
    Topic
  • #4378
    ctaleck
    Participant

    How do I get the message reference to a newly replied to message created by Groupwise in Formativ?

    I understand it is a “draft” message not yet stored and therefore must be saved somehow before I can manipulate it (such as add custom fields to the message.)

    I’ve tried

    Set Msg = Client.ClientState.CommandMessage

    but this always returns the original message which is usually still selected in the list view.

    Can anyone help on the proper command or series of commands?

  • Author
    Replies
  • #7996
    ctaleck
    Participant

    I found this code, but it does not work also. I get “X00” as the ID during the while loop.

       
      dim oMsg
      dim iMsgID
      dim iWIPPath
      Dim iBreakCount
    
      ' Save the draft message to the Work in Progress folder
      iWIPPath = GroupWise.Account.Owner.DisplayName & "" & GroupWise.Account.WorkFolder.Name
      Utilities.Trace "iWIPPath=" & iWIPPath
      Groupwise.ItemSaveMessageDraft(iWIPPath)
    
      ' Calling ItemMessageIDFromView immediately after GroupWise.ItemSaveMessageDraft
      ' can result in an X00 ID.
      iMsgID = GroupWise.ItemMessageIDFromView
      iBreakCount = 0
      while (iMsgID = "Token failed execution!") or (iMsgID = "X00")
         Application.ProcessMessages
         utilities.Timer(1)
         Application.ProcessMessages
         iMsgID = GroupWise.ItemMessageIDFromView
         iBreakCount = iBreakCount + 1
         Utilities.Trace iBreakCount & ": " & iMsgID
         if (iBreakCount > 10) then
           exit sub
         end if
      wend
    
      set oMsg = GroupWise.Account.GetMessage(iMsgID)
    
    #8001
    Support 3
    Participant

    GroupWise 7 client contains a localized word ‘Home’ after the account name. You will need to modify the code to add the localized ‘Home’ word after the account name. See the code below:

      
      dim oMsg
      dim iMsgID
      dim iWIPPath
      Dim iBreakCount
    
    
      ' GroupWise 7+ onwards contains a localized word 'Home' after the account name.
      ' You will need to add the localized 'Home' after the name
      if (groupwise.EnvVersionName > "7") then
        iWIPPath = GroupWise.Account.Owner.DisplayName & " Home" & GroupWise.Account.WorkFolder.Name
      else
        iWIPPath = GroupWise.Account.Owner.DisplayName & "" & GroupWise.Account.WorkFolder.Name
      end if
    
    
     ' Save the draft message to the Work in Progress folder
      Utilities.Trace "iWIPPath=" & iWIPPath
      Groupwise.ItemSaveMessageDraft(iWIPPath)
    
      ' Calling ItemMessageIDFromView immediately after GroupWise.ItemSaveMessageDraft
      ' can result in an X00 ID.
      iMsgID = GroupWise.ItemMessageIDFromView
      iBreakCount = 0
      while (iMsgID = "Token failed execution!") or (iMsgID = "X00")
         Application.ProcessMessages
         utilities.Timer(1)
         Application.ProcessMessages
         iMsgID = GroupWise.ItemMessageIDFromView
         iBreakCount = iBreakCount + 1
         Utilities.Trace iBreakCount & ": " & iMsgID
         if (iBreakCount > 10) then
           exit sub
         end if
      wend
    
      set oMsg = GroupWise.Account.GetMessage(iMsgID)
      msgbox oMsg.subject.plaintext
    

    Hope this helps.

    Regards,
    Advansys Support

    #8002
    ctaleck
    Participant

    You are right, I am using GW 7. But, I get the string “7.0.2 HP” for the EnvVersionName so that the following code returns FALSE for me.

    (GroupWise.EnvVersionName > "7")
     

    I had to modify it to make it thusly:

      (Cint(Left(GroupWise.EnvVersionName,1))) >= 7)
    

    However, I then had to deal with the fact that the “Work In Progress” folder was in another folder. So I used the code above combined the “GetWIPFolderPath” function found elsewhere on these forums for that.

    But then… I figured out that you need to modify the draft message before it can be saved so I used this code:

    Call Groupwise.ItemSetText("X00", itfSubject, " COMPLETED", TRUE)  

    Now the message is saved in the “Work In Progress” folder. Yeah!

    But alas, I still get an “X00” message ID for all the iterations. What else am I missing? Is some sort of “refresh” needed?

    #8005
    Support 3
    Participant

    Does the messages saved to the folder? You can use the Groupwise.ThrowToken() method to call the native Token(), alternative you can use our Token wrapper. See the Formativ Language Guide for more information. The code below execute the ItemSaveMessageDraft() token and return boolean value which indicate the token execution.

      msgbox Groupwise.throwtoken("ItemSaveMessageDraft(""" & iWIPPath & """)", iReturnVal)     
    

    Could you also post the updated source so that we have review.

    Regards,
    Advansys support

    #7998
    ctaleck
    Participant

    I just reviewed again the thread on this forum about this problem and I’ve decided to tackle it in a different manner as there appears to be no resolution to the “custom field in a draft message” problem.

    Too bad, as I was trying to avoid having to re-create an e-mail form just to send a reply with some data attached to a custom field.

    There was a suggestion to put the data in the body of the message at the bottom, which I might consider, but does not seem as clean.

    #7994
    ctaleck
    Participant

    For the record, here is the code I was working with. The result is a still “X00” during the iterations.

     Sub Main(Client, GWEvent)
    
    dim iWIPFolderPath
      dim oMsg
      dim iMsgID
      dim iWIPPath
      Dim iBreakCount
    
     ' Save the draft message to the Work in Progress folder
      Call Groupwise.ItemSetText("X00", itfSubject, " COMPLETED", TRUE) ' TRUE = Append
      Utilities.Trace "iWIPPath=" & iWIPPath
      'Groupwise.ItemSaveMessageDraft(iWIPPath)
      Call Groupwise.throwtoken("ItemSaveMessageDraft(""" & iWIPPath & """)", iReturnVal)
      MsgBox "ItemSaveMessageDraft returns " & iReturnVal
    
      ' Calling ItemMessageIDFromView immediately after GroupWise.ItemSaveMessageDraft
      ' can result in an X00 ID.
      iMsgID = GroupWise.ItemMessageIDFromView
    
      iBreakCount = 0
      while (iMsgID = "Token failed execution!") or (iMsgID = "X00")
         Application.ProcessMessages
         utilities.Timer(1)
         Application.ProcessMessages
         iMsgID = GroupWise.ItemMessageIDFromView
         iBreakCount = iBreakCount + 1
         Utilities.Trace iBreakCount & ": " & iMsgID
         if (iBreakCount > 10) then
           exit sub
         end if
      wend
    
      set oMsg = GroupWise.Account.GetMessage(iMsgID)
      msgbox oMsg.subject.plaintext
    
    End Sub
    
    
    
    '-------------------------------------------------------------------------------
    ' Get full path of the Work-In-Progress folder where Drafts are saved
    '-------------------------------------------------------------------------------
    Function GetWIPFolderPath(aGWFolder, byref aPath)
      Dim sHome
      sHome = ""
      Utilities.Trace "aGWFolder.Name=" & aGWFolder.Name & " aPath=" & aPath
      If (Cint(Left(GroupWise.EnvVersionName,1)) >= 7) Then
        If aGWFolder.Name = GroupWise.Account.Owner.DisplayName Then
          sHome = " Home"
        End If
      End If
      If aGWFolder Is Nothing Then
        Exit Function
      End If
      If (aPath <> "") Then
        aPath = aGWFolder.name & sHome & "" & aPath
      Else
        aPath = aGWFolder.name
      End If
      If (aGWFolder.objtype = fgwRoot) Then
        Exit Function
      Else
        Call GetWIPFolderPath(aGWFolder.ParentFolder, aPath)
      End if
    End Function 
    #8000
    Support 3
    Participant

    Your code review shows that you did not call the GetWIPFolderPath from the main subroutine prior to save the message. The following code works fine in our environment. Let us know if we missed anything…

    Sub Main(Client, GWEvent)
    
      dim iWIPFolderPath
      dim oMsg
      dim iMsgID
      dim iWIPPath
      Dim iBreakCount
    
     ' Save the draft message to the Work in Progress folder
      Call Groupwise.ItemSetText("X00", itfSubject, " COMPLETED", TRUE) ' TRUE = Append
    
      call GetWIPFolderPath(groupwise.account.workfolder, iWIPPath)
    
      msgbox "Work In Progress folder path: " & iWIPPath
    
      Call Groupwise.throwtoken("ItemSaveMessageDraft(""" & iWIPPath & """)", iReturnVal)
    
      ' Calling ItemMessageIDFromView immediately after GroupWise.ItemSaveMessageDraft
      ' can result in an X00 ID.
      iMsgID = GroupWise.ItemMessageIDFromView
    
      iBreakCount = 0
      while (iMsgID = "Token failed execution!") or (iMsgID = "X00")
         Application.ProcessMessages
         utilities.Timer(1)
         Application.ProcessMessages
         iMsgID = GroupWise.ItemMessageIDFromView
         iBreakCount = iBreakCount + 1
         Utilities.Trace iBreakCount & ": " & iMsgID
         if (iBreakCount > 10) then
           exit sub
         end if
      wend
    
      set oMsg = GroupWise.Account.GetMessage(iMsgID)
      msgbox "Subject: " & oMsg.subject.plaintext
    
    End Sub
    
    
    
    '-------------------------------------------------------------------------------
    ' Get full path of the Work-In-Progress folder where Drafts are saved
    '-------------------------------------------------------------------------------
    Function GetWIPFolderPath(aGWFolder, byref aPath)
      Dim sHome
      sHome = ""
      Utilities.Trace "aGWFolder.Name=" & aGWFolder.Name & " aPath=" & aPath
      If (Cint(Left(GroupWise.EnvVersionName,1)) >= 7) Then
        If aGWFolder.Name = GroupWise.Account.Owner.DisplayName Then
          sHome = " Home"
        End If
      End If
      If aGWFolder Is Nothing Then
        Exit Function
      End If
      If (aPath <> "") Then
        aPath = aGWFolder.name & sHome & "" & aPath
      Else
        aPath = aGWFolder.name
      End If
      If (aGWFolder.objtype = fgwRoot) Then
        Exit Function
      Else
        Call GetWIPFolderPath(aGWFolder.ParentFolder, aPath)
      End if
    End Function  
    

    BTW, you can use the custom fields to store data or insert the data to the message body. If the data is sensitive then you can consider to encrypt and decrypt at the other end by your solution.

    Most probably in GroupWise 8 (Bonsai) will have the X-Fields where you can add additional data and viewable by other non GroupWise clients.

    Hope this helps.

    Regards,
    Advansys Support

    #7995
    Support 3
    Participant

    FYI, the example code above worked fine in 2 out of 3 GroupWise accounts. We are not sure why it failed to return the proper message ID in one account, it could be the message not yet synchronize with the GroupWise system. Although, the applet failed to return proper message id but the message actually saved to the Work-In-Progress folder. Note that, all of the 3 accounts tested are running in caching mode.

    Regards,
    Advansys Support

    #7997
    ctaleck
    Participant

    I’m not sure why I had the ItemSaveMessageDraft commented out. Tired mistake…

    I tried using your cleaned up code and finally got a message ID. However, I got the message ID of the “original” message, not the “reply” message.

    It turns out that I’ve had the “integration” setup incorrectly.

    In all my tests, I’ve had integrations set to run the code BEFORE the “OnReply” event.

    I changed it to run AFTER “OnReply” and it successfully retrieves the “reply” message ID.

    I guess the moral of this exchange is that no assumptions should be made about which integrations are being used during tests.

    [This message was edited by ctaleck on July 17, 2008 at 06:15 AM.]

    #7999
    Support 3
    Participant

    Good to hear that you are making progress. If you have any further questions, please do not hesitate to contact us.

    Regards,
    Advansys Support

    #8003
    andremor
    Participant

    hi.
    i’m trying to get “ItemMessageIDFromView()” to work after saving the msg as a draft, but even using the routine above i always get id X00.. any idea?

    #8004
    Support 3
    Participant

    This issue also posted to this thread: http://www.advansyscorp.com/forums/topic/5571038701/

    Regards,
    Advansys Support

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