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....
Similar Messages
-
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 -
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 -
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
viswanathHi 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. -
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.
-
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 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.
-
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.
-
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.
BennyCheck 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 VerveckenThanks 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 -
I noticed that my credit card info is old. I'm wonering if that could be the reason for the notice. OR does it reallly mean that my account has really been accessed by another source? Of course, this is the first time seeing this and it's Easter!
Any help greatly appreciated.
lisa1952It means that is is the first time that the device that you are using has been used to make a purchase in the iTunes Store.
I get the same message whenever I buy a new iPhone or iPad. It's normal. -
I'm about to buy an item in the apps store but I forgot my secret question, so i tried and tried to remember my secret question but it ended up that my account has been locked. I reset my account - new email has been used. I log-in in the apps store but there is no option that i can use no credit card. I have 25$ apple wallet and i want to use it. What will I do?
Oh gosh, I saw the same issue. Because i was messing around with something earlier. I don't know why Apple took off the option of "none" as a payment since not everyone puts in a credit card and people use iTunes gift cards. I think they just made that changed recently. Anyways, Ive just found out about this new issue also, so i don't know what you could do... maybe call apple support?
-
SAP has been used in SHIP building industry?
Hi
I need to find out how SAP has been used in SHIP building industry, is there any case study or process where I can read the stuff. I need how sap help the ship building domain.
NitinDear,
Just search internet 'SAP for Ship building Industries" and I get 186,000 results with lots of PDF's and Case studies. Please check and these will helpful for you.
Regards,
Syed Hussain. -
Whether I try to download a free or paid app. The roblem is I don't have that card anymore, I switched banks. I try to enter my new card info and I keep getting the same message.
It means that is is the first time that the device that you are using has been used to make a purchase in the iTunes Store.
I get the same message whenever I buy a new iPhone or iPad. It's normal. -
How to update selected list items in SharePoint 2010?
Hello All
I have a list containing field named "Category". I want to develope a solution which will take two inputs: Old Category and New Category. The expected result is: all the list items will be fetched which have Old Category input value in
their category field and the field is replaced with the input value New Category.
I have a limitation that I can not use Visual Studio. So I am thinking to create aspx page with content editor webpart. But I am new to all these things. Could you please suggest the development approach for this?
Thanks.Hello,
I don't think CEWP can help you because you won't be able to find old and new category when there is any change in list. However you can identify the latest modified item from list but how will you identify whether category is old or new. If you have any
other column in list which can tell you that category value has been updated then you can write ECMA or Jquery script to update other items.
If have any column in list then see below jquery code, where you will see how to query the list: (In my case it is Active)
var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>";
soapEnv += "<listName>Highlights</listName>";
soapEnv += "<query><Query><Where><Eq><FieldRef Name='Active' /><Value Type='Text'>Yes</Value></Eq></Where><OrderBy Override='TRUE'><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy></Query></query>";
soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/><FieldRef Name='ows_FileLeafRef'/><FieldRef Name='Links'/></ViewFields></viewFields><rowLimit></rowLimit>";
soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";
Please comment if i misunderstood you?
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help
Maybe you are looking for
-
Impact of Field Status change in production
Hello Experts, While doing MB1c intial stock upload i got an error that "Fld selection for mvmt type 561/acct 230000 differs for Ext GA amount in LC(023). I found that the feild Ext GA amount in LC is made optional for mvnt type 561. For gl 230000 th
-
On three or four occasions i have purchased items on my sims game for the ipad and koney has been deducted from my account but the items have not been purchased. Now about 10 minuted ago i purchased money for the sims game of a cost or around £35 and
-
Acquiring Classic for 10.4.8
I bought a new macbook pro a few days ago, and I have some games that I want to play on it that require classic. I have an older g3(originally 10.2.8, now 10.4) with classic on it. I read on another topic that you can simply transfer the classic syst
-
Is it possible to restore recent history information once it has been cleared?
One of my kids cleared her search history by mistake and would dearly love to have it back. Is it possible to restore it once it has been deleted?
-
i write xml file in Eclipse and compile it its giving errors.