SharePoint Discussion Forum Get url using CAML Query

Sometime we may need to get the Discussion forum list item url (folder url), we can use CAML Query to get that.

we can set the viewfields of the caml query with the below.

string stViewFields = “<FieldRef Name=’ID’/><FieldRef Name=’FileRef’ /><FieldRef Name=’Title’/><FieldRef Name=’Body’ />”;

add  the viewfields of the camlquery with FileRef field that will give the folder relative url

SPQuery camlQuery = new SPQuery();

camlQuery.Query = strQuery;

camlQuery.ViewFields = stViewFields;

SPListItemCollection ItemColl = currentWeb.Lists[“DiscussionListName”].GetItems(camlQuery);

The above list item collection will return the discussion list with folder relative url.