Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Using Check In Method Programmatically

  Asked By: Vasudev    Date: Feb 06    Category: Sharepoint    Views: 3187

I have been facing few problems in using Check In Method of Knowledge
Version object. I can checkin a file but the contents of the file are
not updated.

Can anyone provide me with an example?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Ravish Patel     Answered On: Feb 06

You are saving and updating the knowledgedocument before the check  in?

 
Answer #2    Answered By: Satyajit Kabadagi     Answered On: Feb 06

Function GetFileName()
Dim kDoc 'As New PKMCDO.KnowledgeDocument
Dim kDocWorking 'As New PKMCDO.KnowledgeDocument
Dim kVer 'As New PKMCDO.KnowledgeVersion
Dim adoStream 'As ADODB.Stream
Dim sWorkingCopy 'As String
'create the objects
Set kDoc = CreateObject("CDO.KnowledgeDocument")
Set kDocWorking = CreateObject("CDO.KnowledgeDocument")
Set kVer = CreateObject("CDO.KnowledgeVersion")
Set adoStream = CreateObject("adodb.stream")
'set the file  we want to check  out and change
sURL = strWorkspaceUrl & "/documents/temp/donttouch.txt"
sFile = "c:\donttouch.txt"
'check out the file on the server
kVer.checkout sURL
'Get the file we checked out
kDoc.DataSource.Open sURL
'download the file to our local system (c:\donttouch.txt)
Set adoStream = kDoc.OpenStream
adoStream.SaveToFile sFile, 2
' get the "WorkingCopy" property of the file we just downloaded
kDoc.DataSource.Open sURL
sWorkingCopy =
kDoc.Fields("urn:schemas-microsoft-com:publishing:WorkingCopy").Value
Set kDoc = Nothing
'open the working copy and load into it the file from our local
system we just downloaded
kDocWorking.DataSource.Open sWorkingCopy, , 3
Set adoStream = kDocWorking.OpenStream
With adoStream
.Type = 1
.SetEOS
.LoadFromFile sFile
.Flush
End With
Set adoStream = Nothing
'play with the properties of the file (in this case I am adding
1 to the property SerialNuber)
filenum =
kDocWorking.Property("urn:schemas-microsoft-com:office:office#SerialNumber")
+ 1

kDocWorking.Property("urn:schemas-microsoft-com:office:office#SerialNumber")
= CInt(filenum) '"" & CInt(filenum) & ""
GetFileName = filenum
'update the fields and save the datasource!
kDocWorking.Fields.Update
kDocWorking.DataSource.Save
Set kDocWorking = Nothing
'checkin and publish, done!
kVer.checkin sURL
kVer.Publish sURL
End Function

 
Didn't find what you were looking for? Find more on Using Check In Method Programmatically Or get search suggestion and latest updates.




Tagged: