Hi There,
I am working on a form that submits to several sharepoint lists. I'm not using a data connection as I am working with the SharePoint object model using a browser based form. I have hooked up a button to some code tested in a spike console app. The code:
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();SPListItem item = null;
try
{
SPList list = web.Lists["MyList"];
//SPListItem item = list.Items[];web.AllowUnsafeUpdates = true;foreach (SPListItem i in list.Items)
{
if (item["ID"].ToString() == readNode("/my:myFields/my:group/my:ID"))
{
item = i;
break;
}
}
if (item != null)
{
item[
"Full Name"] = "Monkeys";
item.Update();
list.Update();
}
//item.Update();
}
catch
{
}
finally
{
web.AllowUnsafeUpdates = false;
site.Close();
web.Dispose();
}
After publishing to the IPFS server and clicking the button, I get the following CAS related error:
Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e8888c' failed.
That was the first line in a rather long winded error message contain the entire Ipermissions object and the failure at each point.
I must admit I've never used approach before, however, i have run methods from the main submit code block that contain code to add items to lists on other forms and not recieved errors like this even without elevating permissions.
Am I missing something here?
Do I have to set canceleventargs as with submission through data connections?
I have also tried substituting the the SPSite context for a hardwired one and run it preview mode. Same error though.