Wednesday, 30 December 2015

Office 365 Workflow (Default Functionality)

A - OBJECTIVE: after you have subscribed to Office 365, you can leverage on its out-of-the-box workflow mechanism & functionality to build processes.

Note: You are supposed to have SharePoint Designer 2013 (free of charge). Visio (licensed) is a nice to have tool when your workflow is complicated.

B - PROBLEMS :

Several scenarios will be described in section C but the default workflow functionality is quite limited in terms of utilities for large-scale & complicated workflows.

Considerations in workflow design:

1. For workflow at list or library items, try to finish the workflow whenever it is possible ; i.e. not keep the workflow in the standby mode because it will consume resources immensively.

2. For site workflow, try to run it once a day

3. At the end of each stage, the section "Transition to stage" only allow you to go to two other stages including "End of Workflow" stage (i.e. an IF clause with only 2 branches).

4. Workflow Task List & History List should be newly created for each workflow because of the default limitation of 5,000 items per list.

5. Permission to run workflow: if you try sending emails to some SharePoint groups in the workflow but you do not have permission to view the Group, the workflow will be suspended.

If you are keen to build a more complicated process at Office 365, a third-party product called Nintex for Office 365 can be considered with a separate cost http://www.nintex.com/workflow-platform/nintex-workflow/workflow-for-office-365

C - SOLUTION:

Scenario 1: to build a review & approval process

Step 1: admin group will be notified whenever there is a new document added into the library.


Step 2: after assessed (i.e. Status is not Submitted anymore), check if the document is rejected



Step 3: if the admin approves the documents for being reviewed


Step 4: to set the all reviewers to local variables


Step 5: to email to all reviewers when there is a review added to the document


Step 6: when all reviews are added (which is 3 in this case), the admin will be notified


Scenario 2: to build a daily reminder process



At line 2 of the scenario 2, mouse over the whole action, click Properties. In the RequestHeaders box, choose the variable dictionary




D - SOURCE CODE:

To provide source code

Topic Coverage in this blog:

1. SharePoint
2. Enterprise Content Management
3. Database

Recommendation Foci:

1. Best Practices
2. Safeguarding Measures against future error re-occurrennces.

Thursday, 6 March 2014

Search Service Application

A - OBJECTIVE: to create a new Search Service Application.

B - PROBLEMS :

1. Search Application: Index Component grows bigger when more content is populated at SharePoint farm.

2. Available Drive Space: this should have at least twice the value of physical memory (RAM). By default, all Search components are saved at C drive and it will consume this drive; hence, it leads to many operational issues. For example: permissions removed silently due to the problem at Virtual memory swap file.

C - SOLUTION:

1. Search Availability: to ensure the Search service is available to users, "Query Processing" and "Index" components should be replicated at all SharePoint servers.


2. Index Components of Search Application should be allocated at a separate drive to cater for future growth & access speed.
# to move the Index Components at all SharePoint servers to drive I
New-SPEnterpriseSearchIndexComponent -SearchTopology $new -IndexPartition 0 -SearchServiceInstance $hostWFE1 -RootDirectory "I:\FEOshareSearchComponents2015"
New-SPEnterpriseSearchIndexComponent -SearchTopology $new -IndexPartition 0 -SearchServiceInstance $hostWFE2 -RootDirectory "I:\FEOshareSearchComponents2015"
New-SPEnterpriseSearchIndexComponent -SearchTopology $new -IndexPartition 0 -SearchServiceInstance $hostApp -RootDirectory "I:\FEOshareSearchComponents2015"


D - SOURCE CODE:
### GET THE EXISTING ENVIRONMENT PARAMETERS ###
$ssa = Get-SPEnterpriseSearchServiceApplication "Search Service Application - FEOshare"
$current=Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$new=New-SPEnterpriseSearchTopology -Clone -SearchApplication $ssa -SearchTopology $current


# list all search servers deployed in the farm
$hostApp = Get-SPEnterpriseSearchServiceInstance -Identity "kc1mspappprd01"
$hostWFE1 = Get-SPEnterpriseSearchServiceInstance -Identity "kc1mspwfeprd01"
$hostWFE2 = Get-SPEnterpriseSearchServiceInstance -Identity "kc1mspwfeprd02"

# check the settings of the search application
Get-SPEnterpriseSearchStatus -SearchApplication "Search Service Application - FEOshare"


### RE-CONFIGURE TO ALLOCATE SEARCH COMPONENTS ###

# delete the old configuration at the default location (drive C)
$del = Get-SPEnterpriseSearchComponent -SearchTopology $new | ? {$_.Name -eq "IndexComponent1"}
Remove-SPEnterpriseSearchComponent -Identity $del -SearchTopology $new


# create new INDEX components at new location
# must configure RootDirectory https://technet.microsoft.com/en-us/library/jj219721.aspx
New-SPEnterpriseSearchIndexComponent -SearchTopology $new -IndexPartition 0 -SearchServiceInstance $hostWFE1 -RootDirectory "L:\FEOshareSearch2015"
New-SPEnterpriseSearchIndexComponent -SearchTopology $new -IndexPartition 0 -SearchServiceInstance $hostWFE2 -RootDirectory "L:\FEOshareSearchComponents2015"
New-SPEnterpriseSearchIndexComponent -SearchTopology $new -IndexPartition 0 -SearchServiceInstance $hostApp -RootDirectory "I:\FEOshareSearchComponents2015"


# create new QUERY PROCESSING component at new location
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $new -SearchServiceInstance $hostWFE1
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $new -SearchServiceInstance $hostWFE2

### SET THE NEW TOPOLOGY TO BE ACTIVE ###
Set-SPEnterpriseSearchTopology -Identity $new

Tuesday, 14 May 2013

Database Restoration at WSS 3.0

A - OBJECTIVE: to restore an .mdf file to an existing SharePoint farm (a backup file is an older version of the existing database).

B - PROBLEMS :

 1. The content database can be restored by the MS SQL server. However, the web application cannot recognize the attached database (Number of Sites is 0)

2. The Site ID of the backup database is the same as the Site ID of the current database.


C - SOLUTION:

To manually configure the stsadm & Powershell commands

D - SOURCE CODE:

1)
Detach site
stsadm -o deletecontentdb -url http://test/teams/site -databasename DMS_Teams_Site -databaseserver DBSERVER

2)
Restore new DB

3)
Attach Site
stsadm -o addcontentdb -url http://test/teams/site -databasename DMS_Teams_Site  -assignnewdatabaseid

4)
Check if the contentDB is listed Sharepoint admin under Content Databases
If the “Current Number of sites is 0′ then follow this process to resolve

5)
Check is the site is listed under Site Collections
e.g /teams/site

6)
create a site collection with same settings

7) Check content Database list again to see if there if current number of Sites = 1

8) Goto database server

use DMS_Teams_Site
select ID, TimeCreated from dbo.Sites

You will see two ID’s listed and the one old one is next to the earliest date.

05D84414-B498-455C-BA15-3155C92349C3 2008-06-13 13:30:02.000
5FC42416-6554-4E4F-B55B-3E106110A20E 2009-09-30 13:39:35.000

Copy the old ID to the clipboard

9) Now check the ID ised in the SharePoint_Config for the site.

use SharePoint_Config
select ID, Path from dbo.SiteMap where path = ‘/teams/site’

5FC42416-6554-4E4F-B55B-3E106110A20E /teams/site
10) Now replace the ID of site in SharePoint_Config with the old ID

use SharePoint_Config
update dbo.Sitemap
set Id = ’05D84414-B498-455C-BA15-3155C92349C3′
where Path = ‘/teams/site’

11) Perform an IISRESET on all the servers

Note: to change SiteID of the backup database, please go through all tables in the database & manually change the SiteID :

    AllDocs
    AllDocStreams
    AllDocVersions
    AllLinks
    AllUserData
    AlluserDataJunctions
    AuditData
    BuildDependencies
    ComMd
    ContentTypes
    ContentTypeUsage
    Deps
    Features
    GroupMembership
    Groups
    ImmedSubscriptions
    NameValuePair
    NavNodes
    Perms
    RecycleBin
    RoleAssignment
    Roles
    SchedSubscriptions
    ScheduledWorkItems
    Sites
    SiteVersion
    UserInfo
    Webs
    WebpartList
    WebParts
    Workflow
    WorkflowAssociation

ALL DONE Now should see the correct website.

Note: at step 10, attaching the content DB to the same SP farm that is using the current content DB will cause a problem because SP won’t allow two databases with the same ID –> use PowerShell to “mount” the content DB:

Mount-SPContentDatabase [-Name] <String> [-WebApplication] <SPWebApplicationPipeBind> [-AssignNewDatabaseId]
Example:
Mount-SPContentDatabase “Contoso Sales” -WebApplication http://contoso/sales -AssignNewDatabaseId

Friday, 15 March 2013

Remove Pending Deployed Solutions

A - OBJECTIVE: to describe a high-level objective.

B - PROBLEMS :

Using stsadm to deploy a solution, a timer job for deployment is created but its state is always “pending”

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm -o enumdeployments
<Deployments Count=”1″>
<Deployment JobId=”7547c94e-5b2a-4619-88a4-93306319ec6d”>
<Title>Windows SharePoint Services Solution Deployment for “samplesolution.wsp”</Title>
<Type>Deployment</Type>
<State>Pending</State>
<Schedule>3/15/2013 12:14 PM</Schedule>
<File>sharepointboost.licensecentersetup12.3.wsp</File>
<ServerType>Front-end Web server</ServerType>
<Target>http://feowss01/</Target&gt;
</Deployment>
</Deployments>

Troubleshooting:

– Ensure that the deployment lock is released at all server by stsadm:

stsadm -o removesolutiondeploymentlock


C - SOLUTION:

– In my case, there was a server which had been removed out of the farm. Hence, deployment for the whole farm (including all servers) will surely encounter the above problem.

– The expected stsadm command is to use “local” parameter for one current server at a time

stsadm -o deploysolution -name “timerjobmanager.wsp” -url “http://testsite&#8221; -local -allowgacdeployment -force

Tuesday, 26 February 2013

Change Values at "Read-Only" fields

A - OBJECTIVE: to complete a proper data migration with correct authors & editors ("Created By" & "Modified By")

B - PROBLEMS :

Admins cannot "edit" Read-Only fields at SharePoint in a straight-forward method.

C - SOLUTION:

As an admin, you can open Powershell and run the below code to update these Read-Only fields:

Experiment 1: to update Modified Time, Created Time, Author & Editor

$author = New-Object Microsoft.SharePoint.SPFieldUserValue($web,”1111;#User Display Name”)  #1111 is User ID in All People List
$item[“Author”] = $author
$item.Properties[“vti_author”] = $author.User.LoginName
$item[“Editor”] = $author
$item.UpdateOverwriteVersion()

Result : Successful

Experiment 2: to update File/Folder Name, Modified/Created Time & Author/Editor

First Try:


# get the original metadata
$personEditor = $Folder.Item["Editor"]
$timeModified = $Folder.Item["Modified"]

# update the folder name
$Folder.Item["Name"] = "New Name"

# revert the original metadata back
$Folder.Item["Editor"] = $personEditor
$Folder.Item["Modified"] = $timeModified

$Folder.Item.UpdateOverwriteVersion()

Result : Failed (Folder Name is updated but Modified Time & Editor are not updated)

Second Try:

# get the original metadata
$personEditor = $Folder.Item["Editor"]
$timeModified = $Folder.Item["Modified"]

# update the folder name
$Folder.Item["Name"] = "New Name"

# THIS LINE IS IMPORTANT TO BE ADDED IN
$Folder.Item.UpdateOverwriteVersion()

# revert the original metadata back
$Folder.Item["Editor"] = $personEditor
$Folder.Item["Modified"] = $timeModified

$Folder.Item.UpdateOverwriteVersion()

Result : Successful (All fields are updated properly).

D - SOURCE CODE:

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
$site = New-Object Microsoft.SharePoint.SPSite(“http://sharepoint/subsite”)
$web = $site.OpenWeb()
$doclib = $web.Lists[“TestDocLib”]
Write-Host “SharePoint Object: ” $doclib.basetype
foreach($item in $doclib.Items){
Write-Host “Created By – Old Value: ” $item[“Author”]
$author = New-Object Microsoft.SharePoint.SPFieldUserValue($web,”1111;#User Display Name”)  #1111 is User ID in All People List
$item[“Author”] = $author
$item.Properties[“vti_author”] = $author.User.LoginName
$item[“Editor”] = $author
$item.UpdateOverwriteVersion()
Write-Host “Created By – New Value: ” $item[“Author”]
}

Wednesday, 23 January 2013

Update Search Results in WSS 3.0

A - OBJECTIVE: to manually run Search Crawling & Indexing at WSS 3.0 (aka SharePoint 2007)

B - PROBLEM:

A new list with its items was created but it is not shown in the Search result (even 2 weeks after the creation date).

C - SOLUTION:

To configure database settings & use stsadm commands.

D - SOURCE CODE:

1. Database Permission: ensure the account (used for Search crawling/indexing) should have expected access rights (e.g. dbowner, dbcreator, etc):

– Open the DB server by Management Studio

– Right click at the Server Name, then choose Properties

– At Permission option, select the Account & grant permissions

2. SharePoint Config:

– Central Administration > Operations > Services on Server > Windows SharePoint Services Search Service Settings => Configure “Indexing Schedule”

* Note (9 Mar 2013): if you don’t see “WSS Search Sevice”, you can start it by stsadm -o spsearch -action start

– Site Actions > Site Settings > Search Visibility => to ensure the web is visible for Search

– Listing Settings > Advanced Settings > Allow items from this list to appear in search results? Yes => Allow list items to be searchable

3. Manual Crawl:

– Stop Crawling by: stsadm –o spsearch –action fullcrawlstop
– Start a Full Crawl: stsadm –o spsearch –action fullcrawlstart

* Note: Full command guide: http://technet.microsoft.com/en-sg/library/cc288507%28v=office.12%29.aspx

4. Check Database: Open the Search Database & look for information at:

– [MSSCrawlContent]: list all crawls so far => after you start a new crawl, a new row is added for your reference.

– [MSSScopes]: show Search Scopes (e.g. All Sites or People Search).

– [MSSCrawlHostList]: show all crawl rules with the success/error/warning messages for the latest crawl => it can be used to check if the crawl is happening by refreshing the SELECT statement frequently.

– [MSSCrawlURL]: show successful crawled URLs