retrieving the value of a multiple choice column from SharePoint document library

Mark Collins asked on May 25, 2017 21:57

I am trying to get the values from a multiple choice column in a document library list. When I use this transformation:

<a href="<%# GetSharePointFileUrl("FileRef") %>"><%# Eval("FileLeafRef") %> {<%# Eval("Document_x0020_Type").ToString() %>}

the page displays System.String[] for the Document_x0020_Type. I am guessing I have to somehow parse this as an array or something to get the selected choices?

is there a way to do this in the transformation or do I have to do it in my CAML query? here is my current query, returning all fields.

Image Text

please advise and thanks!

Recent Answers


Prashant Verma answered on May 26, 2017 07:48 (last edited on May 26, 2017 07:50)

Hi Mark,

Yes you can go with transformation to parse value and write your own logic. Transformation support's runat server scripts in which you can define a function or method to perform any operation on the page, it act's similar as code-behind of your transformation.

In transformation how to call function

<a href="<%# GetSharePointFileUrl("FileRef") %>">
   <%# Eval("FileLeafRef") %>
  {<%# GetSelectedValueAndParseString(Eval("Document_x0020_Type").ToString()) %>} 
</a>

How to define your method to parse and get selected value

<script runat="server"> 
  protected void GetSelectedValueAndParseString(object DocumentValue)
  {
    var Output;
    //Write your logic to parse DocumentValue which holds Document_x0020_Type and get selected value.
    return Output
  }
</script>

It look like this

Capture

Thanks

Happy to help you

1 votesVote for this answer Mark as a Correct answer

Mark Collins answered on May 26, 2017 17:47 (last edited on May 26, 2017 17:48)

As far as I can tell, the Eval("Document_x0020_Type") actually actually returns, literally, "SystemString[]" as a string, not an object.

do i have to do something different in the CAML Query?

Thanks for you help. I really appreciate it.

0 votesVote for this answer Mark as a Correct answer

Mark Collins answered on June 20, 2017 21:02

anybody else have any ideas on this one? Eval on a multiple choice field does not return the list of selected choices.

0 votesVote for this answer Mark as a Correct answer

Mark Collins answered on July 6, 2017 19:51

Just received confirmation that this is bug and will be in the next hotfix. Thanks for your help!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.