• Creator
    Topic
  • #3954
    sstewart
    Participant

    I need to save a group of documents that are stored in a GW library to disk in their native format. I can’t locate a method in Formativ that saves a document – only to open, view, add, close, etc. Is some way to accomplish this task? Thanks
    Steve

  • Author
    Replies
  • #6696
    Support 1a
    Participant

    As will most access to the GroupWise message store, you need to use the GroupWise Object API, which is exposed in Formativ via the GroupWise.Account object.

    To save a DMS document to disk, you need to locate the appropriate DocumentReference object, access it’s Document property, then locate the appropriate DocumentVersion you wish to save. You then check out the document to phsically save it to disk, then check it back in again. (If you don’t check it back in the document will be unavailable to other users).

    Here is some sample code that shows how this can be done given a DocumentReference object:

      private function GetDocument(aMsg)
        
        GetDocument = ""
        
        if aMsg is nothing then
          exit function
        end if
      
        on error resume next
        
        ' Exit, if the document is checked out.
        if aMsg.Document.CurrentVersion.CheckedOut then
          exit function
        end if
        
        ' Exit, if the document is inuse by another application.
        if aMsg.Document.CurrentVersion.InUse then
          exit function
        end if  
        
        dim iDocPath
        dim iDocumentName
        
        
        iDocumentName = replace(trim(aMsg.subject), ".", "")
        if iDocumentName = "" then
          iDocumentName = "Document"
        else
          iDocumentName = GetLegalFileName(iDocumentName)
        end if
        
        iDocumentName = iDocumentName & "." & replace(aMsg.Document.CurrentVersion.OriginalFileType, ".", "")
        
        iDocPath = iWorkFolderName & iDocumentName
        
        aMsg.Document.CurrentVersion.CheckOut(iDocPath)
        call aMsg.Document.CurrentVersion.CheckIn(iDocPath, 0)
        
        GetDocument = iDocPath
          
      end function

    Advansys Support

    #6694
    sstewart
    Participant

    Your sample code made it clear. Thanks for helping a newbie!
    Steve

    #6695
    Support 1a
    Participant

    No problems. Don’t hesitate to post if you have any other questions.

    Advansys Support

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