Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Submits the file for content approval with the specified comment.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
<ClientCallableExceptionConstraintAttribute(FixedId := "5", ErrorType := GetType(SPFileCheckOutException), _
ErrorCode := , Condition := "The file is not checked out")> _
<ClientCallableAttribute> _
<ClientCallableExceptionConstraintAttribute(FixedId := "1", ErrorType := GetType(SPException), _
Condition := "You can only publish, unpublish documents in a minor version enabled list. You cannot perform this action on a checked out document. You can only Unpublish a major version or approved document. Or Cancel publish for a pending document.")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "4", ErrorType := GetType(SPFileCheckOutException), _
ErrorCode := , Condition := "The file is already checked out")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "12", ErrorType := GetType(UnauthorizedAccessException), _
Condition := "Lack of permission to perform the operation")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "6", ErrorType := GetType(SPFileLockException), _
ErrorCode := , Condition := "There is an exclusive lock on the file")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "7", ErrorType := GetType(SPFileLockException), _
ErrorCode := , Condition := "There is a shared lock on the file")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "8", ErrorType := GetType(SPFileLockException), _
ErrorCode := , Condition := "The operation timed out")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "9", ErrorType := GetType(SPFileLockException), _
ErrorCode := , Condition := "The file is not locked")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "10", ErrorType := GetType(SPDuplicateValuesFoundException), _
ErrorCode := , Condition := "The list item could not be updated because duplicate values were found for one or more field(s) in the list")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "11", ErrorType := GetType(SPInvalidLookupValuesException), _
ErrorCode := , Condition := "The list item could not be updated because because invalid lookup values were found for one or more field(s) in the list")> _
Public Sub Publish ( _
comment As String _
)
'Usage
Dim instance As SPFile
Dim comment As String
instance.Publish(comment)
[ClientCallableExceptionConstraintAttribute(FixedId = "5", ErrorType = typeof(SPFileCheckOutException),
ErrorCode = , Condition = "The file is not checked out")]
[ClientCallableAttribute]
[ClientCallableExceptionConstraintAttribute(FixedId = "1", ErrorType = typeof(SPException),
Condition = "You can only publish, unpublish documents in a minor version enabled list. You cannot perform this action on a checked out document. You can only Unpublish a major version or approved document. Or Cancel publish for a pending document.")]
[ClientCallableExceptionConstraintAttribute(FixedId = "4", ErrorType = typeof(SPFileCheckOutException),
ErrorCode = , Condition = "The file is already checked out")]
[ClientCallableExceptionConstraintAttribute(FixedId = "12", ErrorType = typeof(UnauthorizedAccessException),
Condition = "Lack of permission to perform the operation")]
[ClientCallableExceptionConstraintAttribute(FixedId = "6", ErrorType = typeof(SPFileLockException),
ErrorCode = , Condition = "There is an exclusive lock on the file")]
[ClientCallableExceptionConstraintAttribute(FixedId = "7", ErrorType = typeof(SPFileLockException),
ErrorCode = , Condition = "There is a shared lock on the file")]
[ClientCallableExceptionConstraintAttribute(FixedId = "8", ErrorType = typeof(SPFileLockException),
ErrorCode = , Condition = "The operation timed out")]
[ClientCallableExceptionConstraintAttribute(FixedId = "9", ErrorType = typeof(SPFileLockException),
ErrorCode = , Condition = "The file is not locked")]
[ClientCallableExceptionConstraintAttribute(FixedId = "10", ErrorType = typeof(SPDuplicateValuesFoundException),
ErrorCode = , Condition = "The list item could not be updated because duplicate values were found for one or more field(s) in the list")]
[ClientCallableExceptionConstraintAttribute(FixedId = "11", ErrorType = typeof(SPInvalidLookupValuesException),
ErrorCode = , Condition = "The list item could not be updated because because invalid lookup values were found for one or more field(s) in the list")]
public void Publish(
string comment
)
Parameters
comment
Type: System.StringA string that contains the comment.
Exceptions
| Exception | Condition |
|---|---|
| SPException | The list item associated with the file is null or the SPList in which the list item locates does not support minor versions. -or- The value of the CheckOutType is Online. -or- An error occurred when publishing the file. |
Remarks
To call this method, the parent SPList of this file should support minor versions.