jeudi 12 février 2015

C# example - pre populate and display sharepoint list form



Can someone provide or point me in the direction of a c# example of how to:



  • create a SharePoint list form (in an existing list)

  • pre populate specific fields on the from

  • then display the default modal popup "edit" form that SharePoint uses for data entry, so the user can complete remaining fields on the form.


This is the code I have so far. Seems to work for the first two points above. However when I try to get the "web.Url" in order to construct the url for my edit form, I get a "PropertyOrFieldNotInitalizedException". How to I initialize web.Url in the code below ?


ClientContext clientContext = new ClientContext(url); SP.List oList = clientContext.Web.Lists.GetByTitle(listTitle); ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); SP.ListItem oListItem = oList.AddItem(itemCreateInfo); oListItem["Title"] = guid;

oListItem.Update();

clientContext.ExecuteQuery();


SP.Web web = oList.ParentWeb; string webUrl = web.Url;


return String.Format("{0}/{1}?ID={2}", webUrl, dispUrl, oListItem.Id);








0 commentaires:

Enregistrer un commentaire