So I learned and have used the following to update a list item by ID using Javascript Client Object Model:
function updateItem(passedID) {
var ctx = new SP.ClientContext.get_current();
var myList = ctx.get_web().get_lists().getByTitle('Example');
this.listItem = myList.getItemById(passedID);
this.listItem.set_item("Title", "different value");
this.listItem.update();
ctx.executeQueryAsnyc(Function.createDelegate(this, this.OnHooray), Function.createDelegate(this, this.onAwww));
}
function onHooray(sender, args) {
alert('hooray');
}
function onAwww(sender, args) {
alert('Awww');
}
So this is the basic idea, but I would am interested in finding out if I can apply a CAML query instead of updating by the Id in every instance. So for example if I had a ProjectID within the example list could I somehow apply this:
var proproductIDVal = "TR543A1Z";
"<Query><Where><Eq><FieldRef Name = 'ProjectID'/><Value Type='Text'>" + productIDVal + </Value></Eq></Where>"</Query>";
so that whatever Id that has a record gets updated instead of knowing (or querying for) the record Id everytime in advance? Is this is possible would and there were multiple records would that update every record that held that value?
greatly appreciated as I can't seem to find a reference to this in particular anywhere.