0

I need to query from pages library to get a HTML column. This column contains rich text and references to various URLs(anchor tag). The query should return items which contain a column value with hyperlink to certain URL Pattern.

For ex: Column contains "http://example.com/my-sites/......[UniqueIDWhichVaries].aspx"

Below is my caml query:

   <ViewFields>
      <FieldRef Name='MyColumn' />
   </ViewFields>
   <Where>
      <Contains>
         <FieldRef Name='MyColumn' />
         <Value Type='HTML'>a href=http://example.com/my-sites/</Value>
      </Contains>
   </Where>
   <QueryOptions>
      <ViewAttributes Scope='RecursiveAll' />
   </QueryOptions>

This query does not return expected results.

I would like to know what is the best way to retrieve such items. I need to use this query in a power shell script.

Can anyone help me here, please?

Thanks in advance!!!

2 Answers 2

1

To put this in powershell you can use the following reference: https://gallery.technet.microsoft.com/office/How-to-do-a-CAML-Query-6f5260cf

0

Please try this below query:

<ViewFields>
      <FieldRef Name='MyColumn' />
   </ViewFields>
   <Where>
      <Contains>
         <FieldRef Name='MyColumn' />
         <Value Type='Note'>http://example.com/my-sites/......[UniqueIDWhichVaries].aspx</Value>
      </Contains>
   </Where>
   <QueryOptions>
      <ViewAttributes Scope='RecursiveAll' />
   </QueryOptions>

You can encode the square brackets using their unicode value in query:

http://example.com/my-sites/......&#91;UniqueIDWhichVaries&#93;.aspx

Hope this will help you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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