How to create a back button in Sharepoint

By peter.stilgoe









How to create a back button in Sharepoint to take you back to the previous page either using a text link or image -

Text link:

<a href="#" onClick="history.go(-1)">Back Link Text</a>

Using a back button image:

<a href="#" onClick="history.go(-1)"><img src="linktobackbuttonimage.gif" alt="Back"/></a>

Note: I have only tested this in Internet Explorer




Share

Leggi tutto

Sharepoint: How to find a Sharepoint feature by GUID

By peter.stilgoe









If you need to find a Sharepoint feature by its GUID because you are getting the error:

Error: The site template requires that the feature *GUID* be activated in the site collection

1) Site Actions -> Site Settings -> Site Collection Features

2) Right click on the features page and select ‘View Source’

3) Now do a search/find for the GUID & you will find the one in question (if its still installed on the farm)




Share

Leggi tutto

Sharepoint 2010 One Way Trust users on the trusted domain do not return any search results

By peter.stilgoe









If you have you Sharepoint 2010 Farm setup in one domain & your users are in a seperate domain using a one way trust, when they perform a search they will not return any search results. This is because the account running the app pool for the search query service is running using a domain account on the trusting domain.

This account has no rights on the domain where the users sit to determine how the search results should be security trimmed etc. My initital thought was we need to run the search query app pool account using an account on the same domain as the users which does / will work.

However a better way is to run the following powershell command:

$searchapp.SetProperty("ForceClaimACLs",1)

now run a ‘Full Crawl’ and you users should now return search results as expected over the one way trust.

You can display you Search App details with the following command:

Get-SPEnterpriseSearchServiceApplication

Note: After performing the above search alerts will be broken. If you do need search alerts you can try running your search app pool with an account from the user domain.

Share

Leggi tutto

SPDataSource Cross List Data View – Roll up all tasks across site collection

By peter.stilgoe









Add the following code to your Data View webpart (tbc)

<SharePointWebControls:SPDataSource runat="server" DataSourceMode="CrossList" SelectCommand="<Webs Scope='Recursive'></Webs><Lists ServerTemplate='107'</Lists><Query /><ViewFields><FieldRef Name='Title' /><FieldRef Name='Status' /><FieldRef Name='PercentComplete' /><FieldRef Name='Matter_x0020_Number' /><FieldRef Name='Task_x0020_KPI' /></ViewFields><QueryOptions />" UseInternalName="True" UseServerDataFormat="True" ID="dataformwebpart1"><SelectParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{470C3D07-87CE-4FFD-908B-A59223155B15}" Name="ListID"></WebPartPages:DataFormParameter><asp:Parameter DefaultValue="0" Name="StartRowIndex"></asp:Parameter><asp:Parameter DefaultValue="0" Name="nextpagedata"></asp:Parameter><asp:Parameter DefaultValue="10" Name="MaximumRows"></asp:Parameter>

Share

Leggi tutto

How to display related information in a Sharepoint form based on a column / field choice

By peter.stilgoe









Looking to to automatically complete various columns in your Sharepoint forms based on the selection in a previous column ? If so take a look at SpServices Jquery library.

Here you have a function called: $().SPServices.SPDisplayRelatedInfo that will do just that.

Functionality
SPDisplayRelatedInfo is a function in the jQuery Library for SharePoint Web Services that lets you display information which is related to the selection in a dropdown. This can really bring your forms to life for users: rather than just selecting bland text values, you can show them images and links that are related to their choices.

How Does It Work?
The SPDisplayRelatedInfo function works like this:

When the function is first called, it attaches an event handler to the dropdown control. The logic here varies a bit depending on what type of dropdown it is.
When the selected option in the dropdown changes, SPDisplayRelatedInfo calls two Lists Web Service operations:

- GetList on the relatedList to get information about its columns (fields)
- GetListItems to get the items where the specified column’s value matches the current selection. Note that there can be multiple items returned; generally displayFormat: “table” makes more sense if you’ll want to display multiple items.
- For each column it’s asked to display, SPDisplayRelatedInfo calls a private function (showColumn) to render the column value based on its type. Most of the normal column types are covered, though locale conversions can’t be done from the client side (yet!). The related information is shown in a DIV which is inserted into the form. The DIV is named “SPDisplayRelatedInfo_” + columnStaticName in case you need to do any post-processing.

Tip: If you don’t want to see the column headers, pass in ms-hidden for headerCSSClass. (This is a CSS class in core.css which sets display: none.)

Prerequisites
You’ll need to have a list (relatedList) which contains the values in the dropdown in one column and the related values you’d like to display in additional columns. If you’re already using SPCascadeDropdowns, then you’ll already have a list (or lists) in place which you can use here.

Sample usage:


<script type="text/javascript">
$(document).ready(function() {
$().SPServices.SPDisplayRelatedInfo({
	columnName: "Consultant Lookup",
	relatedList: "Consultants",
	relatedListColumn: "Consultant_x0020_Name",
	relatedColumns: ["Sector"],
	displayFormat: "list",
	debug: true
	});
});
</script>

You will need to reference your Jquery & SpServices either in each page or specify it within your master page so its available throughout the whole site eg.

<script language="javascript" type="text/javascript" src="/jQuery%20Libraries/jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript" src="/jQuery%20Libraries/jquery.SPServices-0.5.6.min.js"></script>

SpService Codeplex Project

SpServices Display Related Info Function

Share

Leggi tutto

Sharepoint 2010: How to get the people picker to work across domains in one way trust

By peter.stilgoe









If you have your Sharepoint farm hosted in a different domain to your users you will notice that the people picker only looks at its local domain, ie does not list any users from the Internal / User domain. Luckily you can get round this fairly easily:

Run this command on all Sharepoint servers in your farm:

stsadm -o setapppassword -password <AnyPasswordYouWant>

Then run this commmand for each web app:

stsadm.exe -o setproperty -url <YourWebApp> -pn "peoplepicker-searchadforests" -pv "domain:<YourDomain>,<Domain Account>,<password>"

You should now be good to go & pull people & resolve names from both domains.




Share

Leggi tutto

Sharepoint 2010: How to hide the quick launch menu

By peter.stilgoe









To hide the quick launch menu in Sharepoint 2010 add a content editor webpart (CEWP) at the bottom of your page with the following code in it:

Share

Leggi tutto

Populating an Infopath dropdown using a specific Sharepoint list view

By peter.stilgoe









If you have a Sharepoint list containing multiple views, one view shows all approved items and another view shows all items that are pending approval. You have an Infopath form where you have a dropdown control that you want to be populated with only ‘Approved’ list items from your Sharepoint list.

If you create your Infopath data connection & copy the URL to this list view as your source you will notice it still returns ALL items as opposed to your filtered view listing only the approved items.

The way round this is to create you data connection using an XML source, use this link to find out how to view your list data as XML and get the source URL – http://www.petestilgoe.com/2009/11/converting-a-sharepoint-list-into-xml/

Now you need to expand on this & add the particular view to the url to make the data connection get the filtered data for you.

Currently your URL looks something like this:
/_vti_bin/owssvr.dll?Cmd=Display&List={GUID}&XMLDATA=TRUE&noredirect=true

1) Now in your Sharepoint list click ‘Settings’ –> ‘List Settings’

2) Scroll down to the bottom & click on the view you want to use as your datasource

3) Now your URL contains the {List GUID} as well as the {View GUID}

eg. /_vti_bin/owssvr.dll?Cmd=Display&List=%7BD66DCB51%2D80B0%2D43AB%2DB80B%2DCD7D23E63B09%7D&View=%7B6D0CEF69%2DF899%2D40D0%2D86B2%2D6E01CC7D9CA1%7D&XMLDATA=TRUE

4) The URL is encoded so you will need to replace “%7B” with “{” and “%7D” with “}” and “%2D” with “-” so now your url will look something like

/_vti_bin/owssvr.dll?Cmd=Display&List={D66DCB51-80B0-43AB-B80B-CD7D23E63B09}&View={6D0CEF69-F899-40D0-86B2-6E01CC7D9CA1}&XMLDATA=TRUE

5) Use this url as your XML data source in Infopath and your drop down data will be filtered as per your chosen view.

Share

Leggi tutto

How to display most viewed documents from a Document Library

By peter.stilgoe









Came accross an interesting solution on Linkedin to display most viewed Documents from a Document Library in a webpart. I havnt tried it myself but sounds like it would work:

1) Install LogParser on Web App Server (Sharepoint Index Server)

2) Setup a batch file with the LogParse query of your choice.
For example:
“C:\Program Files\Log Parser 2.2\logparser” -i:IISW3C -o:XML “SELECT TOP 10 REPLACE_CHR(cs-uri-stem,’+',’ ‘) AS sUrl, EXTRACT_FILENAME(cs-uri-stem) AS sName, EXTRACT_EXTENSION(cs-uri-stem) AS sExt, COUNT(*) AS [Total Hits] INTO MYFILE.XML FROM \\WFE1\C$\Windows\system32\LogFiles\W3SVC1\*.log, \\WFE2\C$\Windows\system32\LogFiles\W3SVC1\*.log WHERE TO_UPPERCASE(sUrl) Like ‘/SITES/SPECIALSITE%%’ AND TO_UPPERCASE( sExt ) IN (‘DOCX’;'PPTX’;'PNG’;'GIF’;'JPG’;'BMP’) AND TO_UPPERCASE(sUrl) Not Like ‘%%/_T/%%’ AND TO_UPPERCASE(sUrl) Not Like ‘%%/_W/%%’ GROUP BY sUrl,sName,sExt ORDER BY [Total Hits] DESC

3) This query code search only for some documents (docx, pptx, etc.) on the site ‘/sites/specialsite’ on the default web application and site collection W3SVC1. The logs are located on WFE1 and WFE2. The log parser result file is an XML file named MYFILE.XML.

4) Daily Schedule the execute of the batch and the upload of the xml file to a sharepoint document library

5) Create an XSLT file for presentation and upload to the sharepoint document library.

6) Finally show the XML with the XML WebPart with the xml and xslt files as the parameters.

Share

Leggi tutto