In my hosted app I have one text field which contains username. I want to apply filter on a view which on filtering gives me data related to current user.

<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" DisplayName="Name" Required="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" FromBaseType="TRUE" ColName="nvarchar1" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Version="1" RowOrdinal="0" />

I can only have above text field to apply filter. How to apply caml query for this situations

  • How come you are not using a user-column? May 18 '16 at 6:01

A CAML query for that would look something like this

                <FieldRef Name='Title'/>
                <Value Type='Text'>username</Value>

But I do wonder why you are not using a field of user type, to be able to do a better filtering (and a better GUI for the end users)

  • will the username replaced with current logged in username May 18 '16 at 6:11
  • You would need to manually place the current users login name there in your scenario. If you instead use a user column you could put in <UserID /> as outlined here sharepoint.stackexchange.com/questions/35975/… May 18 '16 at 6:16
  • is there a possible solution without using user column May 18 '16 at 6:21
  • Not without you creating the CAML-query yourself (eg. pass in the username dynamically) May 18 '16 at 6:26
  • do you have any reference for this condition May 18 '16 at 9:58

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.