Friday 12 May 2017

How to restrict SharePoint list item from search result

Problem Statement:


SharePoint default search functionality display all list data. Sometime user don't want to display particular list items data in search result, then what is solution?

Solution:

To remove particular list item details from search result follow below steps:

  1. Open list and go to list setting
  2. then go to "Advanced Settings" option
  3. In "Advanced Settings", find out "Search" section
  4. In "Search" section, option called as "Allow items from this list to appear in search results?" is available
  5. By default its "Yes", change it to "No"

Based on SharePoint search architecture, list items will get time to stop displaying from search result.

Product applies to:


  • SharePoint 2010
  • SharePoint 2013
 

Thursday 11 May 2017

Get manager using SharePoint designer workflow

Problem Statement:

Our one of the client come with requirement that they want to send an email to manager who create an SharePoint list item.
So to fulfill this requirement, there are multiple options are available in SharePoint. But its always better to used OOTB approach.

Solution:

In SharePoint, to get manager of particular user one action is present called as "Lookup Manager of a User".This action will give us provision to find manager of particular user from user profile as follow:


Product applies to:


  • SharePoint 2010
  • SharePoint 2013
 

A Workflow lookup cannot be copied & pasted from one email message to another

I was defining email template in SharePoint designer workflow using email action. I have added all necessary columns needed in email template and when I try to save email its showing me following error:



Solution:


After comparing all column I used in email templates I realize that there is problem with column called name as "Occurred Date & Time".
Then I removed "&" and rename column as "Occurred Date and Time" and its works.


But still I faced same issue in different workflow email action and I didn't see any special character in column name. Column detail is as follow:


Alternate Solution:


This time I am go with alternate solution. I create one workflow variable and I stored column value in it. Same variable I used in email template and its work properly.


Please let us know your suggestion on same...

 

Wednesday 10 May 2017

Announcement list template missing in SharePoint 2013

Solution:

When "Announcement" list template is missing from site content then we have to enable "Team Collaboration Lists" site feature.

Following are steps to enable "Team Collaboration Lists":


Step 1: Go to site setting. Click on "Manage site features" from "Site Actions" section:

Site Setting

Step 2: Search for "Team Collaboration Lists" and click on "Activate" button:

Team Collaboration Lists

Product applies to:
  • SharePoint Server 2013
  • SharePoint Foundation 2013

 

Get All SharePoint list items using REST API

Solution:


Here I create 1 variable as follow:


1)      url : REST API with list name

var url = "/_api/Web/Lists/GetByTitle('CRUDList')/Items";

Function:


            function getItems(url) {
                $.ajax({
                    url: _spPageContextInfo.webAbsoluteUrl + url,
                    type: "GET",
                    headers: {
                        "accept": "application/json;odata=verbose",
                    },
                    success: function (data) {
                        console.log(data.d.results);
                    },
                    error: function (error) {
                        alert(JSON.stringify(error));
                    }
                });
            }

Function call:


getItems(url);


Feel free to revert in-case of any query...

Product Applies To:


·         SharePoint Server 2013

·         SharePoint Foundation 2013


 

Monday 8 May 2017

SharePoint REST API to get list item entity type full name

To perform SharePoint list CRUD operation, mostly we need list item entity type full name.

Solution:

Following is REST API URL to get list item entity type full name:


_spPageContextInfo.webAbsoluteUrl  + /_api/Web/Lists/getbytitle('CRUDList')/ListItemEntityTypeFullName


Output:


Delete SharePoint list item using REST API

Solution:

Here I create 1 variable as follow:

1)      url : REST API with list name

var url = "/_api/Web/Lists/GetByTitle('CRUDList')/getItemById('1')";


Function:

            function deleteItem(url) {
                $.ajax({
                    url: _spPageContextInfo.webAbsoluteUrl + url,
                    type: "DELETE",
                    headers: {
                        "accept": "application/json;odata=verbose",
                        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                        "If-Match": "*"
                    },
                    success: function (data) {
                       alert("Record deleted.");
                    },
                    error: function (error) {
                        alert(JSON.stringify(error));
                    }
                });
            }


Function call:

deleteItem(url);


Feel free to revert in-case of any query...


Product Applies To:

·         SharePoint Server 2013

·         SharePoint Foundation 2013

 

Update SharePoint list item using REST API

Solution:

Here I create 2 variables as follow:

1)      url : REST API with list name
2)      data : this variable contain the column name with respective values

var url = "/_api/Web/Lists/GetByTitle('CRUDList')/getItemById('1')";
var data = {
__metadata: { 'type': 'SP.Data.CRUDListListItem' },
            Title: 'Update title'
};


Function:

function updateItem(url, updateData) {
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + url,
type: "PATCH",
headers: {
                        "accept": "application/json;odata=verbose",
                        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                        "content-Type": "application/json;odata=verbose",
                        "X-Http-Method": "PATCH",
                        "If-Match": "*"
                    },
                    data: JSON.stringify(updateData),
                    success: function (data) {
                        console.log(data);
                    },
                    error: function (error) {
                        alert(JSON.stringify(error));
                    }
                });
            }


Function call:

updateItem(url,data);


Feel free to revert in-case of any query...


Product Applies To:

·         SharePoint Server 2013

·         SharePoint Foundation 2013


 

Add SharePoint list item using REST API

Solution:

Here I create 2 variables as follow:

      1)      url: REST APi with list name
      2)      data: this variable contain the column name with respective values

var url = "/_api/Web/Lists/GetByTitle('CRUDList')/Items";
                           
var data = {
      __metadata: { 'type': 'SP.Data.CRUDListListItem' },
      Title: 'Some title'
};


Function:

function addNewItem(url, data) {
$.ajax({
            url: _spPageContextInfo.webAbsoluteUrl + url,
            type: "POST",
            headers: {
                        "accept": "application/json;odata=verbose",
                        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                        "content-Type": "application/json;odata=verbose"
            },
            data: JSON.stringify(data),
            success: function (data) {
                        console.log(data);
            },
            error: function (error) {
                        alert(JSON.stringify(error));
            }
            });
}

Function call:

addNewItem(url,data);


Feel free to revert in-case of any query...

Product Applies To:

·         SharePoint Server 2013

·         SharePoint Foundation 2013