Friday, March 19, 2010

Error 5337 when Submitting Data from InfoPath 2007 to a SharePoint List

There might be two reasons:-

1. security issue

In infopath editor, Go to form option, set full trust and create trusted certificate. That should make it work.

2. If you are using RunWithElevatedPrivilages or updating list

This happens mostly when you call SPListItem.Update inside the RunWithElevatedPrivileges block. So you should

•Declare your SPWeb object outside elevated block.
•Get SPWeb object inside elevated block.
•Use & Dispose SPWeb object outside elevated block

SPWeb myWeb = null;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite mySite = new SPSite("URL"))
{
myWeb = mySite.RootWeb;
}
});
myWeb.AllowUnSafeUpdates = true;
// using myWeb object access your list item, call update method on SPListItem
myWeb.AllowUnSafeUpdates = false;
myWeb.Dispose();

=========================================================

No comments: