Wednesday, February 17, 2016

K2 Vs Nintex workflows for SharePoint

Areas
K2
Nintex
Business
·         Good tool for representing processes visually
·         Support for delivery of data to process approvers and other stakeholders that includes the information they need to perform their role in the process in a friendly format. Ability to show them the data they need to make a decision on a variety of devices, and to record their decisions.
·         Good tools for monitoring and reporting process performance and identify delays.
·         Nintex Workflow is GUI base and easy to use. It is suited for workflows that are not too complex. It would be great to have more in depth training and the user guide has room for improvement as well
·         Nintex is a great tool for a logical, tech-minded individual without official development skills.

Support
·         K2 as has best support and great community base
·         Nintex lags in support
Advantages
·         User friendly
·         Reporting capability
·         Auditing capability
·         Workflow and business process management
·         Line of Business Data integration
·         Good for large data pulling
·         Easy upgrade to new versions
·         Non-technical users can implement somewhat complex solutions.
·         Email notifications easy.
·         Can see workflow task history visually.
·         Administration for Nintex is easy
Disadvantages
·         We found SharePoint's built-in process tools clumsy, hard to re-use, and not very powerful or flexible.
·         Getting setup to where you're actually start using the product can be quiet complex and the instructions are not quite clear
·         Error messages are completely vague, making it extremely difficult to debug.
·         Failures occur for random reasons.
·         Error notifications get sent out too frequently which confuse users.
·         Have performance issue when pulling larger lists
·         Support nightmare for failed workflows.
Cost
·         K2 blackpearl (enterprise) has a fixed cost for unlimited users and servers
·         Nintex has a price per web front-end.  This is key consideration when farming out multiple SharePoint front-ends.
Integration
·         K2 blackpearl provides exclusive activity/event library addressing common systems and scenarios ( AD integration for user management, Exchange integration, SAP, Salesforce,SharePoint integration for actions such as document management, user management, CRM). It also provides excellent framework to connect to LOB systems using Smart Objects. This helps developer’s focus on core process logic than interface details.
·         Nintex also is very tightly integrated with SharePoint and lacks integration ability to external LOB in the enterprise.
·         It also connects to databases and CRM systems, or integrating your SharePoint content with social media platforms
Conclusion
·         K2 is for medium to large budget, scaling to enterprise in IT pro-environment
·         Nintex is best suited for small business solutions which deals with lesser data and business can easily create workflows without any developer

.

Tuesday, September 8, 2015

Provider hosted app security in SharePoint apps


Check the below link, it was in detail.
https://samlman.wordpress.com/2015/03/02/security-in-sharepoint-apps-part-1/

Thursday, September 3, 2015

New Features in SharePoint 2016


  1. Role based configuration wizard for configuring a server role

  • Front end 
  • Application
  • Search
  • Specialized load
  • Distributed cache
  1. Zero downtime patching
  2. App launcher for on premise has been introduced
  3. Office 365 api's coming to On-premise 
  4. No Standalone machine any more there should be two servers two install SharePoint now one for SharePoint and other for Sql server
  5. No Foundation version any more
  6. Build one and deploy into two environments(for one premise and office 365)

Wednesday, September 2, 2015

BCS in Office 365


We can also call BCS an ORM(object relational map)
Secured store service is used to connect to external sources using different accounts apart from the organizational accounts

The main steps involved in devlopemt using BCS are:

  1. Creating external content types using designer or VS
  2. Importing external content type to BCS
  3. Configure the secured store
  4. Creating external lists
  5. Creating apps
Creation of App level ECT(external content type)

FileBackedMetadatCatalog loads External content type into it to easy access and also for creation of external lists
Specific finder is a method that is used to find one particular item, it is similar to a view on a list but i only returns one item on a list
We are have all the CRUD operational method for ECT to do
Sample code to connect to a list

Tuesday, September 1, 2015

Debugging Remote Event Recievers

  1. We must create a new azure service bus namespace using azure powershell
  2. The command give back a connection sting to connect to Azure environment with EndPoint
  3. Use this in visual studio for connecting to azure
  4. go to project properties
  5. inside that go to SharePoint tab
  6. Check the enable debugging via Azure service bus
  7. copy past the connection string that we got from command prompt
  8. insert a breakpoints and click on F5 for debugging

Remote event receivers in SharePoint 2013


The remote events supports

Site - Create, Move, Delete
List - Create, Delete
List schema - Create, Update, Delete
List Item - Create, Update, Delete, Move, CheckIn, UnCheckIn, CheckOut, AttachmentsAdded, AttachemntsRemoved, FileMoved, FileConverted
App - Install, Update, Uninstall

Some Impotent Points to be noted:
  • Remote event receivers call across the networks
  • After events use WCF(Windows communication foundation) call on remote web so that they do not block the sharepoint host nor delay the response back to the user
  • Remote event recievers will only workf if the concern list is present in App Web
  • SharePoint hosted apps doesnt support remote event receievers, its only provider hosted apps
  • IRemoteEventService an interface thats get inherited in remote event recievers
  • We have only two events called "ProcessEvent" which is a two way event and "ProcessOneWayEvent" for one way
  • Properties argument defines the event that has fired on a list item
  • We will be having only single entry point for all the events
  • Properties.ItemEventProperties is for an item events and Properties.ListEventProperties for list events
  • SPRemoteEventResult which is used to sent status back to SharePoint(used for sending information and also for canceling the events)


Before events example

After events example



  • App Life Cycle events are two way events
  • "ProcessOneWayEvent" never file in App related events
This are just brief points about remote event recievers.

Monday, August 31, 2015

points to be noted on Event receivers in SharePoint 2013


properties.ErrorMessage is used for showing error in event handlers
properties.ListItem.Updateoverwriteversion() is used to overwrite version in list item, rather than adding a new version to the item it overwrites the existing one.
this.EventFiringEnable = false or True to stop or start the events on a list item, when ever you use "Updateoverwriteversion()" method inside a event we should set "this.EventFiringEnable= True" to stop the recursion 

Thursday, August 27, 2015

SharePoint 2013 People Picker error: “Sorry, we’re having trouble reaching the server.”


If you see the above error while adding users to a group or to a site there are many resolutions which are out there in internet.

but for me i have tried everything which i seen based on the above error but nothing worked out, finally after extending the web application to new port number and deleting the same, the issue got fixed


Hope this helps others.

News feed error: SharePoint could not retrieve the content. Please try again later




If you see this error message, ther could be an issue with user profile service, Authentication issue and may a with distributed cache.

if you have already checked all of the above and still seeing the same issue, then check the microfeeds list and see whether you are able to see the items in it.

if you are not able to see items in micro feeds list, increase the threshold value of lists from 5000 to 10000 or something...

by default administrators have 20000 has the limit for each list so there will be no issues for administrators on news feeds.

we have figured it out when we see the above error while trying to access "Show all replies" inside a news feed.

Hope this helps others.



Monday, April 27, 2015

Oracle LDAP and SharePoint 2013 integration

I have came across a post for oracle and SharePoint 2013 integration, i think this will help other too.

http://blogs.msdn.com/b/ronalg/archive/2014/04/14/sharepoint-2013-and-forms-based-authentication-configuration-for-open-ldap.aspx


Friday, December 19, 2014

Setting Timespan for forms authenticated user in SharePoint

If you want to make user logout after one min of idle status try the below code, this is only for forms authenticated users.
Run the below script in powershell script

$Data = Get-SPSecurityTokenServiceConfig
$Data .UseSessionCookies = $true
$Data .FormsTokenLifetime = (New-Timespan –Minutes 2)
$Data .LogonTokenCacheExpirationWindow = (New-Timespan –Minutes 1)
$Data .Update() 

Enabling session in SharePoint


Error:System.Web.HttpException: Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration.

When you see the above error try the below resolution
Enable-SPSessionStateService -DefaultProvision

I have tried many solutions that are out there on other site but nothing seems to resolve my issue
finally used powershell command and site came up like magic.

Thursday, December 18, 2014

Important points on OAuth for SharePoint 2013


first and most important point is that OAuth is for apps and not for users in SharePoint
OAuth is Web Standard to manage permissions and security for modules like App on Web
OAuth is used to authenticate and authorize app and service
If you are developing an app on SharePoint online there is no need to create OAuth exclusively, it is integrated with the app by default
If development is done on SharePoint Onprem then we have two options:

1.Create a "high trust" app and deploy it, in this scenario tactically there wont be OAuth because there wont be any Authentication server(ACS) to send and get tokens. this type of method is used for creating internal Apps with in the network.

2.The other way is having an azure account and
   Set up SP2013 with Azure account
   create a certificate for SharePoint 2013
   register it in SharePoint server
the above all process is not so easy which it looks like.

CRUD operations in SharePoint 2013 using REST and C#.Net

Below is CRUD operations on a SharePoint list using Rest and C#
to get this working replace site with your site name
here i am using ContactList for CRUD operations


using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Xml;
namespace REST
{
    class Program
    {
        static string sharepointUrl = "http://Site/_api/web/Lists/getByTitle('ContactList')/items";
       public static Stream postStream;
       public static string results;
       public static string newFormDigest;

        static void Main(string[] args)
        {
            GetItems();
            PostItems();
            UpdateItems();
            DeleteItem();

         
        }

        private static void DeleteItem()
        {
             //184 in the below url is Item ID of a list
            Uri uri = new Uri("http://Site/_api/web/lists/GetByTitle('ContactList')/items(184)");
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
            request.ContentType = "application/json;odata=verbose";
            request.Headers["X-RequestDigest"] = RequestDigestValue(out postStream, out results, out newFormDigest);
            request.Headers["X-HTTP-Method"] = "DELETE";
            request.Headers["IF-MATCH"] = "*";
            request.Credentials = CredentialCache.DefaultCredentials;
            request.Accept = "application/json;odata=verbose";
            request.Method = "POST";
            request.ContentLength = 0;
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
        }

        private static void UpdateItems()
        {
         
            Uri uri = new Uri("http://Site/_api/web/lists/GetByTitle('ContactList')/items(185)");
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
            request.ContentType = "application/json;odata=verbose";
            request.Headers["X-RequestDigest"] = RequestDigestValue(out postStream, out results, out newFormDigest);
            request.Headers["X-HTTP-Method"] = "MERGE";
            request.Headers["IF-MATCH"] = "*";
            request.Credentials = CredentialCache.DefaultCredentials;
            request.Accept = "application/json;odata=verbose";
            request.Method = "POST";
            string stringData = "{'__metadata':{'type':'SP.Data.ContactListListItem'}, 'Title':'Jaffa','Street':'Mystreet','City':'Chennai'}";
           // string stringData = "{ '__metadata': { 'type': 'SP.List' }, 'Title': 'New title' }";
            request.ContentLength = stringData.Length;
            StreamWriter writer = new StreamWriter(request.GetRequestStream());
            writer.Write(stringData);
            writer.Flush();

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
        }
        public Uri WebUri { get; private set; }
        private static void PostItems()
        {
            // 1st request to get the context information

         
            newFormDigest= RequestDigestValue(out postStream, out results, out newFormDigest);

            Uri webUri = new Uri("http://Site/");
       
            var digestRequest = new Uri(webUri, string.Format("/_api/web/lists/getbytitle('{0}')/items", "ContactList"));
            HttpWebRequest spNewRequest = (HttpWebRequest)HttpWebRequest.Create(digestRequest);
            CredentialCache credNewCache = new CredentialCache();

            //credNewCache.Add(new Uri(digestRequest), "NTLM", CredentialCache.DefaultNetworkCredentials);
            credNewCache.Add(digestRequest, "NTLM", CredentialCache.DefaultNetworkCredentials);
            spNewRequest.Credentials = credNewCache;
            spNewRequest.Method = "POST";
            spNewRequest.Accept = "application/json;odata=verbose";
            spNewRequest.ContentType = "application/json;odata=verbose";
            spNewRequest.Headers.Add("X-RequestDigest", newFormDigest);
            string listPostBody = "{'__metadata':{'type':'SP.Data.ContactListListItem'}, 'Title':'MyTitle','Street':'MystreetName','City':'Delhi'}";
   


            // For Content Length

            byte[] postByte = Encoding.UTF8.GetBytes(listPostBody);
            spNewRequest.ContentLength = postByte.Length;
            Stream postStreamBody = spNewRequest.GetRequestStream();
            postStreamBody.Write(postByte, 0, postByte.Length);
            postStreamBody.Close();
            HttpWebResponse webResponse = (HttpWebResponse)spNewRequest.GetResponse();
            results = GetHTTPResponse(webResponse, out postStream, out results);

        }

        private static string RequestDigestValue(out Stream postStream, out string results, out string newFormDigest)
        {
            string formdigestRequest = "http://Site/_api/contextinfo";
            CredentialCache credCache = new CredentialCache();
            credCache.Add(new Uri(formdigestRequest), "NTLM", CredentialCache.DefaultNetworkCredentials);
            HttpWebRequest spRequest = (HttpWebRequest)HttpWebRequest.Create(formdigestRequest);

            spRequest.Credentials = credCache;
            spRequest.Method = "POST";
            spRequest.Accept = "application/json;odata=verbose";
            spRequest.ContentLength = 0;


            HttpWebResponse endpointResponse = (HttpWebResponse)spRequest.GetResponse();
            results = GetHTTPResponse(endpointResponse, out postStream, out results);



            // Get the FormDigest Value

            var startTag = "FormDigestValue";
            var endTag = "LibraryVersion";
            var startTagIndex = results.IndexOf(startTag) + 1;
            var endTagIndex = results.IndexOf(endTag, startTagIndex);
            newFormDigest = null;
            if ((startTagIndex >= 0) && (endTagIndex > startTagIndex))
            {

                newFormDigest = results.Substring(startTagIndex + startTag.Length + 2, endTagIndex - startTagIndex - startTag.Length - 5);

            }
            return newFormDigest;
        }
        private static String GetHTTPResponse(HttpWebResponse endpointResponse, out  Stream postStream, out  string results)
        {
            postStream = endpointResponse.GetResponseStream();
            StreamReader postReader = new StreamReader(postStream);
            results = postReader.ReadToEnd();
            postReader.Close();
            postStream.Close();
            return results;
        }
        private static void GetItems()
        {
           //Replace "Site" with your site name
            HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create("http://Site/_api/web/Lists/getByTitle('ContactList')/items");

            endpointRequest.Method = "GET";
            endpointRequest.Accept = "application/json;odata=verbose";
            NetworkCredential cred = new System.Net.NetworkCredential("UserName", "Password", "Domain");
            endpointRequest.Credentials = cred;
            HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse();
            try
            {
                WebResponse webResponse = endpointRequest.GetResponse();
                Stream webStream = webResponse.GetResponseStream();
                StreamReader responseReader = new StreamReader(webStream);
                string response = responseReader.ReadToEnd();
                JObject jobj = JObject.Parse(response);
                JArray jarr = (JArray)jobj["d"]["results"];

                foreach (JObject j in jarr)
                {
                    //City and County are column names in a list
                    Console.WriteLine(j["City"] + "  " + j["County"]);

                }

                responseReader.Close();
                Console.ReadLine();

            }
            catch (Exception e)
            {
                Console.Out.WriteLine(e.Message); Console.ReadLine();
            }
        }
    }

}

Tuesday, March 11, 2014

1.difference between visual webpart and a standard webpart'
the SharePoint 2010 Visual Web Part is an ASCX web user control that is hosted inside a standard Web Part.

2.Difference between web user control and webpart
user control:
a.User controls must be compiled before use, which adds to the time it takes to load the control.
b.The Visual Web Developer designer provides support for designing the UI by using drag-and-drop operations that gives the control a consistent look-and-feel, which results in faster development.
Webpart:
a.Web Parts are precompiled and ready for use as soon as you need them.
b.The controls in Web Parts must be added by using code.

3.SharePoint site pages vs application pages
Site Pages:- Site Pages are Site or Web Scoped, User can customize Site Pages, Site Pages are stored in Content Database,
You cannot have custom code in Site Pages, Site Pages are Un-ghosted Pages.

Application Page:-
Application Pages are farm scoped, No customization can be done by the user, Application Pages are stored in WFE(Web Front End) in _layouts folder, You can have custom code in your Application Pages, Application Pages are Ghosted Pages.

4.Difference between WFE and application server
Microsoft SharePoint Foundation Web Application makes WFE in SharePoint farm

5.Difference between page library and site library
The Pages library is for storing Publishing Pages whereas the Site Pages library is for storing wiki and web part pages.
You only get the Pages library once the SharePoint Server Publishing feature is activated on the site. This library is usually used when you have requirements for content-centric pages that may use the scheduling, workflow and caching capabilities of SharePoint; such as in the case of public-facing websites. In a more collaborative scenario, you'd want to use the Site Pages library to create wiki and web part pages.

Saturday, March 16, 2013

Sandbox solutions support:

  1. Web parts
  2. Event Receivers
  3. Workflows
  4. List definitions

What is Sandbox solutions and its limitations


Sandbox solution is a new feature introduced in SharePoint 2010. It's a secured wrapper around webparts and other elements with limitations. There is no thumb rule that every webpart in SharePoint 2010 belongs to Sandbox Solution. But it's recommended to develop webparts with Sandbox solution. It allows administrators to monitor the solutions and control as required. SharePoint Site Collection administrators can view the resource utilization of each solution and can block if it consumes too much resources. Usually when sites working slow, developers complain the server is slow whereas site/server administrators blame on Develepor code/solutions. Now Microsoft put a Full Stop to that. :)

Technically speaking SharePoint solutions run in seperate worker processes and not in w3wp.exe. So It doesn't require IIS Reset or Application Pool Recycling. Without disturbing the SharePoint site, Sandbox solutions can be deployed. Only thing while deploying new version of Sandbox solution over existing solution, SharePoint will display No Solution found error in Sandbox Webparts on the page. However within seconds sandbox solutions getting deployed and it'll start working. In SharePoint 2007, only farm administrators can install/deploy developer solutions. But Now site collection administrators can deploy solutions with web based interface. This reduces the dependency of Farm Administrator and improves rapid deployment.

Sandbox Processes
Here the processes which required for Sandbox solutions.
  1. SPUCWorkerprocess.exe - Sandbox Worker process service which is a Seperate Service Application which actually executes Sandbox code. It should be started in every farm to use Sandbox solutions.

  2. SPUCWorkerProcessProxy.exe - Sandbox Worker process proxy which is working as a proxy for Worker process and takes care of Sandbox code execution. It can also serve to other farms if configured. Basically it helps site administrator for load balancing.

  3. SPUCHostService.exe - Sandbox User Code Service takes care of user code in Sandbox amd it can be started in the farms where to use Sandbox solutions.
Sandbox Limitations
As I said before, Sandbox is a secured wrapper and it has restrictions on code to run in SharePoint environment. Few Key limitations which developers should know are listed below.
  1. No Security Elevation - RunWithElevatedPrivileges which runs the specified block of code in application pool account(typically System Account) context is not allowed in Sandbox code. SPSecurity class also not allowed to use in Sandbox.

  2. No Email Support - SPUtility.SendMail method has been blocked explicitly in Sandbox, However .Net mail classes can be used to send mails. Additionaly sandbox won't allow to read Farm SMTP address. So developers has to specify the SMTP address in code itself(may be some other workaround).

  3. No Support to WebPartPages Namespace - Sandbox won't allow to use Microsoft.SharePoint.WebPartPages namespace.

  4. No Support to external Webservice - Internet web service calls are not allowed to ensure security in Sandbox solutions. Allow Partially Trusted code also can't be accessed within Sandbox.

  5. No GAC Deployment - Sandbox solutions are not stored in File System(Physical path) and assemblies can't be deployed to Global Assembly Cache(GAC). But it's available on C:\ProgramData\Microsoft\SharePoint\UCCache at runtime. Note the ProgramData is a hidden folder.

  6. No Visual Webparts - Visual Studio 2010 by default won't allow to create Visual Webparts to deploy as sandbox solution. But with Visual Studio PowerTools extensions(downloadable from Microsoft MSDN website) Visual Webparts can be developed and deployed as sandbox Solutions.
SharePoint Online which is SharePoint environment provided by Microsoft to manage SharePoint Sites in internet accepts only Sandbox solutions. Because SharePoint Online sites are Windows Servers at Microsoft Datacenters, Microsoft won't allow GAC deployment or file system access. In future Sandbox solution will give more features for developers.

Deploying Master Pages & Themes via a Feature using Visual Studio 2010

Following this guide you’ll see the process that goes behind creating the feature which commonly be used to deploy branding items such as Master Pages, CSS, JavaScript, & Themes. If you plan to follow along just replace the steps with my name with whatever you wish.

Configure the Project

  1. Open Visual Studio 2010
  2. File -> New -> Project

  1. Select SharePoint -> Empty SharePoint Project
  2. Add Name: TomDaly.SharePoint.Branding (this is my standard structure)
  3. Add Location: C:\Projects\TomDaly

  1. Click OK
  2. Enter your test site for debugging purposes.
  3. Select ‘Deploy as farm solution’

  1. Click Finish

Adding the CSS / Image / JavaScript Files

Add CSS file

  1. Right Click on the Project -> Add -> SharePoint ‘Layouts’ Mapped Folder

  1. This created a folder which is mapped to the layouts

** These files in here are accessible through the web via http://YOURSITE/_layouts/TomDaly.SharePoint.Branding/
  1. Right click on Layouts\TomDaly.SharePoint.Branding folder -> Add -> New Item

  1. Select Web on the left, and Style Sheet on the right, and Name the file at the bottom.
(I typically use base.css or style.css for the foundation of my styles, but this is all up to you)
  1. Click Add

Add Images & JavaScript Folder

This would be the location for any images associated with the site css.
  1. Right Click on the Layouts\TomDaly.SharePoint.Branding folder -> Add -> New Folder

  1. Name the folder ‘images’

OPTIONAL STEP
  1. Repeat Step 1 & 2 for the JavaScript folder. (I typically call this folder ‘js’)

I usually include a JavaScript folder because most of the time I end up using jQuery somewhere on the site, this is where I store those files which I would reference on page or in the Master Page. Depending on how it’s needed.
These files would be accessible: http://YOURSITE /_layouts/TomDaly.SharePoint.Branding/js/JSFILESHERE

Setting up the Feature

  1. In your project Right click on Features -> Add Feature

This will create a feature with some default name of ‘Feature 1′, which we don’t want
  1. Select Feature1, Right Click -> Rename

  1. Rename the Feature to TomDaly.SharePoint.Branding (I typically name it to the same as the project name)

  1. Double Click on your Primary feature, in the main left hand window the properties should appear

  1. Give your feature a normal title name Title and Description, and scope it accordingly. (I usually scope my master pages to (Site) as they are normally used through the site collection

  1. Click Save

Renaming the WSP

This is really annoying to me so I always change it. When a .WSP is generated it will usually come out as Feature_Feature.wsp. I prefer just Feature.wsp.
1. Double Click on the primary Feature, the Properties should appear right below it.
2. Change ‘Deployment Path’
From: $SharePoint.Project.FileNameWithoutExtension$_$SharePoint.Feature.FileNameWithoutExtension$
To: $SharePoint.Project.FileNameWithoutExtension$

Adding the Master Page

1. Right Click on the Project -> Add -> New Item

2. In the left Installed Template column, Select SharePoint 2010
3. On the right select Module
4. At the bottom name the Module, Master Pages

5. Click Add
** You module will be added to your project **
6. Under the Master Pages Module, right click on Sample.txt and Delete It

7. Now Drag & Drag and Drop your Custom Master Page from another folder into the project, In the Master Pages Module

8. Double Click on the Elements.xml in the Master Pages Module

9. In the Elements.xml file, make the following changes to the <Module> line
Change
<Module
Name=MasterPages>


To
<Module
Name=MasterPages
Url=_catalogs/masterpage>


10. In the Elements.xml file, make the following changes to the <File> line
    a. add IgnoreIfAlreadyExists=True

    b. add Type=GhostableInLibrary

    c. remove MasterPages/ from the
Url=MasterPages/TOMDALY.master


So essentially this line
<File
Path=MasterPages\TOMDALY.master
Url=MasterPages/TOMDALY.master />


Changes to

<File
Path=MasterPages\TOMDALY.master
Url=TOMDALY.master
IgnoreIfAlreadyExists=True
Type=GhostableInLibrary />


11. Click Save

Adding Theme

This step will incorporate a theme into your project. How to generate the .thmx is not covered here but a simple way would be to export from PowerPoint or use ThemeBuilder to generate this file.
1. Right Click on the Project -> Add -> New Item

2. On the left Click SharePoint -> 2010
3. On the Right Select “Module”
4. Add Name: Theme

5. Click Add
6. In the Theme node, Delete Sample.Txt

7. Copy in you custom .thmx file
8. Double Click on the Elements.xml in the Theme Module

9. In the Elements.xml file, make the following changes to the <Module> line
Change
<Module
Name=Theme>


To
<Module
Name=Theme
Url=_catalogs/theme>


10. In the Elements.xml file, make the following changes to the <File> line
    a. add IgnoreIfAlreadyExists=True

    b. add Type=GhostableInLibrary

    c. remove Theme/ from the
Url=Theme/TomDaly.thmx


So essentially this line
<File
Path=Theme\TomDaly.thmx
Url=Theme/TomDaly.thmx
/>


Changes to

<File
Path=Theme\TomDaly.thmx
Url=TomDaly.thmx
IgnoreIfAlreadyExists=True
Type=GhostableInLibrary />


11. Click Save

Adding the Feature Receiver

This whole step is optional. Its sole purpose is to automatically turn on the branding on the sites and subsites, apply a theme, or apply search master pages to your site collection. NOTE: If you changed the scope then there is no guarantee that this code will work.
Please take some time to look through the code as there are different sections you might want to comment out or fill in. Say if you want to configure the Site Logo or an Alternative CSS file. If you not interested and just want a working project jump down to the END and in the summary there is a link to download the project.
1. Right Click your primary Feature, Select Add Event Receiver

** This will get added Right under your feature**
2. Double Click on the new file TomDaly.SharePoint.EventReciever.cs

5. At the very top Add the following using statements
using Microsoft.SharePoint.Utilities;

using System.Collections.ObjectModel;


7. Under the class declaration add these three string constants which contain the names of the masterpages and the theme.

So my master page name is TomDaly.master, my search master page which I don’t have a custom one for yet is minimal.master, and my Custom Theme is called TomDaly
8. Replace the public override void FeatureActivated, with

public override void FeatureActivated(SPFeatureReceiverProperties properties)

{

SPSite site = properties.Feature.Parent as SPSite;


if (site != null)

{

using (SPWeb topLevelSite = site.RootWeb)

{

//Get the relative path

string relativePath = topLevelSite.ServerRelativeUrl;

if (!relativePath.EndsWith(“/”))

{

relativePath += “/”;

}


//Get Theme collection from site and the them we want

ReadOnlyCollection<ThmxTheme> themes = ThmxTheme.GetManagedThemes(site);

ThmxTheme customTheme = null;

foreach (ThmxTheme theme in themes)

{

if (theme.Name == themeName)

{

customTheme = theme;

break;

}

}


//Apply branding to each web in the site collection

foreach (SPWeb web in site.AllWebs)

{

//Apply masterpage and logo

if (web.WebTemplate == “SRCHCENTERLITE” || web.WebTemplate == “SRCHCEN” || web.WebTemplate == “SRCHCENTERFAST”)

{

web.CustomMasterUrl = relativePath + “_catalogs/masterpage/” + searchMasterPage;

}

else

{

web.MasterUrl = relativePath + “_catalogs/masterpage/” + masterPage;

web.CustomMasterUrl = relativePath + “_catalogs/masterpage/” + masterPage;

}


web.AlternateCssUrl = “”;

web.SiteLogoUrl = “”;

web.UIVersion = 4;

web.Update();


//Also apply the theme

if (customTheme != null)

{

customTheme.ApplyTo(web, true);

web.Update();

}

}

}

}

}

9. Replace the public override void FeatureDeactivated, with
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)

{

SPSite site = properties.Feature.Parent as SPSite;


if (site != null)

{

using (SPWeb topLevelSite = site.RootWeb)

{

//Get the relative path

string relativePath = topLevelSite.ServerRelativeUrl;

if (!relativePath.EndsWith(“/”))

{

relativePath += “/”;

}


//Apply branding to each web the wen the site collection

foreach (SPWeb web in site.AllWebs)

{

//Apply default masterpage and logo

if (web.WebTemplate == “SRCHCENTERLITE” || web.WebTemplate == “SRCHCEN” || web.WebTemplate == “SRCHCENTERFAST”)

{

web.CustomMasterUrl = relativePath + “_catalogs/masterpage/minimal.master”;

}

else

{

web.MasterUrl = relativePath + “_catalogs/masterpage/v4.master”;

web.CustomMasterUrl = relativePath + “_catalogs/masterpage/v4.master”;

}


web.AlternateCssUrl = “”;

web.SiteLogoUrl = “”;

web.Update();


//reset the theme back to default

ThmxTheme.SetThemeUrlForWeb(web, null, true);

web.Update();

}

}

}

}

10. Click Save
11. Hit F6, or Build -> Build Solution … to ensure that everything is correct and ok. You should receive the “Build Succeed” in the bottom left corner



Changing the Site Url for Testing

Sometimes you want to create or re-use this package and you need to change the url of the site to deploy to.
1. Click on the project and in the Properties window you’ll notice the Site URL

2. Change that to your new site destination
3. Click Save

Deployment

If you’re testing on a development box, that visual studio is on then you can simply deploy through visual studio. Otherwise you’ll have to push out your solution with the .wsp file.

Deploy from Visual Studio

1. In the Build Menu, Select Deploy

OR

Getting the .WSP for manual deployment

1. In the Build menu, Select Build to ensure no errors
2. In the Build menu, Select Package to generate the .WSP file

3. The files will be in the project folder, and by default in the BIN\DEBUG
Either way once you deploy your solution should be available in the Site Collection Features Gallery as shown here

Summary

So that’s how you setup a project for deploying branding assets. This is the typical setup I use but can change from client to client depending on their needs.

When to use Allow Unsafe Updates

AllowUnsafeUpdates is set to true when you are trying to update the database as a result of the GET request.
Say you have a list and you want to update something, then you need to set AllowUnsafeUpdates = true for the web and after you have done you need to set it back to false.
AllowUnsafeUpdates = false protects from cross site scripting.
So if you need to allow your code to make some updates, you need to set allow unsafe updates to true and then back to false as soon you update.
SPList list= web.Lists["list name"];

SPListItemCollection items= list.GetItems();

web.AllowUnsafeUpdates = true;
foreach (SPListItem item in items)
{
     item["Field"] = "new val";
     item.Update();
}
web.AllowUnsafeUpdates = false;

Also refer following links for more idea.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.allowunsafeupdates.aspx
http://blog.animesh.co.in/2010/03/sharepoint-spsiteallowunsafeupdates.html

Difference between SharePoint 2010 and 2013


Very briefly i will tell what are the major changes in SharePoint 2013 on above of 2010

First thing is it 14 hive folder has been moved to 15 hive folder and it is also called as SP15

Shredded storage this is used for storing the version updates in documents and stores locally
Workflow manager for 2013 which is also called as windows azure workflow which can be only used for SharePoint 2013
workflow service manager - this is an integration layer between SharePoint and workflow manager
workflow manager should be installed in separate farm server where SharePoint is not installed

SharePoint is now with HTML 5

content search web part(CSWP) new in SharePoint 2013

Distributed cache service which is a new service located in services on server this is used for cache in SharePoint and also used for rendering of docs more faster than previous versions

Minimal downloaded Strategy(MDS) : when a document is downloaded to SharePoint server it will create a copy locally and keep it in cache when ever changes happens it will only download the changes that are made not the whole document
MDS will not be enabled for publishing site
Enable minimal download= True is the property for enabling MDS and it is a feature in SharePoint 2013

Now using Open XML/Power point/word 2010 we can create themes in SP15 and the extension for this is .thmx

Three new services had been included in SharePoint service application:

  • Machine Translation( only this can be used across farm servers)
  • Work Management
  • App Management


Usage.xslx is an excel file in webanalytics used to see the usage of user and you can see this option in site settings--> site administration--> property trends

In SP15 webapplications are by default claims based authentication
and this calims based authentication supports

  • windows claims
  • SAML- based claims
  • Forms based authentication claims

Hosted name site collection: these site collections should have public IP and DNS examples for these site collections are
http://hr.adventure-works.com
http://it.adventure-works.com
(SP15) this is a new change in SP15

http://intranet.adventure-works.com/sites/hr
http://intranet.adventure-works.com/sites/it
(sharepont 2010) this is a old version


Saturday, January 19, 2013

How to get data from multiple lists in SharePoint

In this article I am showing you how to display data from two lists in one data view using share point designer 2007

Here I am taking the example of two list say Task and Contact list

Image1.gif



1. First of all you have to open the share point site in share point designer And then open the page where you want to insert data view.

2. Click on Insert -> Share point Controls-> Data view by selecting a web part region in your page.

Image2.gif

3. From the Right top region from the data Source Library go to Linked Source.

4. Click on Create linked source as shown below.

Image3.gif

5. Following pop up will come .From there select Configure Linked Source.

Image4.gif

6. Select the contact and Task list as shown below.

Image5.gif

7.
 Click Next. From the next screen choose Join the contents of the data sources and click Finish.

Image6.gif

8. Now you get popup as shown below Go to General Tab ad Give a proper name for our Linked source. Click OK.

Image7.gif

9. Now our linked Source will be added to Data Source list as shown below. Select Show Data.

Image8.gif

10. Now you can see the data from Two list (Contact and Task are displayed in the Linked source).

11. I have selected Phone number from Contact, Title and priority from task List.

Image9.gif

12. Now please drag the items you selected to the region where you want to display the dataview joined with two lists.

Image10.gif

13. Click save and check in your changes.

SharePoint - Cannot convert a primitive value to the expected type 'Edm.Double'. See the inner exception for more details If y...

Ad