Wednesday 22 April 2015

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>
  

0 comments:

Post a Comment