Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to Get the RecordCenterURL from Sharepoint2010,

  1. I have created Connection to Connect RecordCenter or DocumentRepository. I used this LINK

  2. When I try to Retrieve the OfficialFileUrl from Application, Its always return NULL value.

I have used this sample Code , Please help me for this Issue.

 string URL = "http://inblr-iifw8sv03:31521";

                SPSite site = new SPSite(URL);
                string recordCenterUrl = string.Empty;

                if (site.WebApplication.OfficialFileUrl != null)// This is Always NULL
                {
                    recordCenterUrl = site.WebApplication.OfficialFileUrl.ToString().
                        Replace("_vti_bin/officialfile.asmx", string.Empty);
                }

                Console.WriteLine("URL Found " + recordCenterUrl);
                Console.ReadLine();
share|improve this question

1 Answer 1

To get an official file host you need to use

site.webApplication.OfficialFileHosts

This contains an array of filehost. You can easy use powershell to create get and manipulate these hosts

For example to get an official host you can user this function

Function Get-SPOfficialFileHost{
[CmdletBinding()]
param(
    [Parameter(Mandatory=$true,ValueFromPipeline=$true, Position=0)][Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind] $WebApplication,
    [Parameter(Mandatory=$true)] [string] $Name
    )

    $WebApp = $WebApplication.Read()
    $officialFileHost =  $webapp.OfficialFileHosts | ? { $_.OfficialFileName -eq $Name }
    return $officialFileHost
}

or Create

Function New-SPOfficialFileHost{
[CmdletBinding()]
param(
    [Parameter(Mandatory=$true,ValueFromPipeline=$true, Position=0)][Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind] $WebApplication,
    [Parameter(Mandatory=$true)] [string] $Name,
    [Parameter(Mandatory=$true)] [string] $Url,
    [Parameter(Mandatory=$true)] [string] $Action,
    [Parameter(Mandatory=$true)] [string] $Explanation,    
    [Parameter(Mandatory=$true)] [switch] $ShowOnSendToMenu
    )

    $WebApp = $WebApplication.Read()

    $officialFileHost = Get-SPOfficialFileHost -WebApplication $WebApplication -Name $Name

    if ($officialFileHost -eq $null) {
        Write-Host "Add new Send To Connections..." -NoNewline
        [Microsoft.SharePoint.SPOfficialFileHost] $officialFileHost = New-Object "Microsoft.SharePoint.SPOfficialFileHost"
        $officialFileHost.Action = [Enum]::Parse([Microsoft.SharePoint.SPOfficialFileAction], $Action)
        $officialFileHost.Explanation = $Explanation
        $officialFileHost.OfficialFileName = $Name
        $officialFileHost.OfficialFileUrl = $Url.TrimEnd("/") + "/_vti_bin/officialfile.asmx" 
        $officialFileHost.ShowOnSendToMenu = [bool]::Parse($true)
        $webapp.OfficialFileHosts.Add($officialFileHost)
        $webapp.Update()
        Write-Host -ForegroundColor Green " - Done."   
    }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.