Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have the unique requirement of needing to get the current user's id (domain\logon) for use within a Content Query Web Part. If no documents are retrieved with the CQWP I need to craft a custom url in the format site/employees/currentuserlogon/. How do i get that information?

The proposed functionality would be as follows:

A user accesses a generic top level page with a Content Query Web Part pulling the most recent form that the user authored. If there is no form that the user authored, than a custom link will appear that allows the user to create a form. The link is user specific, using the logon account as part of the site path.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

I haven't done much with the CQWP because I find it falls down as soon as you want to do anything really hard. That said, there's a CAML variable you can use in a DVWP:

<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>

It probably is available somehow in a CQWP, too.

share|improve this answer
    
Unfortunately the DVWP isn't working as a rollup with the proper settings. The CQWP works but I need that one piece of information to build the null result link. =( –  Serious SharePoint Mar 13 '10 at 15:40
    
Can you add to your post what you're trying to do from a functionality perspective? –  Marc D Anderson Mar 13 '10 at 22:27
    
Original post updated, I hope that helps. Thanks! –  Serious SharePoint Mar 14 '10 at 0:15
1  
OK, the DVWP should totally be able to do this. When you say form, you mean item(s) in list(s). Are you wanting to look at one list or multiple lists? Either way, it can work with a DVWP. You're going to have far more flexibility with a DVWP. –  Marc D Anderson Mar 14 '10 at 17:08
    
DVWP is really the right way to do this, CQWP doesn't allow for this variable out of the box and doesn't seem that you can modify the XSLT to retrieve it. –  Serious SharePoint Mar 16 '10 at 10:04
add comment

Hopefully someone here knows of a this can be done without needing to write custom code. However I have found before the need to extend the CQWP to send through extra information such as this to the XSLT.

Waldek Mastykarz has some great tutorials for the CQWP and many other things on his blog, of which this is one should help you.

share|improve this answer
add comment

Agreed with Marc on this one the DVWP adds the parameter he mentions above in by default which represents the current userID. Its also really easy to specify a template which will be used when no results are returned. Just click on 'Common Data View Tasks' and select Data View Properties. Under General tick 'Display text if no matching items are found'.

This adds a template to the XSL called 'dvt_1.empty' you can edit this to display your link. All the logic is pre-built for you.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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