Button Control Submitting to SPList - InfoPath Dev
in

InfoPath Dev

Button Control Submitting to SPList

Last post 03-12-2010 07:37 AM by mrsafe. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-12-2010 06:43 AM

    Button Control Submitting to SPList

    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. 

     

     

     

  • 03-12-2010 07:37 AM In reply to

    Re: Button Control Submitting to SPList

    Ok So I'm an idiot!,

    I Had started with a fresh template and didn't set the trust level to "full trust" inside tools\form options\Security and Trust. Sorry to waste anyones time!. 

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.