Script:
$(document).ready(function ()
{
var thisUser = $().SPServices.SPGetCurrentUser();
var userLocation;
$().SPServices(
{
operation: "GetUserProfileByName",
async: false,
AccountName: thisUser,
completefunc: function (xData, Status)
{
userCountry = getUPValue(xData.responseXML, "country");
var path = "documentlibraryURL?FilterField1=CountryField&FilterValue1="+ userCountry;
window.location.href=path;
}
});
});
function getUPValue(x, p) {
var thisValue = $(x).SPFilterNode("PropertyData").filter(function() {
return $(this).find("Name").text() == p;
}).find("Value").text();
return thisValue;
}
</script>
$(document).ready(function ()
{
var thisUser = $().SPServices.SPGetCurrentUser();
var userLocation;
$().SPServices(
{
operation: "GetUserProfileByName",
async: false,
AccountName: thisUser,
completefunc: function (xData, Status)
{
userCountry = getUPValue(xData.responseXML, "country");
var path = "documentlibraryURL?FilterField1=CountryField&FilterValue1="+ userCountry;
window.location.href=path;
}
});
});
function getUPValue(x, p) {
var thisValue = $(x).SPFilterNode("PropertyData").filter(function() {
return $(this).find("Name").text() == p;
}).find("Value").text();
return thisValue;
}
</script>
Filter script for document library | SharePoint 2010 Tutorial