José Cruz
José Cruz

Reputation: 35

sharepoint insert new item list

I am trying to insert new ListItems in a Sharepoint 2010 List already created. The code I'm using is:

ClientContext ctx = new ClientContext("http://bigboss/sites/presidencia"); Web thisWeb = ctx.Web; ctx.Load(thisWeb);

  List processosList = ctx.Web.Lists.GetByTitle("Processos");
  ListItemCreationInformation lici = new ListItemCreationInformation();
  ListItem liNovoProcesso = processosList.AddItem(lici);
  liNovoProcesso["Title"] = processo.Identificador;
  liNovoProcesso["IdentificadorProcesso"] = processo.Identificador;
  liNovoProcesso["DescricaoProcesso"] = processo.Descricao;
  liNovoProcesso["NotasObservacoesProcesso"] = processo.NotasObservacoes;
  liNovoProcesso["SituacaoProcesso"] = processo.Situacao;
  processosList.Update();
  ctx.ExecuteQuery();

This code runs without erros or exceptions, but the list isn't showing the items. I've already tried to change Field names to trigger an error, just to be sure that the code its running, and it throws an error, like expected!

Any tips, please?

thanks,

José Cruz

Upvotes: 2

Views: 490

Answers (1)

Madhur Ahuja
Madhur Ahuja

Reputation: 22709

Are you missing ? liNovoProcesso.Update();

You should update the ListItem object instead of List.

Upvotes: 2

Related Questions