Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
ImportNewVersionCmd User Interface
System
Found the example of how to use the ImportNewVersionCmd
....
'Optional
'oContext.Add "IManExt.Import.DeleteLocalFiles", True
oContext.Add "IManExt.Import.FileName", "C:\Temp\Dummy Docs\testme.doc"
oContext.Add "iManExt.NewVersionCmd.NoCmdUI", True
' Skips the NewVersion Profile dialog
...
but I still get the dialog showing and the description field is always blank. How can I stop the dialog from showing and make sure the description has some data in it, thanks
Paul.
Find more posts tagged with
Comments
jny
Try using the NewVersionCmd instead:
Dim objCmd As IMANEXTLib.NewVersionCmd
Dim objContextItems As IMANEXTLib.ContextItems
Dim arrSessions(0) As IManage.NRTSession
Dim pOldDoc As IManage.NRTDocument
Dim pNewDoc As IManage.NRTDocument
Dim pNRTDMS As New IManage.NRTDMS
Dim pSession As IManage.NRTSession
' VB variables
Dim sServer As String
Dim sCheckoutPath As String
Dim sCheckinPath As String
Dim sUser As String
Dim sPW As String
Dim i As Long
Dim iErrs
On Error GoTo ERROR_HANDLER
' Assuming it's drive C
sCheckinPath = "C:\Temp\Dummy Docs\testme.doc"
' Hard code login values
sServer = "<servername>"
' Login as administrator
Set pSession = pNRTDMS.Sessions.Add(sServer)
pSession.TrustedLogin
' Get document
Set pOldDoc = pSession.PreferredDatabase.GetDocument(519, 1) 'Arbitrary example of a docnum & version
If Not pOldDoc Is Nothing Then
' Build portable path
sCheckoutPath = "C:\Temp\tempdoc.doc"
End If
' Put session into array
Set arrSessions(0) = pSession
' Check out old doc
If pOldDoc.CheckedOut = False Then
pOldDoc.CheckOut sCheckoutPath, nrReplaceExistingFile, Date, "checkout to import new version"
pOldDoc.UpdateProfile iErrs
End If
' Create a new ContextItems collection
Set objContextItems = New IMANEXTLib.ContextItems
' Populate the ContextItems collection with required values
objContextItems.Add "IManExt.NewVersion.Document", pOldDoc
objContextItems.Add "SelectedNRTSessions", arrSessions
' The session array should contain only one NRTSession object.
objContextItems.Add "IManExt.Checkin.FileName", sCheckinPath
' Designated the file path to upload.
'objContextItems.Add "ParentWindow", Me.hWnd
' The Window handle for the Window that should act as the parent for any modal windows displayed by the command.
' Optional values
objContextItems.Add "iManExt.NewVersionCmd.NoCmdUI", True
' Skips the NewVersion Profile dialog
' Dim bDontKeepCheckedOut As IManage.CheckinOptions
' bDontKeepCheckedOut = nrDontKeepCheckedOut
'
' objContextItems.Add "IManExt.Import.KeepCheckedOut", bDontKeepCheckedOut
' Option to keep imported file checked in / out.
' Create a new NewVersionCmd object
Set objCmd = New IMANEXTLib.NewVersionCmd
' Initialize the command with populated ContextItems collection
objCmd.Initialize objContextItems
' Use the Update method to find out if the command is available, _
based on the information posted to the ContextItems collection
objCmd.Update
' Check command status before execution. Use bitwise operation: the SDK example is incorrect.
If objCmd.Status = (objCmd.Status And nrActiveCommand) Then
objCmd.Execute
On Error Resume Next
Set pNewDoc = objContextItems.Item("iManExt.NewVersionCmd.Document")
' Returns a pointer to the new version NRTDocument object
If Not pNewDoc Is Nothing Then
' Unlock the new doc
pNewDoc.UnlockDocument
pNewDoc.UpdateProfile iErrs
pNewDoc.Refresh
End If
Dim newVerPath As String
newVerPath = objContextItems.Item("iManExt.NewVer.FileLocation")
' When finished using the ContextItems, _
remove them from the collection.
objContextItems.Remove "iManExt.NewVersionCmd.Document"
objContextItems.Remove "iManExt.NewVer.FileLocation"
End If
GoTo Cleanup
ERROR_HANDLER:
MsgBox Err.Description
Err.Clear
Cleanup:
' unlock old doc
If pOldDoc.CheckedOut = True Then
If pOldDoc.IsOperationAllowed(nrUnlockDocumentOp) = True Then
pOldDoc.UnlockDocument
Else
pOldDoc.CheckIn sCheckoutPath, nrReplaceOriginal, nrDontKeepCheckedOut, iErrs
End If
pOldDoc.UpdateProfile iErrs
End If
' If sPath exist, destroy it.
If sCheckoutPath <> "" Then Kill (sCheckoutPath)
' Logout and close app
If pSession.Connected Then pSession.Logout
pNRTDMS.CloseApplication
' Free memory
Set objContextItems = Nothing
Set objCmd = Nothing
Set pOldDoc = Nothing
Set pNewDoc = Nothing
Set pNRTDMS = Nothing
Set pSession = Nothing
Migrateduser
I copied this code and it nearly works, the only problem now is that I end up with a zero byte file being imported as the new version. I've checked that I have a valid file assigned to sCheckinPath, but I still get the zero byte new version. Any ideas?
jny
That sounds like the source code is not uploading the file you have specified in the contextitem. What you could do is instead of unlocking the new version, call checkin to upload the file:
If Not pNewDoc Is Nothing Then
If pNewDoc.CheckedOut Then
pNewDoc.Checkin "<filename>", imCheckinNewVersion, imDontKeepCheckedOut, iErrs
End If
' Unlock the new doc
'pNewDoc.UnlockDocument
'pNewDoc.UpdateProfile iErrs
'pNewDoc.Refresh
End If
robcom
...What you could do is instead of unlocking the new version, call checkin to upload the file: ...
Calling this checkin instead of unlock works for me (from Test VB App).
THANKS