"SharePoint list itme update error : Invalid data has been used to update the list item. The field you are trying to update may be read only."

Hi Everyone,
i am facing one problem ...
when i am updating an SharePoint List item, it is throwing above error....
This is my code......
 try
                tbl = getListDateTable("NCR");
                DataTable dt = tbl;
                oWebsite = mysite.OpenWeb();
                oList = oWebsite.Lists["NCR"];
                SPListItem itemToUpdate = null;
                foreach (SPListItem listItem in oList.Items)
                    listItem.Update();
                    workOrderID = Convert.ToInt32(txtTitle.Text);
                    itemToUpdate = listItem;
                //SPListItem itemToUpdate = oList.GetItemById(workOrderID);
                //itemToUpdate.Fields["Title"].ReadOnlyField = false;
                //string str = ddlStatus.SelectedValue;
                itemToUpdate["Title"] = txtTitle.Text;
                itemToUpdate["JobNumber"] = txtJobNumber.Text;
                itemToUpdate["PartNumber"] = txtPartNumber.Text;
                itemToUpdate["PartDescription"] = txtPartDescription.Text;
                //itemToUpdate["RequiredBy"] = txtRequiredBy.Text;
                itemToUpdate["ReportedBy"] = txtReportedBy.Text;
                itemToUpdate["WrittenBy"] = txtWrittenBy.Text;
                //itemToUpdate["DateOpened"] = txtDateOpened.SelectedDate;
                //itemToUpdate["DateClosed"] = txtDateClosed.SelectedDate;
                itemToUpdate.Update();
                oList.Update();
               // bind();
            catch (Exception ex)
                throw ex;
Thanks
viswanath

Hi Viswanath,
If you are using People/User Type Field Column then use below code methord
SPUser user = web.EnsureUser(loginName);
item["UserTypeFieldName"] = user;
Lookup Type Field Column then use below code methord
public static SPFieldLookupValue GetLookupFieldFromValue(string lookupValue,string lookupSourceColumn, SPList lookupSourceList)
SPFieldLookupValue value = null;
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name='" + lookupSourceColumn + "'/><Value Type='Text'>" + lookupValue + "</Value></Eq></Where>";
SPListItemCollection listItems = lookupSourceList.GetItems(query);
if(listItems.Count > 0 )
value = new SPFieldLookupValue(listItems[0].ID,lookupValue);
return value;
item["LookupField"] = GetLookupFieldFromValue(lookupfieldValue, lookupSourceColumn, listName);
Please mark the replies as answers if they help or unmark if not.

Similar Messages

  • WebPart is raising the following error "Invalid data has been used to update the list item.The field you are trying to update may be read only"

    I have created a farm solution and then i deploy it to SharePoint server, the code looks as follow, and i use it to update a page info values (as the current page values represents old info):-
    [ToolboxItemAttribute(false)]
    public partial class VisualWebPart1 : WebPart
    // Uncomment the following SecurityPermission attribute only when doing Performance Profiling using
    // the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
    // for production. Because the SecurityPermission attribute bypasses the security check for callers of
    // your constructor, it's not recommended for production purposes.
    // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
    public VisualWebPart1()
    protected override void OnInit(EventArgs e)
    base.OnInit(e);
    InitializeControl();
    using (SPSite site = new SPSite(SPContext.Current.Site.Url))
    using (SPWeb web = site.OpenWeb())
    SPList list = web.Lists["Pages"];
    web.AllowUnsafeUpdates = true;
    foreach (SPListItem items in list.Items)
    items["Author"] = "SharePoint";
    items["Created"] = "01/08/2014 01:44 PM";
    items.Update();
    list.Update();
    web.AllowUnsafeUpdates = false;
    protected void Page_Load(object sender, EventArgs e)
    but when i try adding this web part to a page i got the following error:-
    Invalid data has been used to update the list item.The field you are trying to update may be read only
    so can anyone advice?

    i only changed lines bitween 
    web.AllowUnsafeUpdates = true;
    and
    web.AllowUnsafeUpdates = false;
    and other parts of code remains without change
    so it will updates all pages in current web
    yaşamak bir eylemdir

  • Invalid data has been used to update the list item. The field you are trying to update may be read only (Lookup Field).

    Hi.
    I am getting below error while adding value to look-up field.
    Invalid data has been used to update the list item. The field you are trying to update may be read only.
    I have tried many forums ans post but didn't come to know what's the root cause of issue. I am also posting Code for creating and adding lookup field.
    CAML to create lookup field (It works Fine)
    string lkproductNumber = "<Field Type='Lookup' DisplayName='Product Number' StaticName='ProductNumber' ReadOnly='FALSE' List='" + pNewMaster.Id + "' ShowField='Product_x0020_Number' />";
    Code to insert value to lookup field
    ClientContext client = new ClientContext(SiteUrl);
    client.Load(client.Web);
    client.Credentials = new NetworkCredential(this.UserName, this.Password, this.Domain);
    // Lookup Lists
    List pmList = client.Web.Lists.GetByTitle("Product_Master");
    //List Conatining Lookup Columns
    List piList = client.Web.Lists.GetByTitle("Product_Inventory");
    client.Load(piList);
    query.ViewXml = "<View/>";
    ListItemCollection collection = pmList.GetItems(query);
    client.Load(collection);
    client.ExecuteQuery();
    int prodid=0;
    foreach (ListItem item in collection)
    if (Convert.ToString(item["Product_x0020_Number"]) == ProductNumber)
    { prodid = Convert.ToInt32(item["ID"]); }
    ListItem piItem = piList.AddItem(new ListItemCreationInformation());
    piItem["Product_x0020_Number"] = new FieldLookupValue() { LookupId = prodid };
    piItem.Update();
    client.ExecuteQuery();
    Exception Detail
    Microsoft.SharePoint.Client.ServerException was caught
    Message=Invalid data has been used to update the list item. The field you are trying to update may be read only.
    Source=Microsoft.SharePoint.Client.Runtime
    ServerErrorCode=-2147352571
    ServerErrorTypeName=Microsoft.SharePoint.SPException
    ServerStackTrace=""
    StackTrace:
    at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
    at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
    at WebServiceProviders.ClientServices.NewProductInventory() in Z:\.............ClientServices.cs:line 889
    InnerException:
    Quick response is highly appreciated.
    Thanks
    Mehar

    Try some thing like below,
    your data value that needs to be update should be in this format "ID of the lookup";#"Title of the Lookup" 
    For example,
    listItem["Product_x0020_Number"]
    = "1;#iPhone";
    listItem["Product_x0020_Number"]
    = "2;#Mobile";
    Hope this helped you....

  • Invalid data has been used to update the list item. The field you are trying to update may be read only.

    Trying to follow Serge Luca's Step by Step Tutorial. Creating Workflows for Windows Sharepoint Services and MOSS2007.  http://sergeluca.spaces.live.com/blog/cns!E8A06D5F2F585013!859.entry
    I have an onWorkflowActivated, followed by an ifElse condition and a log to history.
    In the IfElse, each branch has a code segment, that trys to update the status column in the list that the workflow is attached to.
    private void Authorize_ExecuteCode(object sender, EventArgs e)
    // tried serveral methods
    WorkflowProperties.Item["Status"] = "Automatically Approved";
    // tried all of the following (one at a time)
    item.update();
    WorkflowProperties.Item.Update();
    WorkflowProperties.Item.SystemUpdate();
    //tried this as well.
    Microsoft.SharePoint.SPListItem item = WorkflowProperties.Item;
    item["Status"] = "Automatically Approved";
    item.Update() ;
    On the update call I keep getting "Invalid data has been used to update the list item. The field you are trying to update may be read only."
    Could someone explain how to update "Status" column of the list item that the workflow is working on?
    Thank you very much.
    Bill
     

    Hi:
    you can do the following:
    add the following code to the workflow.xml file (under the MetaData section)
    Code Snippet
    <ExtendedStatusColumnValues>
    <StatusColumnValue>Branch1</StatusColumnValue>
    <StatusColumnValue>Branch2</StatusColumnValue>
    </ExtendedStatusColumnValues>
    then add 2 SetState activities one in each branch of the IfElse.
    for the code behind of setState1 (branch1) write the following code:
    Code Snippet
    state = Convert.ToInt32(SPWorkflowStatus.Max);
    for setState2 (branch2) write the following:
    Code Snippet
    state = Convert.ToInt32(SPWorkflowStatus.Max) + 1;
    where state is the variable assigned to the field State in the properties of the SetState(design lever), or instead of state u can use the following code:
    Code Snippet
    ((SetState)sender).State
    where sender is the object sent through the function parameter.
    hope this answered your question
    Best Regards

  • Smartview error when submitting/refreshing: "The cell or chart that you are trying to change is protected"

    Hello! Users are trying to submit data within a form, but they get the following error message:
    <<The cell or chart that you are trying to change is protected and therefore read-only. To modify a protected cell or chart, first remove protection using the Unprotectect Sheet command (Review tab, changes group). You may be prompted for a password.>>
    They get the same error when they try to refresh the form.
    The form is part of a task-list, but is not supposed to be protected. Actually they open the form from an empty excel workbook, so I don't understand what's the difference with other forms, where they don't have this message.
    Do you have an idea of what is triggering it?

    Users were in Smartview 11.1.2.1. The issue described above has been identifed as a software defect an it has been logged as bug 16017903 by Oracle. To solve this issue download and install Patch 16238382, or alternatively unistall Smartview and install version 11.1.2.2.310.

  • Error: "Variable State has been used outside the reusable components"

    When I open a query in the ad hoc query designer I get several error messages like "Variable State has been used outside the reusable components."  I don't what this means or how to fix it.
    "State" is one of the variables used.  And there is a error for every variable that is used.
    All the variables are in the free characteristics.
    When I open the query in Query Designer, it is ok.
    Any ideas?

    Hi Fong,
    PLease check the following link:
    http://help.sap.com/saphelp_nw04/helpdata/en/1f/03223c5f00612be10000000a11402f/content.htm
    It states that:
    You cannot integrate variables into the query directly.
    However, you can use variables in reusable structures, or restricted or calculate key figures, which are used in the Ad-hoc Query Designer
    Hope this helps...

  • Every time I try do download an app iTunes asks for a billing update, claiming my account has been used on another machine. Why?

    Why is it, since the last iTunes update, I'm asked to update my billing information every time I try to download or update an app?
    iTunes claims that my account has been used on another machine, but it's only running on my iPhone and my laptop as always.
    Help. It's bugging me.

    Lt Chu
    You can buy an iTunes card and redeem it at the on-line store.
    Cheers

  • TS3694 when a 1015 code pops up and you are trying to update your software what can you do?

    when a 1015 code pops up and you are trying toupdate your software on your 3G iphone how can you go about fixing that?

    Check this support document http://support.apple.com/kb/ts1275 for explanation for error codes. This explains the 1015 error code
    Error 1015: This error is typically caused by attempts to downgrade the iPhone, iPad, or iPod touch's software. This can occur when you attempt to restore using an older .ipsw file. Downgrading to a previous version is not supported. To resolve this issue, attempt to restore with the latest iPhone, iPad, or iPod touch software available from Apple. This error can also occur when an unauthorized modification of the iOS has occurred and you are now trying to restore to an authorized, default state.
    The iPhone 3 does not support newer iOS, and there is no iPhone 3G as you list in your profile. If you are referring to the iPhone 3GS, it will support iOS 6, but if you tried to put something else in there, this explains your problem.

  • I am running with Firefox version 3.5.7. I am trying to update to a more recent version. So far, the update has been running for 4 hours. For most of the time it has been downloading versoin 3.6.18. Why am I hanging trying toi update?

    I have an old version of Firefox - Version 3.5.7.
    I am trying to update to the current version. As part of the update, the system is first loading all of the intermediate versions.
    I started the update 4 hours ago. It is still running. Most of the time, it has been downloading version 3.6.18. I am letting it run.
    Is there any other way to get the most recent version?

    Thank you. That is basically what I did. I gave up on the update and downloaded a fresh version of Firefox.

  • Hello since i got the new itunes update 2012,my ipod has been having problems,didnt have these before the update

    i have a 120 gig ipod classic,i noticed i was having problems,with itunes taking longer to sync,after spending almost 2 hours up loading all my movies music,to my ipod,then after all was done i would get an error 69 message,in the middle of the sync,then all my music would be on there some movies,music worked fine,most movies didnt except for a few,that happened once,most times after syncing there was no music movies, on the ipod,,then i would reconnect to itunes,tried to restore my ipod was taking forever,then when i clicked restore,would take longer,very annoyed,think its the new itunes causing problems for me,hoping i wont have to purchas up dates,done that before,paid 450 3 years ago for the ipod,paid for lots of music,movies,its not very old,but to apple the thing is probebly considered ancient,any help would be cool,

    Read this Apple Support Article on handling error 69  it may be a bad corrupted file.
    Or worst case the iPod Hardisk need to be check, as you are saying that it is taking longer than usual.
    Do the iPod Disk Diagnostic as posted earlier by tt2, it wont fix your problem but helps in troubleshooting.
    Have a nice day!

  • Have just got my iphone back from my daughters who has been using it. I have put my sim card in and cannot update it or do anything as it is stating emergency calls only. it only recognises on itunes as her iphone what should i do please

    i have just got my 3gs back from my daughter and i have put my sim card in and it comes up as emergency calls only. That is my first problem then when i plug it into itunes it only recognises it as her iphone can anyone help my please ?

    I agree with wjosten. Sounds like a sim card issue. Was your sim card removed from a working,activated phone? I've switched sim cards in an iphone multilple times and never had a problem. You might try removing the sim card and reinstalling.

  • Am unable start Photoshop (CS5.1 Extended version), it gives me this message: Could not initialize Photoshop, because the preferences file was invalid (it has been deleted). Please help, thanks.

    Dear Friends or anybody, please help.
    Am unable start Photoshop (CS5.1 Extended version), it gives me this message:
    Could not initialize Photoshop, because the preferences file was invalid (it has been deleted).
    I have also watched the video on “restoring peferences” trouble shooting above, but got nowhere.
    Please help me, am leaving Canada on a business trip to China in 36 hours and I need to work using Photoshop. Thank you.
    Benny

    Check these solutions here Re: Preferences File was invalid.
    Gene

  • Which version of JDeveloper has been used

    hi
    If one would stumble upon some source files of an ADF application for which there is not much context available (like e.g. in the forum thread "SelectBooleanCheckBox/SelectBooleanRadio and getTransaction().isDirty()") ...
    ... (q1) How can be determined which exact version of JDeveloper has been used to create (or work on) the ADF application?
    many thanks
    Jan Vervecken

    Thanks for the replies John and Timo.
    John Stegeman wrote:
    It's not as easy as it would seem.Hence the question.
    ... but even the metadata in there doesn't necessarily give you an exact answer.To avoid confusion, only an exact answer would seem to make sense.
    Timo Hahn wrote:
    ... check the version properties of the meta data files ... The highest number which is used points to the jdev version used to build the file. ...It seems rather inconvenient to have to check each and every meta-data file to determine the (exact/preferred) version of JDeveloper to work on the ADF application.
    I wonder what the Oracle intended/preferred approach is to determined the version of JDeveloper to use, based on the ADF application source files alone, answering (q1).
    (Also when extension are taken into account, see for example the somewhat related questions in forum thread "use the same extensions for all developers".)
    (This delayed reply was caused by the many "currently experiencing network connectivity errors" responses I got from the OTN forum, especially after login.)
    regards
    Jan

  • Cannot send email via AOL on iPad2 - "A copy has been placed in your Outbox. Sending the message content to the server failed."

    My CEO has an ipad2 and I set it up w/ AOL.  She cannot send any email via her AOL account from her iPad.  She gets a message that says "A copy has been placed in your Outbox. Sending the message content to the server failed."   We've tried it on wifi and on 3G (Verizon version).  I've removed the account and added it, I've tried setting it up as an IMAP account vs. using Apples standard AOL mail setting and nothing seems to work.  The SMTP settings are smtp.aol.com, port 587.  I've tried adding an alternate server/smtp, but I haven't been able to find anything that works.  Any advice or other people having this issue?  It works fine sending an email from her aol web mail.  And unfortunately, having her sign up for a gmail account is not an option.  Thanks

    Interesting.  Firstly I have been on AOL since the early 90s with no current intention to switch as my primary personal email account.
    I have two email accounts on my iphone - AOL and my email from my business website.  I deleted both and then recreated first the business account and then the AOL account.  Same error.  Then I wasn't sure what you suggested but I turned off the AOL SMTP server and selected the business email SMTP server by turning it on with the same result.  I still get the error "A Copy has been placed in your Outbox.  Sending the mssage content to the server failed."
    Perhaps this problem will get fixed by IOS 6.   AOL will not talk to me unless I pay and Apple says its not their problem.  So for the time being I use the AOL web interface in the iPhone's Safari to send emails from the phone.

  • Object has been disconnected or does not exist at the server

    Hi,
    I have a report which had run daily without any problem for months. Now it stops after quite a lot of time with error: 'object .rem has been disconnected or does not exist at the server'.
    I have checked the dataset queries and the parameters, and everything is fine. I changed the timeout for the report as well, but it did not help either. I don't use a hidden object.
    Could anyone tell me what's happening?
    Many thanks.
    P.

    I'm using 2008. I had thought the bug was fixed in it during the past 4.5 years.
    And what is a 'bad default'? And how come that the report worked for a long time without problems? If it is a known bug, it should have prevented proper running from the beginning.
    Hi Pelso,
    This issue has been fixed in SSRS 2008R2. If you need to fix this issue in a previous release of Reporting Services, I would suggest opening a case with Microsoft Customer Support Services (CSS) (http://support.microsoft.com),
    so that a dedicated Support Professional can assist you in a more efficient manner.
    Regards,
    Elvis Long
    TechNet Community Support

Maybe you are looking for