I have an list of links in sharepoint foundation site. In this list I have a particular link lets say "www.yahoo.com" and I need to append querystring ?id=domain\userid to it. Let me know how to do it so that every user who is logged in his/her user id is appended in this particular link like : www.yahoo.com?id=domain\userid



This answer can diffenently help you.

You'll need a reference to this some where on your page. Add that JS file to your Layouts folder.

Add an HTML Form Web Part to the page and add a reference to the spservices.js file and then add the linked answer script below.

Your final result should look something like this:

<script type="text/javascript" src="/_layouts/myJavascripts/spservices.js"></script>
<script type="text/javascript">
    operation: "GetUserInfo",
    async: false,
    userLoginName: $().SPServices.SPGetCurrentUser(),
    completefunc: function (xData, Status) {
        $(xData.responseXML).find("User").each(function() {
            curUserId = $(this).attr("ID");
            curUserName = $(this).attr("Name");
            curFullUserName = $(this).attr("ID")+";#"+$(this).attr("Name");

All you have to do from here is add some javascript or jquery which will add the information to the link webpart's URls and then you should be good to go!

Hope this helps :)

  • Cant I do this through XLST ?
    – RHM
    Mar 12 '12 at 12:36
  • Yes, it is possible to implement in XSLT :)
    – user2536
    Mar 12 '12 at 14:19

You could do it this way:

1) Create a custom Sharepoint application page, under _layouts.

2) Create links to this page, using a query string for the target url e.g. YOUR APP PAGE.aspx?site=www.yahoo.com

3) In the app page code, append the current user id to the target url and redirect.

  • Cant I do this through XLST ?
    – RHM
    Mar 12 '12 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.