Wednesday, July 27, 2016

Hide a text field in a SharePoint form using jquery

If you have several SharePoint Forms, where you want to hide the input field and using SharePoint Designer to create a custom form is not an option. Here is my collection of jQuery you can insert, using the ScriptEditor webpart.

Edit the “view” of a ListItem (DispForm.aspx)

  1. Open an element on the list, thus letting you view the DispForm.aspx page
  2. Edit the page (not the content)
  3. Insert the Scripteditor webpart
  4. Insert this code in the webpart and remember to edit the “SPBookmark_CaseID” to “SPBookmark_” + whatever name your field has
1

Edit the “new” and “edit” of a ListItem (NewItem.aspx and EditItem.aspx)

It is the same jQuery code that goes for the new item page and the edit item page.
  1. Edit a ListElement, thus letting you view the EditForm.aspx page or
  2. Add a Listelement, thus letting you view the NewForm.aspx page
  3. Edit the page (not the content)
  4. Add the Scripteditor webpart
  5. Insert the code in the webpart and remember to edit the “CaseID” to whatever name your input field has
1

Article taken from >> www.getinthesky.com

How to: Create a Simple SharePoint 2013 People Directory

Article taken from www.sharepointconfig.com
A people directory can be useful if you want to list all the people in an organisation without users having to enter a search query. Users can then narrow down the list using filters such as Department or Job Title to narrow the results. This is really easy to set up using the default SharePoint 2013 search web parts and doesn’t require writing a single line of code. An example of what this can look like is shown below:
sharepoint people directory
Especially when the organisation only contains a few hundred people this can help users discover people in the organisation without necessarily knowing their names. The steps to create this are as follow (assuming the user profile and search services are running successfully):
  1. Assuming you have an enterprise search center set up the first step to create the people directory is to enable the people search page layout so we can create a people search results page. This can be done by navigating to the Site Settings > Look and Feel | Page layouts and site templates page and selecting ‘(Welcome Page) Search People’ in the Page Layouts section.
    sharepoint available page layouts search
  2. The next step is to navigate to the pages library and select New Document > Page from the ribbon.
    sharepoint new page
  3. On the create page screen select the Search People page layout to create a page that contains the people search results web parts.
    sharepoint create people results page
  4. The standard search result web part does not show any results unless a query is specified. To get all people to show up by default we need to modify the query used by the People Search Core Results web part. This can be done by clicking the ‘Change Query’ button in the web part properties and adding a property filter that returns all people. To do this we can select the property ‘contentclass’ and enter the manual value ‘spspeople’.
    sharepoint search build query
  5. We now have a list of people that will be displayed as soon as the user navigates to our custom people results page. By default we also have some refinements that appear if matching metadata is found within the result set. These are the Department, Job Title, Keywords and Office Location columns. We can change these to show other metadata properties that are defined in our search centre by selecting the ‘Choose refiners’ option on the refinement web part. Note that the managed property must have the ‘Refinable’ option selected in the search schema for it to be available in this list.
    sharepoint search refinements

Adding Sorting by Last Name

Adding additional sort options is much easier than in SharePoint 2010. To add a custom sort option such as Last Name follow the steps below:
  1. Ensure that the managed property you want to sort by has the Sortable option enabled in the search schema. To do this navigate to the Search Service Application > Search Schema, click the LastName managed property and select the Sortable: ‘Yes – active’ option. Note you will need a full crawl for this to take effect.
    sharepoint 2013 managed property sortable
  2. On the search results page edit the People Search Core Results web part, check the ‘Show sort dropdown’ option and enter the following text:
    [{"name":"First name (A-Z)","sorts":[{"p":"FirstName","d":0}]},{"name":"First name (Z-A)","sorts":[{"p":"FirstName","d":1}]},{"name":"Last name (A-Z)","sorts":[{"p":"LastName","d":0}]},{"name":"Last name (Z-A)","sorts":[{"p":"LastName","d":1}]},{"name":"Social distance","sorts":[]}]sharepoint search sorting
  3. You should now be able to sort by first or last name in alphabetical order either A-Z or Z-A.
    sharepoint search people sorting

Using a Table Based Layout

Another option for the people directory is to use a table based layout with column headers for properties. In SharePoint 2013 this can be done using Display Templates. In this case we need to use two display templates – a control template for the table header, and a item template for each search result item. The steps to implement this are shown below.
  1. The first step is to add the display templates to the masterpage gallery by selecting Site Settings > Master Pages and Page Layouts > Display Templates > Search and upload the two html files from the following .zip archive.
    PeopleDirectoryDisplayTemplates.zip
  2. The next step is to edit the search core results web part and in the Display Template section set the Results Control Display Template to ‘Table Result’ and the Item Display Template to ‘People Table Item’.
    sharepoint search display template selection
  3. You should now see the results displayed as a table based layout as shown below:
sharepoint people directory table


If you have worked with previous versions of SharePoint you can see that in SharePoint 2013 the search features are much richer and easier to work with. There are also a number of new features such as query rules and extensibility options such as customising the hover panel that enhance the end user search experience.

Tuesday, April 19, 2016

SharePoint: List filtering by date range

Setting up multiple date filters to filter a list by a date range is possible out of the box in SharePoint 2010.
Using date filter web parts to send values to a lists parameters we can get the list to filter by a date range.
Setting this up is rather simple…
In your browser create a new page and add your populated list to it via the web parts options on the ribbons. For this example I’m just going to use my tasks list.
On the same page add a date filter webpart
2011-08-17-ListFilterByDate-01.jpg
From the arrow drop down that appears when you hover over the new date filter web part, select edit web part.
2011-08-17-ListFilterByDate-02.jpg
In the options pane that appears, change the Filter name to ‘Start Date’, and change the default value to ‘offset from today : 30 days : Before today’. Then click ok.
2011-08-17-ListFilterByDate-03.jpg
Underneath that, add another date filter and change its filter name to ‘End date’, and change the default value to ‘offset from today : 0 days : After today’. Then click ok.
2011-08-17-ListFilterByDate-04.jpg
Now save the page in your browser, then open the page up in SharePoint designer (SPD) – in design view.
2011-08-17-ListFilterByDate-05.jpg
Once opened in SPD, click on the list web part to select it, then in the ribbon click on the list view tools > options > parameters icon.
2011-08-17-ListFilterByDate-06.jpg
Add two new parameters, one called ‘startdate’ and another called ‘enddate. Leave the parameter sources and default values as default and click ok when done.
2011-08-17-ListFilterByDate-07.jpg
The parameters on the list allow us a point for our date filters to pass their values to. Now we need to set up the connections between the list and the date filters.
Right click on the start date filter and click add connection. In the dialog that pops up change the dropdown value to ‘Send filter values to’, click next.
2011-08-17-ListFilterByDate-08.jpg
Ensure that ‘connect to a web part on this page’ is selected in the next dialog and click next.
2011-08-17-ListFilterByDate-09.jpg
Change the target action in the next dialog to ‘Get parameters from’ and click next.
2011-08-17-ListFilterByDate-10.jpg
In the next dialog, select ‘Start Date’ from the first box, and ‘Startdate’ from the second box and click next. Then click finish.
2011-08-17-ListFilterByDate-11.jpg
Go through the same process with the second date filter, but in the final step select ‘End date’ and ‘Enddate’ from the boxes.
2011-08-17-ListFilterByDate-12.jpg
Now we have our date filters feeding the list with its values but we still have to set up the filter on the list.
Click the list web part to select it, then in the ribbon click on the list view tools > options > filters icon.
2011-08-17-ListFilterByDate-13.jpg
The filter criteria box will popup. First add a rule ‘Created > Greater than or equal to > [Start date]’.
2011-08-17-ListFilterByDate-14.jpg
Then add another clause ‘Created > Less than or equal to > [Enddate]’. Click ok.
2011-08-17-ListFilterByDate-15.jpg
Now save the page and open it back up in your browser.
It will, by default, show all tasks created in the last seven days thanks to the default setting of the start date filter. Changing these filter will filter the list according to the date ranges set.
2011-08-17-ListFilterByDate-16.jpg
PS: This article is part of a post.