SPFile.SendToOfficialFile Method (Microsoft.SharePoint) Home
SPFile.SendToOfficialFile Method (Microsoft.SharePoint)
Sends the file to a records repository.
Overload List

Name Description
SPFile.SendToOfficialFile (out String)
Sends the file to a records repository.
SPFile.SendToOfficialFile (String, out String)
Sends the file to a records repository and specifies the name of a record routing type.
See Also

Community Content

SPFile.SendToOfficialFile
Added by:Denis Corbin

Description

The SPFile.SubmitToOfficialFile method enables you to perform the same action as when you use the context menu for an item to click Send To, and then click Official File. This process submits the file to the records center. The method has two overloads the SPFile.SendToOfficialFile (out String) and the SPFile.SendToOfficialFile(String, out String). The methods return an OfficialFileResult from the OfficialFileResult enumeration.

Usage Scenario

You would typically use the SPFile.SubmitToOfficialFile method as part of a workflow or event handler. By using this method you can automate the submission of a file to the record center. For example you may need to add to the record repository, all files that pass through a publications process. You may edit the workflow for this process to include a call to the SubmitToOfficialFile method. You use the return value provided by the method as part of your conditional logic for further steps. For example, if you receive a return of OfficialFileResult.Success you continue with the workflow, however if you receive the OfficialFileResult.FileCheckedOut you perform other actions.

The following code samples show how to send a file to the official record center for your farm by using the SPFile.SendToOfficialFile method.

C# Code Samples

  
SPSite siteCollection = null;
SPWeb web = null;
try
{
siteCollection = new SPSite("Server");
    web = siteCollection.OpenWeb("Site");
    SPFile file = web.GetFile("Source_Folder_Name/Source_File");
    String recordSeries = "";
    String additionalInformation;
    OfficialFileResult returnValue;
    returnValue = file.SendToOfficialFile(recordSeries, out additionalInformation);
    if (returnValue == OfficialFileResult.Success)
{
//Custom code for user notification
}

}
catch(Exception e)
{
//Error Handling
}
finally
{
if (web != null)
web.Dispose();
    if (siteCollection != null)
siteCollection.Dispose();
}

Visual Basic .NET Code Sample

Dim site As SPSite = Nothing
Dim web As SPWeb = Nothing
Try
site = New SPSite("Server")

web = site.OpenWeb("Site")
    Dim file As SPFile = web.GetFile("Source_Folder_Name/Source_File")
    Dim recordSeries As String = ""
    Dim additionalInformation As String = ""
    Dim returnValue As OfficialFileResult
    returnValue = file.SendToOfficialFile(recordSeries, additionalInformation)
    If returnValue = OfficialFileResult.Success Then
    'Custom code for user notification
    End If
Catch e As Exception
    'Error Handling
Finally
    If Not web Is Nothing Then
        web.Dispose()
    End If
    If Not site Is Nothing Then

site.Dispose()

End If
End Try
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View