Wednesday, May 29, 2013

SharePoint 2013 CAML Query Designer - It's not only CAML query builder... More than that...

Karine Bosch and Andy van Steenbergen created new caml query designer. We can download it from biwug site by clicking on downloads and select caml designer.
SharePoint 2013 caml designer provides many more features including all features of SharePoint 2010 caml query builder with nice look and feel. Here is some screen shots with explanation.
Download the caml builder into your Dev server, select the .exe file and run as administrator.

CAML designer 2013 contains language interoperability. By default it is set to English. On the top left we can see two options CAML and Site Data Query to get queries. In the Top of the right side we can see Connection link and settings link with Refresh, Twitter follow us, Help.

By clicking on the settings link, we can see two tabs to set general and display settings as shown in the images below.

In the general settings, it allows us to clear the history and language settings. In display settings we have the option to set the background colors and lighting view.
By clicking on the connection link, we can see connection types (Server OM, Client OM, Web Services) and SharePoint version (SharePoint 2013, SharePoint 2010, Office 365) and the authentication credentials (Current user or allows us to enter the credentials) as shown in the image below.

For SharePoint 2010, we can see only Client OM, Web services options. (I think caml designer is detecting the current installed SharePoint version. So that it is not showing Server OM for SharePoint 2010).

For SharePoint 2013, we can see Server OM, Client OM, web services options as shown below.

For Office 365, we have Client OM and Web services options.

Here I have selected SharePoint 2013, Server Om and current User credentials. By clicking on the connect button, it will connects the SharePoint site. While connecting SharePoint site shows the message “Trying to connect….” As shown in the image below.

After connecting the site, it shows all the lists and libraries on the site as shows in the image.

Select a list for caml query; we have drag and options for view fields as shown in the image below.

Drag and drop the fields to see in the results.

In the “Order By” tab select the field to show in the order.

In the “Where” tab, select the options or logic by dragging the fields and setting the logic.

“Query Options” tab allows us to select the options.

We can results finally in “Test” tab for all these customization.

On the bottom window we can see CAML Query for customized logic. We can also see  Server OM code, .Net Client Object model code, Rest Client Object Model code as well as Web services. As shown in the images below.

In the Rest Services we have two options, JSON, ATOM as per the required result type.

You can see more explanation on CAML Query designer here

Tuesday, May 28, 2013

Set and Get property bag values in SharePoint 2013 apps using CSOM

Property bags are a place to store metadata or properties of SharePoint 2013 site. A Property bag is a key value pair, that can be used in Farm, Web Application, Site and Web level.
Following example shows how to write and read the property bag values of host web.
Following code shows how to write value in property bag. Here I am writing value for “Directory Tagged” key.

function tag() {
    var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
    var appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
    var clientContext = new SP.ClientContext.get_current();
    var hostContext = new SP.AppContextSite(clientContext, hostweburl);
    var web = hostContext.get_web();
    var webProperties = web.get_allProperties();
    webProperties.set_item("DirectoryTagged", true);
    clientContext.executeQueryAsync(TaggedSuccess, TaggedFail);

function TaggedSuccess(sender, args) {
    $("#results").text("Tagged your site.");

function TaggedFail(sender, args) {
    $("#results").text("Tagging failed");

In the following code Iam reading the value of “Directory Tagged” key value and the value is ‘True’ Iam disabling the button

function checkIfTagged() {
    var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
    var appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
    var clientContext = new SP.ClientContext.get_current();
    var hostContext = new SP.AppContextSite(clientContext, hostweburl);   
    var web = hostContext.get_web();

    //get all web properties
    webProperties = web.get_allProperties();
    clientContext.executeQueryAsync(getWebPropertiesSucceeded, getWebPropertiesFailed);

function getWebPropertiesSucceeded() {

    //Get all property fields
    var allProps = webProperties.get_fieldValues();
    var customProp = "";

    //Check property exists or not
    if (webProperties.get_fieldValues().DirectoryTagged != undefined) {
        var customProp = webProperties.get_fieldValues().DirectoryTagged;

    if (customProp == "TRUE")
        //property value is true                       
        $("#results").text("Site tag is true.");
        $("#btnTag").attr("disabled", "disabled");
    //property value is false
    $("#btnTag").bind("click", tag);
    $("#messageText").text("Site is tag is false.");

function getWebPropertiesFailed(args, sender) {
//log error message

Monday, May 27, 2013

Add current logged-in user to a new list item by using SharePoint 2013 Client Object Model

While working in SharePoint event registration with SharePoint-hosted app by using Client Side Object Model. In that code I had a requirement to add the current logged in user to list item. Here is the code to get the current logged-in user and add a new list item to the new list item.

var currentContext;
var web;
var user;

function init() {
//get current context
currentContext = SP.ClientContext.get_current();

//get current web details
web = currentContext.get_web();


function getCurrentUser() {
user = web.get_currentUser();
context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFailed);

function onGetUserNameSuccess() {
//custom code with current logged in user

function onGetUserNameFailed(sender, args) {
//log the error

function addNewItem()
// get the list for your item
var list = context.get_web().get_lists().getByTitle("ListName");

// create a ListItemCreationInformation object
var itemCreateInfo = new SP.ListItemCreationInformation();

// add this item to the list
var newItem = list.addItem(itemCreateInfo);

// Create a UserValue and set the LookupId to the current user
var userValue = new SP.FieldUserValue();
userValue.LookupId = user.get_id();

// Create a LookupValue and set the lookupId to the id of an event
var eventValue = new SP.FieldLookupValue();
eventValue.set_lookupId($("#Lookup Coloumn").val()); 

newItem.set_item('Title', user); //internal names
newItem.set_item('EventLookup', eventValue);

Function.createDelegate(this, this.onAddNewItemSucceeded),
Function.createDelegate(this, this.onAddNewItemFailed)

function onAddNewItemSucceeded() {
//custom code when Item Added Successfully
function onAddNewItemFailed(sender, args) {
//log the error


Thursday, May 23, 2013

Error exporting the list named “Announcements” at the URL: Lists/Announcements while saving site as template in SharePoint

One of my client having a requirement that to create sub sites programmatically using SharePoint site template location in solution gallery. We need to create a site with some lists and libraries and save it as site template by navigating to site settings and clicking on save site as template link. By doing this I got an error saying that,
Error exporting the list named “Announcements” at the URL: Lists/Announcements

Tried to rename the list, but got the same error with another list. By Checking the logs I have found the error message below,
SPSolutionExporter: System.NullReferenceException: Object reference not set to an instance of an object.

After some troubleshooting on the issue, I have found that few of custom content types not set to defaults in site and site collection level.

To fix this issue run the following power shell commands to disable and enable the content type feature.

Disable-SPFeature –Identity ctypes –url “Site Collection URL

Enable-SPFeature –Identity ctypes –url “Site Collection URL

After running this power shell commands there is no change in content types. Now we can save the site template with out any issues.

Wednesday, May 22, 2013

SharePoint - Back to Basics - Are you SharePoint Developer? What Kind of Developer you are?

As per my knowledge, I have divided SharePoint Developers into three categories. Each of them in three groups knows SharePoint very well.
Managing complex custom list and creating custom workflows are both come under Application maintenance. As per the knowledge on custom application development I have assumed the developers into three groups,

End User SharePoint Developer: End user SharePoint developer can have owner or contributor permissions on a site. He can able to create or modify list views (personal or Shared). He is able to change the complex list view to his needs by filtering and sorting the list data. User can add web parts and change the settings of the web part if he has owner permissions to page.
End User SharePoint Developer can use Internet explorer or any other web browsers.

Power User SharePoint Developer: Power User SharePoint Developer will have permissions for site owners or site collection Administrator. He can able to develop complex applications, site pages, and designer workflows. He can have knowledge to modify the web part pages, connecting external data sources and show the data in SharePoint site dashboards. He can have knowledge on JavaScript. He can develop the applications by using SharePoint Out of box features, so that we can see the results in a quick manner.
This user mainly uses Internet Explorer and SharePoint designer to build the applications.

Advanced SharePoint Developer: Advanced SharePoint Developer will have knowledge on SharePoint out of Box features, SharePoint Designer and Custom development using Visual Studio. He can able to build features, Solutions and workflows using Visual Studio. He will have command on everything in SharePoint as well as .net concepts.
This user uses Internet explorer, SharePoint designer and Visual Studio to do his work.

Here is the simple image differentiating the SharePoint Developers.

Saturday, May 18, 2013

"The form cannot be rendered. This may be due to a mis configuration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator," error while configuring legacy workflows in SharePoint 2013

I had a requirement to show the approval workflow form SharePoint 2010 in SharePoint 2013. By default in SharePoint document library we will have two workflows, Three state and expiry workflow.

When I try to create a workflow service without state service setup I got the following error,

The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator.

Generally a state service will automatically create at the time of SharePoint wizard creating our farm creation. If it is not created we can configure it by using the following power shell script.

$stateServiceApp = New-SPStateServiceApplication -Name "State Service"
New-SPStateServiceDatabase -Name "StateServiceDatabase" -ServiceApplication $stateServiceApp
New-SPStateServiceApplicationProxy -Name "State Service Proxy" -ServiceApplication $stateServiceApp -DefaultProxyGroup

After creating the state service, enable the site collection feature  (Site Settings > Site Collection Administration > Site Collection Features Enable SharePoint 2007 Workflows)


Wednesday, May 15, 2013

SharePoint – Back to basics – Why SharePoint is so famous?

Few of my friends who working on .net and other technologies always asking me questions, why SharePoint is famous?  Why organizations (mid and enterprise size) are preferring SharePoint?
Incredulously, there are now well over 10,00,00,000 global users, Fortune 500 companies using this multi-functional platform. It’s one of Microsoft's biggest businesses and in past 5-6 years Microsoft sold over 36 million user licenses…!!!!  A reasonable follow-up question is what exactly does SharePoint offer to businesses that are so widely sought after? Below are the three brief points can help to understand what exactly in SharePoint platform?

      Collaboration Every business on the planet has an imperative need of slick, collaborative processes for every type of operation. Microsoft’s platform helps not only centralize items of all file-types, but it provides harmonized online and offline ways for multiple users collaborate at once. Regardless of location and devices, we are able to log on to our collaborative, SharePoint-based environment to work with our colleagues on documents, projects, or business processes. Additionally, agenda's, contacts, reports, and pretty much everything else under the sun is all synchronized simultaneously. Users can expect a seamless, versatile experience when working together on online and offline applications.  All these changes are updated in an automated fashion with SharePoint's hosted, online library at the guide.All our data can be edited within our own browser so as to avoid necessary applications on our device. SharePoint offers a way for people to work together; regardless of location.

      Internal Controls Imagine never having to worry about who can access what. Just think on an environment where all of our woes as to who can see our financial reports. SharePoint offers an incredibly observing permission tool, allowing us as a business manager or owner to have constant, unhindered control. The interface of SharePoint is a simple-to-use dashboard of all the tools needed to assign and inherit permissions. When building a new site, SharePoint administrators and members (who are assigned through cloud accounts at the commencement of the online portal) can select not only who can visit the site, but what levels of permission they have; site visitor, contributor, administrator, etc. To take this to an even more incentive's step, you can optimize project management by creating sites for clients to log on to, establish agendas, store information while still preserving your infrastructural integrity by restricting the same clients to their own site through permissions.

      Data Management We can also experience the joy of accessing documents from any location on any device; be it laptop, desktop, phone, or tablet. In previous times, the only way to edit data was through direct file access, normally in an offline environment. Every uploaded file, regardless of type or size, can be categorized within different sites and libraries accompanied with unique workflow traits. SharePoint not only allows as team members or business owners to open up documents via the web, but to also synchronize work through document collaboration. Rather than engage us in the hassle of sending files to others to carry out needed edits.SharePoint's powerful content management platform allows us to build up document management solutions with standard policies within our internal environment. With managed metadata, classification, and flexible architecture, SharePoint helps us to classify documents quickly so people will save time in searching and retrieving information every time they need it. Businesses have literally been able to save millions as a result of SharePoint's search integration.

Monday, May 13, 2013

SharePoint 2013 Excel Services: We don’t know what happened. But something went wrong

While working with SharePoint 2013, checking the audit log reports in excel got the error as shown below. I have already configured the excel service as shown in the msdn

Checked the event logs, shows the error below.
Unable to access the workbook cache “C:\Windows\TEMP\Excel Server\FileCache\d8746073-d542-5f43-9b0d-45d345fd9f43\Workbooks. Excel Services Application unable to function without a workbook cache.

 After some troubleshoot found that the root problem is that to create or access the workbook. This is a permission issue. As a managed account, the Excel Services application pool is a member of WSS_WPG security group, to execute the permissions on the Temp folder.

To fix the issue I have followed the steps below,

Start -> run -> enter “%WINDIR%\Temp folder.

Click on properties, select security tab, click on Edit button

Add Modify permissions to WSS_WPG group and do IISRESET.

Now everything will work as expected.

Here we can grant permissions to each and every application pool. Here I just granted the permissions to the WSS_WPG group in other managed accounts need to create temporary cache files.

Thursday, May 9, 2013

SharePoint 2013-"The blob cache is not enabled in this web application. Image renditions will not be generated until the blob cache is enabled. For information on turning on the blob cache, please review the product documentation."

Image Rendition is new feature in SharePoint 2013, those users can re size the images to a fix predefined position to use them in web parts or pages. So that it can help us to improve the user experience of site by changing the image sizes. Using Image renditions we can save the image in different number of scaled variations. Dynamic rendering of the image will effect on the performance of the site. We can fix this by using image rendition.
We have to enable BLOB cache for image rendition. We can check Image rendition in Site Settings -> Image rendition in “Look and Feel” group.

 An Error message will be shown on the top of the page saying that “The blob cache is not enabled in this web application. Image renditions will not be generated until the blob cache is enabled. For information on turning on the blob cache, please review the product documentation”, if we are not enabled the blob cache.

Blob cache is a disk based caching feature. It will eliminate the database round trips in SharePoint. It will load the data from DB and saves on the web client and serves from cache. Generally Blob cache objects are images, Audio or Video files.
To enable Blob cache, Go to IISManger (Run -> inetmgr)

Go to site that need to enable Blob cache. Explore the site, find the web.config file.

Search for “BlobCache”, go to end of the line and make “enabled” value from “false” to “true” 

To use image rendition, publishing feature must be activated in the site.

Monday, May 6, 2013

“We’re having a problem opening this location in File Explorer, Add this web site to your Trusted sites list and try again” error while uploading multiple documents in SharePoint 2013

In SharePoint 2013 document library, to upload multiple documents , we need to select upload button on the top ribbon and click on the link “Upload Files using Windows Explorer Instead” in Add a document popup.

By clicking on the link, popup window has shown with error message “We’re having a problem opening this location in file explorer , Add this web site to your Trusted sites list and try again” as shown below.

I have added the site in IE trusted sites (Internet Options -> Security ->Trusted sites), But still iam getting the same error.
After goggling some time I have found that we need to enable the “Web client” service in windows services.
Go to Run, Type “services.msc”, press Enter

Check WebClient service, Right click on it, select Start.

If you not able to find web client service in services, need to add “Desktop Experience” feature in “User Interface and Infrastructure”.

After starting the “WebClient” service, refresh the browser and click on the link “Upload Files using Windows Explorer Instead”. Now it will open folder associated to Document library.

SharePoint 2013 Manager released

SharePoint 2013 manager got released. You can check and download SP2013 manager in codeplex.( SharePoint manager is one of the necessary tool for share point developers/administrators. SharePoint manager is also upgrading from share point 2007 to share point 2013. currently SPM 2013 is stable.

here is the screen shot for SharePoint 2013 manager,

While running the share point manager i got an error, the requested service http://localhost:32843/SecurityTokenServiceApplication/SecurityToken.svc not been activated

we'll get this error, if Secure Token Service Application pool not started in share point server, or permissions for .net service application pool not set to full trust. For more details check this url
Go to central administration, check secure store service is activated or not. And do iisreset.

Wednesday, May 1, 2013

Audit log reports in SharePoint 2013

Audit log reports in SharePoint, used to check who did what. We can check, sort, filter, and analyze the data in sites, lists, libraries, content types, list items, and library files in the site collection. It is very helpful for the organization. We can also save the audit log report as excel work book in specified site collection document library
Following events are available for auditing log reports to check who did what,
  • Viewed and downloaded items/documents
  • Checked In/ checked out items, moved and copied items in list/libraries
  • Deleted, restored items
  • Work flow and custom events in site collection
  • User permission changes at site collection level
  • Content type and column changes
Following are the reports available in share point auditing
  • Content Viewing -> shows all events where a user viewed content in this site.
  • Content modifications -> shows all events that modified content in this site.
  • Content deletion -> shows all events that caused content in this site to be deleted or restored from the Recycle Bin.
  • Content type and list modifications -> shows all events that modified content types and lists in this site.
  • Information management policy modification -> shows all events related to the creation and use of information management policies on content in this site.
  • Information management policy Expiration and disposition -> shows all events related to the expiration and disposition of content in this site.
  • Security and site settings Auditing -> shows all events that change the auditing settings of Microsoft SharePoint Foundation.
  • Security and site settings Security -> shows all events that change the security configuration of Microsoft SharePoint Foundation.
  • Custom report -> shows specified filters for audit report

We can view the audit log reports by clicking on the “Audit log reports” in Site collection Administration group in Site settings.

Configure auditing:
We have option to configure track which users have taken what actions on the sites, content types, lists, libraries, list items, and library files of site collections. In Site settings we can configure the audit logging by clicking on “Site collection auditing settings” in "Site Collection Administration" section.

Configure trimming:
When we select to audit an event in site collection, it will audited each time the event occurs. It will cause to generate a large number of audit log. This could cause degrading the performance and fills the memory in hard drive. To prevent this, we need to enable the audit log trimming in site collection. We can do this in site settings -> Site collection Administration -> Site Collection audit log settings.

Select “yes” for “Automatically trim the audit log for this site?” in “Audit Log Trimming” section. Specify number of days that audit log remain.