Pages

Showing posts with label List. Show all posts
Showing posts with label List. Show all posts

Monday, January 18, 2016

Manage Permissions on List Views for Different Users / Groups in SharePoint 2013

Follow these steps: -
  • Open the list with all items view (ex. Lists/EmployeeMaster/Allitems.aspx). 
  • Go to Site Actions and select Edit Page 
 Now the web part Allitems.aspx will change to the edit mode.
  • Go to the Web Part section and click Web Part Properties.
 Now the web part properties window will displayed in the right side of the web part.
  • In the List Views pane select the view from the dropdown which you need to manage the permissions.
  • In the Advanced pane select the users/ groups under Target Audiences
  • Click OK.
Follow the above steps to manage access levels and grant permission to user/ groups for different list views.

Sunday, January 17, 2016

Manage permissions for a list, library, or single item or document


This post is going to describe that how to assign unique permissions for a list, library or single list item, or document.

List / Library

Remove inherited permission from Users/Group in list
1. Open the list/library that you want to edit permission
2. Go to List Settings (or Library Settings if it is and library)
3. Go to Permission for this List (or Permission for this Library) under Permission and Management Section.
Permission page for the list will be displayed and you can see that list has inherited permission from site.
4. Click Stop inheriting permissions.
Now the list will be removed inherited permission and it has copy of its own permission.

Remove permission from Users/Group in list
1. Click check box in the left side of user/group name in the name section.
2. Click Remove User Permission under Permissions tab.
 
Grant permission to Users/Groups for list
1. Click Grant Permissions under Permissions tab and then the list permission pop window will displayed.
2. Type names of the users / groups which you need to grant permissions to the list.
3. Click SELECT OPTIONS to edit permission levels for selected users/ groups.
4. Click Share.

Inherit Permissions from Parent
1. Open the list/library that you want to edit permission
2. Go to List Settings ( or Library Settings if it is and library)
3. Go to Permission for this List (or Permission for this Library) under Permission and Management Section
Permission page for the list will be displayed and you can see that list has inherited permission from site.
4. Click Delete unique permissions.
Now the list will be removed inherited permission and it has copy of its own permission.

Note:- Managing permission on single list item or library document will follow the same steps above.

Sunday, November 29, 2015

CAML Query with Lists in SharePoint 2013


Single Line of Text
<Where><Eq><FieldRef Name="Name" /><Value Type="Text">EmployeeName</Value></Eq></Where>
__________________________________________________________________

Multiple Lines of Text
<Where><Eq><FieldRef Name="Address" /><Value Type="Text">EmployeeAddress</Value></Eq></Where>
__________________________________________________________________

Choice
<Where><Contains><FieldRef Name='Province'/><Value Type='Choice'>East</Value></Contains></Where>
__________________________________________________________________

Number
<Where><Contains><FieldRef Name='Quantity'/><Value Type='Number'>0</Value></Contains></Where>
__________________________________________________________________

Date and Time
<Where><Eq><FieldRef Name="CurrentDate" /><Value Type="DateTime" IncludeTimeValue='FALSE'>2001-01-01</Value></Eq></Where>
__________________________________________________________________

Lookup By Lookup Name
<Query><Where><Eq><FieldRef Name="State" /><Value Type="Lookup">Arizona</Value></Eq></Where></Query>

Lookup By Lookup Id
<Query><Where><Eq><FieldRef Name="State" LookupId="TRUE" /><Value Type="Lookup">4</Value></Eq></Where></Query>
__________________________________________________________________

Yes/No
<Where><Eq><FieldRef Name="Active" /><Value Type="Boolean">1</Value></Eq></Where>
__________________________________________________________________

Person or Group By SPUser.Name
<Query><Where><Eq><FieldRef Name="Author" />Value Type="Text">Josh McCarty</Value></Eq></Where></Query>

Person or Group By SPUser.ID
<Query><Where><Eq><FieldRef Name="Author" LookupId="TRUE" /><Value Type="Integer"><UserID /></Value></Eq></Where></Query>
__________________________________________________________________

Hyperlink or Picture
<Where><Contains><FieldRef Name='URL'/><Value Type='URL'>http://facebook.com</Value></Contains></Where>
__________________________________________________________________

Calculated
<Where><Eq><FieldRef Name='Status' /><Value Type='Calculated'>Completed</Value></Eq></Where>
__________________________________________________________________

CAML Operators
<Eq> – Equals
<Neq> – Not Equals
<Gt> – Greater than
<Geq> – Greater than or Equals
<Lt> – Less Than
<Leq> – Less Than or Equals
<sNull> – Is Null (Is Empty)
<BeginsWith> – Begins with a string
<Contains> – Contains a string
__________________________________________________________________

ORDER BY
<OrderBy> <FieldRef Name="[Field_Name]" Ascending="True" /></OrderBy>

Ex: <Where><Eq><FieldRef Name="Name" /><Value Type="Text">EmployeeName</Value></Eq></Where><OrderBy> <FieldRef Name="Name" Ascending="True" /></OrderBy>

The default value of Ascending is TRUE (By Default Order is in Descending)

Sunday, October 11, 2015

Resetting a ID field of a list in SharePoint

When you are developing solutions you may have used to create plenty of items in the lists interact with you solution. But when you are trying to clear up and ready the contents of your solution for production environments you may have struggle with resetting Id field of list and libraries to restart numbering at 1 sometimes. In this scenario there’s no any list options or direct way to handle this case but there’s way.

This post going to describe the way which you can reset the Id field of a list. This can achieve by using the content database of the site which the list has created.

Follow this steps:

First you need to go the content database.(Go to Central Administration > Application Management. Under the Site Collections click View all site collections. Navigate to your site collection and get the Database Name)

Open the content database using MS SQL Server Management Studio.

Open New Query and run following query.

SELECT * FROM [Your_Content_Database_Name].[dbo].[AllListsAux] WHERE ListID='Your_List_GUID'

You can see a list called AllListsAux which is maintain ID details of all the lists of the site. You can see the NextAvailableId of your list there.

Now run the following query to update the NextAvailableId. This will reset the Id field of the list and will restart numbering at “1”.

UPDATE [Your_Content_Database_Name].[dbo].[AllListsAux] SET NextAvailableId=1 WHERE ListID='Your_List_GUID'

Check this Post see how to find the GUID of a list.

Note: You need to be careful when querying on and doing any modifications to content databases to avoid malfunctioning site contents. Also note that this not a recommended approach by Microsoft.

Saturday, October 10, 2015

How to Find the GUID of a SharePoint List

When you are working with SharePoint Lists, sometime you may need to get the ID (Guid) of a list.
For example, when setting the Task list to be used with SharePoint Designer Workflows.
Follow this steps:

  1. Go to the SharePoint List which you need to get ID.
  2. Select the Settings > List Settings menu option.
  3. Copy the entire URL from the browser address bar and paste into the notepad. It should looks like this:

*        Delete all before and including “List=”.
*        Replace “%7B” with “{”
*        Replace all “%2D” with “-“
*        Replace “%7D” with “}”

Now you have left with the GUID you need:
{EF97CD69-7D68-421F-A5CA-69768D83B328}

Sunday, August 16, 2015

Work with list items Using ECMA Script


This post going to describe that how to Insert, Update and Delete list items using ECMA Script(JavaScript Client Object Model).

Insert List Item

var nmspCon = {};

nmspCon.varEmpName = "";
nmspCon.varEmpAddress = "";
nmspCon.varEmpCity = "";
nmspCon.varEmpIdCardNo = "";

nmspCon.fncSaveForm = function () {

    nmspCon.varEmpName = $('#txtName').val();
    nmspCon.varEmpAddress = $('#txtAddress').val();
    nmspCon.varEmpCity = $('#txtCity').val();
    nmspCon.varEmpIdCardNo = $('#txtIdCardNo').val();

    nmspCon.clientContext = SP.ClientContext.get_current();
    nmspCon.oList = nmspCon.clientContext.get_web().get_lists().getByTitle('Employee Information');

    nmspCon.itemCreateInfo = new SP.ListItemCreationInformation();
    nmspCon.oListItem = nmspCon.oList.addItem(nmspCon.itemCreateInfo);

    nmspCon.oListItem.set_item('Name', nmspCon.varEmpName);
    nmspCon.oListItem.set_item('Address', nmspCon.varEmpAddress);
    nmspCon.oListItem.set_item('City', nmspCon.varEmpCity);
    nmspCon.oListItem.set_item('IdentityCardNumber', nmspCon.varEmpIdCardNo);

    nmspCon.oListItem.update();
    nmspCon.clientContext.load(nmspCon.oListItem);

    nmspCon.clientContext.executeQueryAsync(
    Function.createDelegate(this, nmspCon.onQuerySuccess),
    Function.createDelegate(this, nmspCon.onQueryFail)
    );
}

nmspCon.onQuerySuccess = function () {
                alert("Success.!");}

nmspCon.onQueryFail = function (sender, args) {
                alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());}



Update List Item

nmspCon.fncUpdateEmployeeInformation = function () {

    nmspCon.varType = "Temporary";

    nmspCon.clientContext = SP.ClientContext.get_current();
    nmspCon.oList = nmspCon.clientContext.get_web().get_lists().getByTitle('Employee Information');

    nmspCon.listItem = nmspCon.oList.getItemById(1);
    nmspCon.listItem.set_item('Type', '' + nmspCon.varType);
    nmspCon.listItem.update();

    nmspCon.clientContext.load(nmspCon.listItem);
    nmspCon.clientContext.executeQueryAsync(
        Function.createDelegate(this, nmspCon.onQuerySuccess),
        Function.createDelegate(this, nmspCon.onQueryFail));
}

nmspCon.onQuerySuccess = function () {
                alert("Success.!");}

nmspCon.onQueryFail = function () {
                alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());}




Delete List Item

nmspCon.fncDeleteEmployeeInformation = function () {

    nmspCon.clientContext = SP.ClientContext.get_current();
    nmspCon.oList = nmspCon.clientContext.get_web().get_lists().getByTitle('Employee Information');

    nmspCon.listItem = nmspCon.oList.getItemById(1);
    nmspCon.listItem.deleteObject();

    nmspCon.clientContext.load(nmspCon.listItem);
    nmspCon.clientContext.executeQueryAsync(
        Function.createDelegate(this, nmspCon.onQuerySuccess),
        Function.createDelegate(this, nmspCon.onQueryFail));
}


nmspCon.onQuerySuccess = function () {
                alert("Success.!");}

nmspCon.onQueryFail = function () {
                alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());}