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)
SetAttributeValueByID on late bound nrtDocument
David_ISA
Hi,
I'm writing some vb script code to log into the Worksite server, then import a document setting some of the profile attibutes but i'm getting a "The Parameter is incorrect" when i try to set the author, operator or any of the custom attributes using the SetAttributeValueByID function.
The same code works if I have a reference to the 'iManage 8 type library' and early bind my nrtdocument object but as its vbscript i have to late bind it which is giving me this error.
Is there a workaround for this?
Many thanks.
Here is the code i am using.
Sub TestImport()
Dim NewFile As String
Dim Partner_WS_Dept As String
Partner_WS_Dept = "TBA"
NewFile = "C:\Temp\sampleletterdoc"
'************** Start Worksite variables ***************
Const WorksiteServerName = "dms"
Const WorksiteDatabaseName = "legal"
Dim pNRTDMS
Dim pSessions
Dim pSession
Dim pDatabase
Dim pDocument ' As NRTDocument <-- if you aff the iManage 8 type library reference and uncomment this it works
Dim llngSaveErrNumber
Dim lstrSaveErrDesc
Dim errs
Const nrType = 7
Const nrClass = 8
Const nrDescription = 3
Const nrAuthor = 5
Const nrOperator = 6
Const nrCustom1 = 25
Const nrCustom2 = 26
Const nrCustom3 = 27
Const nrNewDocument = 1
Const nrDontKeepCheckedOut = 0
'************** End Worksite variables ***************
'********* Start log into worksite ***********************
Set pNRTDMS = CreateObject("IManage.NRTDMS")
Set pSessions = pNRTDMS.Sessions
Set pSession = pSessions.Add(WorksiteServerName)
On Error Resume Next
'pSession.TrustedLogin
pSession.login "dtai", "password"
llngSaveErrNumber = Err.Number
lstrSaveErrDesc = Err.Description
If llngSaveErrNumber <> 0 Or Not pSession.Connected Then
MsgBox "Unable to login to Worksite: " & lstrSaveErrDesc
Exit Sub
End If
'Try to get a handle of the Legal database
Set pDatabase = pSession.databases(WorksiteDatabaseName)
llngSaveErrNumber = Err.Number
lstrSaveErrDesc = Err.Description
If llngSaveErrNumber <> 0 Or Not pSession.Connected Then
MsgBox "Unable to get " & WorksiteDatabaseName & " Worksite database: " & lstrSaveErrDesc
Exit Sub
End If
On Error GoTo 0
'********* End log into worksite ***********************
'Import a document
Set pDocument = pDatabase.CreateDocument
pDocument.SetAttributeValueByID nrType, "WORD"
pDocument.SetAttributeValueByID nrClass, "LETTER"
pDocument.SetAttributeValueByID nrAuthor, "DTAI"
pDocument.SetAttributeValueByID nrOperator, "DTAI"
pDocument.SetAttributeValueByID nrDescription, "Sample letter"
pDocument.SetAttributeValueByID nrCustom1, "OFFICE"
pDocument.SetAttributeValueByID nrCustom2, "00006666"
pDocument.SetAttributeValueByID nrCustom3, Partner_WS_Dept <---- I get a paramter incorrect error here
pDocument.CheckIn NewFile, nrNewDocument, nrDontKeepCheckedOut, errs
If errs <> "" Then
MsgBox "Error occured checking in document " + errs
Else
MsgBox pDocument.Number
End If
End Sub
Find more posts tagged with
Comments
David_ISA
Oops, i forgot to mention that SetAttributeValueByID works if you assign a static value to the field but gives the error when you assign a value from a variable.
DaleN
Try changing the SetAttributeValueByID line to force the variable to be passed in as using a String format
pDocument.SetAttributeValueByID nrCustom3, CStr(Partner_WS_Dept)
Regards,
Dale