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

Friday, May 27, 2016

Adding new item with plus in circle using Content Editor webpart

Adding new item with hyperlink like in the list form using content editor webpart.



Add the following content in the text file and call this text file in content editor webpart

<div align="right">

<table cellspacing="0" cellpadding="0" border="0" dir="none" id="Hero-WPQ2">
<tbody><tr><td class="ms-list-addnew ms-textXLarge ms-list-addnew-aligntop ms-soften">
<a title="Add a new item to this list or library." target="_self"    href="/MOM/Lists/MOM/NewForm.aspx" class="ms-heroCommandLink" id="idHomePageNewItem">
<span class="icon icon-add-new"></span>
<span>Add new MOM </span></a>
</td></tr></tbody></table>

</div>


<style>

/* css example with custom class */
/* img tag technique */


/* background technique */

.icon {
display: inline-block;
overflow: hidden;
vertical-align: middle;
}

.icon-add-new {
width: 22px;
height: 21px;
background: url('/_layouts/15/images/spcommon.png?rev=23') no-repeat -130px -134px;
}

</style>

Ref: 
http://ericoverfield.com/sharepoint-2013-spcommon-png-sprite-breakdown/
https://gist.github.com/empo/6380de9a10710646fd62

Tuesday, May 03, 2016

SharePoint 2013 : People Editor Control SharePoint:PeopleEditor Vs SharePoint:ClientPeoplePicker in Server Object Model

Searched for difference between People Editor Control SharePoint:PeopleEditor  Vs SharePoint:ClientPeoplePicker in SharePoint 2013 Server Object Model

Requirement: Need to add Users and SPGroup using server object model through Visual Webpart.
Googled and find the below code snippet from different site and consolidate below, May be useful to someone. 

Using SharePoint:PeopleEditor control ( Supports SharePoint Version 2010 and 2013)

ASCX File
<SharePoint:PeopleEditor ID="pplCC" runat="server" class="ms-authoringcontrols" SelectionSet="User,SPGroup"   />

Code File

Setting Values to the Control from the list item
SPFieldUserValueCollection userCol = new SPFieldUserValueCollection(SPContext.Current.Web, item["Attendees"].ToString());

SetUserCollectionWithPeopleEditor(pplCC, userCol);


//set People editor control with the SP user collection
        public void SetUserCollectionWithPeopleEditor(PeopleEditor editor, SPFieldUserValueCollection userCollection)
        {
            System.Collections.ArrayList userList = new System.Collections.ArrayList();
            if (null != userCollection)
            {
                foreach (SPFieldUserValue user in userCollection)
                {
                    PickerEntity tempEntity = new PickerEntity();

                    if (user.User != null)
                    {
                        tempEntity.Key = user.User.LoginName;
                    }
                    else
                    {
                        tempEntity.Key = user.LookupValue;
                    }
                    userList.Add(tempEntity);
                }
                editor.UpdateEntities(userList);
            }
        }
                           
Add or Update Values from Control to the list
if (pplCC.Accounts.Count > 0)
                        {
                            oSPListItem["Attendees"] = GetPeople(pplCC, web);
                            // GetUsersFomPeoplePicker("", web, pplCC);
                        }

//set values People editor control
private SPFieldUserValueCollection GetPeople(PeopleEditor people, SPWeb web)
        {
            SPFieldUserValueCollection values = new SPFieldUserValueCollection();
            if (people.ResolvedEntities.Count > 0)
            {
                for (int counter = 0; counter < people.ResolvedEntities.Count; counter++)
                {


                    PickerEntity user = (PickerEntity)people.ResolvedEntities[counter];
                    switch ((string)user.EntityData["PrincipalType"])
                    {
                        case "User":
                            SPUser spUser = web.EnsureUser(user.Key);
                            SPFieldUserValue userValue = new SPFieldUserValue(web, spUser.ID, spUser.Name);
                            values.Add(userValue);
                            break;

                        case "SharePointGroup":
                            SPGroup siteGroup = web.SiteGroups[user.EntityData["AccountName"].ToString()];
                            SPFieldUserValue groupValue = new SPFieldUserValue(web, siteGroup.ID, siteGroup.Name);
                            values.Add(groupValue);
                            break;
                        default:
                            SPUser webUser = web.EnsureUser(user.Key);
                            SPFieldUserValue spuserValue = new SPFieldUserValue(web, webUser.ID, webUser.Name);
                            values.Add(spuserValue);
                            break;
                    }
                }
            }
            return values;
        }



Using SharePoint: ClientPeoplePicker control ( Supports only in SharePoint 2013)

ASCX File
            <SharePoint:ClientPeoplePicker
        Required="true"
        ValidationEnabled="true"
        ID="pplPickerSiteRequestor"
        UseLocalSuggestionCache="true"
        PrincipalAccountType="User,SPGroup"
        runat="server"
        VisibleSuggestions="3"
        Rows="3"
        AllowMultipleEntities="true"
        CssClass="ms-long ms-spellcheck-true user-block"
        ErrorMessage="*"
/>


Code File

Setting Values to the Control from the list item
    SPFieldUserValueCollection userCol = new SPFieldUserValueCollection(SPContext.Current.Web, item["Attendees"].ToString());
                            SetUserCollectionWithPeopleEditorCLIENT(pplPickerSiteRequestor, userCol);

//set People editor control along with the SP user collection to update the list
public void SetUserCollectionWithPeopleEditorCLIENT(ClientPeoplePicker editor, SPFieldUserValueCollection userCollection)
        {
                        
            System.Collections.ArrayList userList = new System.Collections.ArrayList();
            if (null != userCollection)
            {
                foreach (SPFieldUserValue user in userCollection)
                {
                    PeopleEditor pe = new PeopleEditor();
                    PickerEntity tempEntity = new PickerEntity();

                    if (user.User != null)
                    {
                        tempEntity.Key = user.User.LoginName;
                        tempEntity = pe.ValidateEntity(tempEntity);
                    }
                    else
                    {
                        tempEntity.Key = user.LookupValue;
                    }
                    userList.Add(tempEntity);
                    editor.AddEntities(new List<PickerEntity> { tempEntity });
                }
              
            }
        }

Add or Update Values from Control to the list
//FOR UPDATE client people editor
if (pplPickerSiteRequestor.ResolvedEntities.Count > 0)
{

oSPListItem["Attendees"] = GetPeopleCLIENT(pplPickerSiteRequestor, web);

}

//set People editor control along with the SP user collection to update the list
private SPFieldUserValueCollection GetPeopleCLIENT(ClientPeoplePicker people, SPWeb web)
        {
            SPFieldUserValueCollection values = new SPFieldUserValueCollection();
            if (people.ResolvedEntities.Count > 0)
            {
                for (int counter = 0; counter < people.ResolvedEntities.Count; counter++)
                {
                    
                    PickerEntity user = (PickerEntity)people.ResolvedEntities[counter];
                    switch ((string)user.EntityData["PrincipalType"])
                    {
                        case "User":
                            SPUser spUser = web.EnsureUser(user.Key);
                            SPFieldUserValue userValue = new SPFieldUserValue(web, spUser.ID, spUser.Name);
                            values.Add(userValue);
                            break;

                        case "SharePointGroup":
                            SPGroup siteGroup = web.SiteGroups[user.EntityData["AccountName"].ToString()];
                            SPFieldUserValue groupValue = new SPFieldUserValue(web, siteGroup.ID, siteGroup.Name);
                            values.Add(groupValue);
                            break;
                        default:
                            SPUser webUser = web.EnsureUser(user.Key);
                            SPFieldUserValue spuserValue = new SPFieldUserValue(web, webUser.ID, webUser.Name);
                            values.Add(spuserValue);
                            break;
                    }
                }
            }
            return values;

        }

Many thanks to all who shared the knowledge.

Wednesday, August 21, 2013

SharePoint SQL Server Support Matrix

Thanks to  JASON WARREN

SharePoint SQL Server Support Matrix


2013
2010
2007
2003
2001
SQL Server 2012
All editions
64-bit
All editions
Requires SharePoint SP1
64-bit



SQL Server 2008 R2
SQL Server SP1
All editions
64-bit
All editions
64-bit
All editions
Requires SharePoint SP2
32-bit, 64-bit


SQL Server 2008

SQL Server SP1 + CU2 or CU5
CU3 or CU4 not recommended
All editions
64-bit
All editions
Requires SharePoint SP1
32-bit, 64-bit


SQL Server 2005

SQL Server SP3
All editions
64-bit
SQL Server SP1
All editions
32-bit, 64-bit
SQL Server SP4
Standard 32-bit, 64-bit
Enterprise 32-bit, 64-bit
Workgroup 32-bit, 64-bit

SQL Server 2000


SQL Server SP4
All editions
32-bit, 64-bit
Standard 32-bit, 64-bit
Enterprise 32-bit, 64-bit
Workgroup 32-bit, 64-bit
MSDE 32-bit, 64-bit
All editions
SQL Server 7.0




All editions

Notes
  1. An empty cell mean this SQL Server/SharePoint combination is not supported.
  2. This table reflects all SharePoint editions, i.e. WSS/Foundation and Server Standard/Enterprise/Internet Sites. In other words within a SharePoint version, the SQL Server requirements are the same.
  3. I’ve indicated if a minimum SQL Server or SharePoint Service Pack is required otherwise assume RTM and later.
  4. The documentation isn’t always complete. When specific editions are not provided, I’ve assumed all mainstream editions (e.g. Standard, Enterprise, Datacenter, Web, Workgroup, Express) are supported and used the phrase All editions.
  5. Why have I listed unsupported versions of SharePoint? One day you’ll encounter one of these ancient farms in need of some help and the answer will be obvious.