You need to sign in to do that
Don't have an account?
Update - how to update records on a custom object
I'm trying to build a statement to update some records. I'm having trouble understanding the method and syntaxt. Trying to do this via PHP, forming statements based on this page http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_update.htm
In a nutshell I don't understand what the first term "Contact" in this line from the docs is:
Contact c = [select account.name from contact
where lastName = 'Carter' limit 1];
I'm trying to build a statement like this:
$qry = "XXX cbp = [SELECT Supplier_Code__c FROM MyObj__c WHERE ManufacturerName__c = 'Fish Corp'];";
$qry .= "cbp.Supplier_Code__c = 'FISHCO';";
$qry .= "UPDATE cbp;";
But lost as to what/where the "XXX" term is or where to find it re my custom object...
Hope this makes sense
Thanks.
So then you can pass the Objects one by one in the update call. There is not limitation like in APEX.
Good luck!
Etienne
All Answers
Hi,
I don't think you can query that way in php.
I would try something like:
Thanks Etienne. I'm getting
EXCEEDED_ID_LIMIT: record limit reached. cannot submit more than 200 records into this cal
but looks like the right track, thanks
Hmmm.
That is probably because update does not accept more than 200 records at a time.
Can you try changing the line
to
I did try that, but no change. The update() line causes the error, I guess the $response object needs chunking up somehow.
I confess I'm somewhat out of my depth but will experiment more tomorrow... cheers.
So then you can pass the Objects one by one in the update call. There is not limitation like in APEX.
Good luck!
Etienne
Thanks so much Etienne, I owe you a beer...
Had to make a slight mod. After dumping $result I found it demanded an ID. Bit of searching round the web and modded to this:
Add Id to query
$query = "SELECT Id, Product_Name__c ... "
Add Id to the new object:
foreach ($response->records as $record) {
$myObj = new SObject($record);
$myObj->Id = $record->Id;
Works like a charm... cheers!