Pergunta

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.

Foi útil?

Solução

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.

Outras dicas

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.

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top