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

Friday, April 8, 2011

Changing return URL for SharePoint Forms

By default, when users fill out a SharePoint form, they are navigated back to the "All Items" page after pressing OK. You can easily change this behavior by altering what is in the “source=http://…” part of the URL "query string" on the form page.

Example: Let's add a link to the Announcements “New Item” form on the home page, so that it returns the user back to the home page after they press ok.

Step 1) Add the following URL to the home page:
http:///Announcements/Forms/NewItem.aspx?Source=http:///default.aspx

That’s it! :) Once the user presses OK, the form will read the “source=” part of the URL and navigate the user back to that page.

Friday, July 23, 2010

SharePoint People Picker

Have you ever wondered if you can retrieve data like email, job title, etc, from the people picker control in SharePoint using Javascript? In short, yes it can be done and it is pretty simple.

Below is some javascript which accepts a parameter for the the position of the control, and returns the desired value.

function getEmailFromPoeplePicker(identifier)
{
var tags = document.getElementsByTagName('DIV');
for (var i = 0; i < tags.length; i++)
{
var tempString = tags[i].id;
if ((tempString.indexOf(identifier) > 0) && (tempString.indexOf('UserField_upLevelDiv') > 0))
{
var pplHTML = tags[i].innerHTML;
var valReturn = pplHTML.indexOf(">Email");
if (valReturn > 0)
{
pplHTML = pplHTML.substr(valReturn + 12);
var ValuePos1 = pplHTML.indexOf(">");
var ValuePos2 = pplHTML.indexOf("");
if (ValuePos1 > 0 && ValuePos2 > ValuePos1)
return (pplHTML.substring(ValuePos1 + 1, ValuePos2));
}
}
}
return null;
}

if you wish to return any other details from the people picker simply modify this line :

pplHTML = pplHTML.substr(valReturn + 12);

Change the substr value of 12 to the following :

29 For the mobile number
12 Gets the Job Title

This is only 3 of many examples of how it can be done, feel free to comment if you have found a better way.