Showing posts with label SharePoint 2013. Show all posts
Showing posts with label SharePoint 2013. Show all posts

Tuesday, August 7, 2018

Discussion List Reply Link in SharePoint 2013 and Online

Initially it was possible to achieve this using calculated column and concatenate anchor tag and generate a link. However after latest CU release, this is not possible anymore.
Following steps will help you to create a hyperlink column for discussion reply link in SharePoint 2013 or Online. Also it will help you to create a normal calculated hyperlink column in SharePoint 2013 and Online.


1. Below snap in about Discussion list default view and you are targeting to create highlighted link.

2. Create new Single link text Calculated column and add it in Discussion content type.
PN: Select Do not add it in All Content Types while creating a column.


3. Create a simple list view and make sure it consists your new calculated column.


4. Now on the list view page, add new Script Editor or Content Editor webpart.


5. Insert following script to the webpart.


<script>
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
  Templates: {
        Fields: {

          //Replace "ReplyLink" with Calculated column name
           'ReplyLink': {'View':function(ctx) {
                  var url = String.format('{0}/Flat.aspx?RootFolder={1}/{2}', ctx.listUrlDir, ctx.listUrlDir,ctx.CurrentItem.Title);
                  return String.format('<a href="{0}" onclick="EditItem2(event, \'{0}\');return false;">{1}</a>', url, "Bid for the Job");
           }}
       }
  }
});
</script>




6. Save the page and you can access the link in Calculated column.


PN: Whenever you want such functionality, you need to add new webpart on list view page and insert the same script.

Friday, June 16, 2017

Create Site Collection in New Content Database in SharePoint 2010 / 2013

If you have a requirement where you need to Create a Site Collection in New Content Database, refer following PowerShell Script:

add-pssnapin Microsoft.SharePoint.PowerShell
$url = "http://sitecollection_link"
$ContentDatabase = "Content_DB_Name"
$WebsiteName = "New Site Collection Title"
$WebsiteDesc = "New Site Collection Description"
$Template = "STS#0" #It is for team site (use STS#1 for blank site)
$PrimaryLogin = "Domain\username1"
$SecondaryLogin = "Domain\username2"

New-SPSite -Url $url –ContentDatabase $ContentDatabase -Name $WebsiteName –Description $WebsiteDesc  -Template $Template -OwnerAlias $PrimaryLogin -SecondaryOwnerAlias $SecondaryLogin



Following script will create new content database and create site collection in newly created database. It is with parameters and also handles errors, so looks little longer :P


add-pssnapin Microsoft.SharePoint.PowerShell

#Set following parameters
$WebsiteName = "Test Site"

#Verify following parameters
$DbServer = "SQLServer"
$WebAppUrl = "http://webapplink"
#Uncomment if you are using managed path
#$ManagedPath = "path"
$DBName = "WSS_Content_" + $WebsiteName
$PrimaryLogin = "Domain\UserName"
$SecondaryLogin = "Domain\UserName"
$MaxSiteCount = 1
$WarningSiteCount = 0
$ContentDatabase = $null

#Create new content database
try
{
    $ContentDatabase = Get-SPContentDatabase $DBName -ErrorAction ignore
    if($ContentDatabase -eq $null)
    {
        New-SPContentDatabase -Name $DBName -DatabaseServer $DbServer -WebApplication $WebAppUrl -MaxSiteCount $MaxSiteCount -WarningSiteCount $WarningSiteCount -ErrorAction Stop
        Write-Host "Database Created Successfully" -ForegroundColor Green
        $ContentDatabase = Get-SPContentDatabase $DBName       
    }
    else
    {
        Write-Host "Database already exist." -ForegroundColor Red
    }


    #Set Parameters
    $url = $WebAppUrl + "/sites/" +$WebsiteName
    #Uncomment if you are using managed path
    #$url = $WebAppUrl + "/" + $ManagedPath + "/" +$WebsiteName
    $WebsiteDesc = "FieldDocs for year " +$WebsiteName
    $Template = "STS#1"

    #Create new site collection
    try
    {
        $site= $null
        $site = Get-SPSite $url -ErrorAction ignore   
       
        if($site -eq $null)
        {
            New-SPSite -Url $url –ContentDatabase $ContentDatabase -Name $WebsiteName –Description $WebsiteDesc  -Template $Template -OwnerAlias $PrimaryLogin -SecondaryOwnerAlias $SecondaryLogin -ErrorAction Stop
            Write-Host "Site Collection Created Successfully" -ForegroundColor Green
        }
        else
        {
            Write-Host "Site Collection already exist." -ForegroundColor Red
            $site.Dispose()
        }       
    }
    catch
    {
        Write-Host "Error in site collection creation" -ForegroundColor Red
    }
}
catch
{
    Write-Host "Error in database creation" -ForegroundColor Red
}


Saturday, October 5, 2013

"Sign in as Different User" in SharePoint 2013

To get this feature of sign in as different user back, we can follow either permanent or temporary solution:

Permanent Solution for all web applications

1. Locate the following file and open it in a text editor: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\Welcome.ascx

2. Add the following element before the existing "ID_RequestAccess" element:

<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser" Text="<%$Resources:wss,personalactions_loginasdifferentuser%>" Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>" MenuGroupId="100" Sequence="100" UseShortId="true" />

3. Save the file.

One time Temporary Solution 
Append /_layouts/closeconnection.aspx?loginasanotheruser=true after site url in browser's address bar.

Example: http://sp-dev-srv:7000/_layouts/closeconnection.aspx?loginasanotheruser=true