Wednesday, October 29, 2014

Changes in Term values not getting reflected in Sites - Taxonomy Update Scheduler Job

Issue: I had a list containing some managed metadata columns bound to the respective term sets. I populated some items in the list. Then I went to the Term Store and modified a value of term that was used in one of the item. But when I went back to the list item, it was still showing the previous term only.
Reason: When doing any changes in the term store, there is a timer job called “Taxonomy Update Scheduler” that runs in background and synchronize the changes with the sites. So it will update the modified terms in the respective sites once it would run.  
Solution: You can check the status of this Taxonomy Update Scheduler timer job by following below steps:
·         Go to Central Administration.
·         Click on Monitoring on left navigation.
·         Then Under Timer Job Section, click on Check Job Status.
·         Then Under Timer Links heading on left navigation click on Scheduled Jobs.
·         On Top Right Side, under view selects Web Application and choose your web application.
·         You can find Taxonomy Update Scheduler Job from the list of specified jobs.
So there you can configure how frequently you want it to run according to your needs but generally it is configured to run every hour.
Once it runs, you can go back to the list item and check it would contain the modified term value.

Tuesday, October 28, 2014

Powershell script to create Managed Metadata Columns for each Term Set in a Term Store

I was writing a PowerShell script to create Managed Metadata columns in the library corresponding to each Term Set in the specified term store.
So below is the script with comments.

#This will load the SharePoint Snappin if not already loaded and also it will not throw any error if already loaded.
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin Microsoft.SharePoint.PowerShell
}

    #define SPSite and SpWeb Object
    $spSite = Get-SPSite "http://sharepoint.com"
    $spWeb = $spSite.OpenWeb("")

    #Get Taxonomy Session
    $taxonomySession = Get-SPTaxonomySession -Site $spWeb.Site
    #Get TermStore
    $termStore = $taxonomySession.TermStores["Managed Metadata Service"]
    #Get Term group corresponding to which columns would be created in the target  list
    $group = $termStore.Groups["Term Group"]
    #Get Reference to List
    $targetList=$spWeb.Lists["Target List"]
    for($i=0;$i -lt $group.TermSets.Count;$i++){
    
     #Get Current TermSet    
     $termSet = $group.TermSets[$i]
    
     #Check if another column is already present in the list.
     if(!($targetList.Fields.ContainsField($termSet.Name)))
     {
         $taxonomyField = $targetList.Fields.CreateNewField("TaxonomyFieldType", $termSet.Name)

         #Gets or sets the GUID that identifies the TermStore object, which contains the Keywords for the site that the current TaxonomyField belongs to.
         $taxonomyField.SspId = $termSet.TermStore.Id

         #Gets or sets the GUID of the TermSet object that contains the Term objects used by the current TaxonomyField object.
         $taxonomyField.TermSetId = $termSet.Id

         #if true then user can select multiple terms
         $taxonomyField.AllowMultipleValues = $true

         #group in which this field will be saved
         $taxonomyField.Group = $fieldGroup
         $taxonomyField.StaticName = $termSet.Name
         $taxonomyField.ShowInEditForm = $true
         $taxonomyField.ShowInNewForm = $true
         $taxonomyField.Hidden = $false
         $taxonomyField.Required = $false
         $targetList.Fields.Add($taxonomyField);

        
     }
    }   
    $targetList.Update(); 
    $spWeb.Dispose()
    $spSite.Dispose()
   
    Write-host “Script Completed"           

Wednesday, October 1, 2014

Error while adding/updating Items

I was creating a PowerShell script to add files to Shared Documents library. Everything was going fine. I was able to add files to the library but suddenly I got the below error while running the script.





It says URL “Shared Documents/new.txt” is invalid. I was looking for error in script if I had done something wrong but it was the same script that was working fine a minute ago.  Error also says “It may refer to a nonexistent file or folder” but file and folder both exists.
I was able to upload document to library using PowerShell but in different web app. Now it was confirmed that Script is fine. So error was not with Script but with something else.
I tried to add and edit items in document manually by going to Shared Document Library and I got the below error. I was getting the error while doing any CRUD operations.












On doing some testing, I found that there was not enough space on database server which was causing the issue.
So the issue got resolved by cleaning up the database server.



Wednesday, September 10, 2014

Strange Boxes in Nintex Workflow Designer

Recently I was developing a workflow in Nintex but while working on it I found some strange extra boxes on the designer as shown in the image.



This is really strange. I tried to Google out if anyone faced this strange thing but hard luck. After consulting with Nintex Support, came to know that these strange boxes appears in cases where some custom css is being referred on master page.
Good news is after extensively testing the workflows found out that these are just visual error and do not impact the performance of the workflow.


 

Monday, September 8, 2014

Error in "Pause for" Action - Nintex Workflows

Error in Pause for Action
Recently I was working on a project where I had to develop multiple workflows calling each other. To provide some delays I used “Pause for” action at the start of the workflow so that the all the other workflows should complete before the current workflow proceeds ahead.
But what I found during this implementation was, whenever workflow pauses for some duration lets say 1  minute at “Pause for” action it throws error. But interesting thing was, even after throwing error, workflow continues to run and completes successfully.
Email triggered says Workflow Terminated unexpectedly for item.
Error message logged was “Error POC 1” failed to run.
I got below information when I discussed this issue with nintex support.

Reason: Nintex workflows are run by SharePoint workflow engine only (i.e. Windows workflow foundation). Workflow is first executed generally in World Wide Web Publishing Services (w3wp.exe). After a delay or pause, in which the workflow "sleeps", it wakes up and is then run by the SharePoint Timer Service (the owstimer.exe process). The only time this isn’t the case is if the w3wp.exe is under excessive load, in which case it postpones the workflow and the Timer Service is then used to the continue the process.

SharePoint dictates which Workflow Timer Service will run the workflow - so this could occur on any server on which the "Microsoft SharePoint Foundation Workflow Timer Service" is enabled.

When Nintex is deployed it install’s some DLL’s required for workflows on the WFE’s where
 Microsoft SharePoint Foundation Web Application service is enabled.
So when Workflow Timer Service attempts to run a workflow where Microsoft SharePoint Foundation Web Application is disabled it throws error.

Solution:
1)      Disable Workflow Timer Service to all the WFE’s where Microsoft SharePoint Foundation Web Application service is disabled.
2)      Or Enable Microsoft SharePoint Foundation Web Application Service on all WFE’s.

Related Issues: So due to the above reasons not only “Pause for” action throws error but some below mentioned actions also throws error.

Change State: Since while changing state in a State Machine Workflow, a hidden delay is involved. So in that case also, it may throw error in case after delay it got caught by WFE where Microsoft SharePoint Foundation Web Service is disabled but Workflow Timer Service is enabled.

Pause Until: This action also throws error while in a paused state until some date is passed.

Assign Flexi Task: Due to the delay involved before sending reminders, it may error out.

Similarly Task Reminder Action, Request Data, or any other action where delay is involved may throw errors if occupied by wrongly configured WFE’s.