0

I have a discussion board. Using client object model, I can create a new thread:

List lst = ctx.Web.Lists.GetByTitle("Test");

//Create the topic
ListItem t = Utility.CreateNewDiscussion(ctx, lst, templateSubject);
t["Body"] = templateBody;

t.Update();

But, how can I get the new thread's url? Query the list again? which field I should load?

2
  • Are you tryin to reply to created discussion item? Apr 28, 2015 at 0:24
  • no, I try to get the url of the discussion thread. so I can send it to someone else to check the thread.
    – urlreader
    Apr 28, 2015 at 1:51

1 Answer 1

1

ListItem["FileRef"] returns server relative url of list item, in case of Discussion item the format is as follows:

/Lists/Discussion/<Topic title>

Example:

var list = ctx.Web.Lists.GetByTitle("Discussion");
var t = Utility.CreateNewDiscussion(ctx, list, templateSubject);
t["Body"] = templateBody;
t.Update();
ctx.Load(t);
ctx.ExecuteQuery();
var topicAbsUrl = ctx.Url + t["FileRef"];  //get absolute url

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.