0

I'm using Javascript CSOM to try and integrate a Discussion list into a site I'm working on. However, I can't figure out what Discussion item fields are available for me to access via get_item(). I tried digging through the returned SPListItemCollection manually but it's so incredibly convoluted that diving into it only lead to recursion madness.

Here's the code I'm using to access the list of Discussion topics:

var commCtx = new SP.ClientContext('/sites/developer_mm');
var communityList = commCtx.get_web().get_lists().getByTitle("Discussion");

camlQuery = new SP.CamlQuery.createAllFoldersQuery();

communityItemsCollection = communityList.getItems(camlQuery);

commCtx.load(communityItemsCollection);
commCtx.executeQueryAsync(onGetCommunityPostsSucceeded, onGetDiscussionPostsFailed);

Through trial and error I've discovered that Title, Body, and Author are valid fields, but I still need to retrieve A) the date a discussion was posted, and B) something that will help me link back to that discussion. Is there somewhere I can look to see what fields are attached to a Discussion when I create it via Site Contents?

2
  • 1
    How about get_fieldValues() (on item)
    – eirikb
    Commented Feb 19, 2015 at 19:48
  • eirikb, you had the right answer. If you post it I'll mark it as such.
    – IAmKale
    Commented Feb 19, 2015 at 20:35

2 Answers 2

1

Try get_fieldValues() on item.

0

I usually get the list of available field names (internal names!) via PowerShell:

$web = Get-SPWeb http://YourSharePoint/web
$list = $web.Lists["Title of your list"]
$item = $list.GetItemById(12) # where 12 is the ID of an arbitrary (existing!) item in your list
$item.Fields | % { $_.InternalName }

Your Answer

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

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