I am trying to increase the value of number field in an SObjects, how could I do this ?
-
To answer the last question, you cannot alter fields purely with SOQL. You must first fetch the record and then update it as you are doing now.– ScottWCommented Sep 17, 2014 at 14:37
-
@mast0r I rolled this back as to a new comer it got confusing with the answer below, and I think that answer is valid. Be interesting to see if some others come up!– Matt Lacey ♦Commented Sep 18, 2014 at 0:00
Add a comment
|
1 Answer
I did it using this way
object = [SELECT Id, views FROM SObject WHERE ID =: id ];
object.view++;
update object;
-
You better update your existing question rather than create a new answer that is actually not an answer. Commented Sep 17, 2014 at 13:52
-
I was going to update the question, but I thought that this would be another question. People may want to ask about the same thing in the question :) Commented Sep 17, 2014 at 13:59
-
Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question.– Keith CCommented Sep 17, 2014 at 14:02
-
@mast0r I will create a new question about the SOQL only Commented Sep 17, 2014 at 14:03
-
@KeithC sorry, I thought it would be better to create a new question Commented Sep 17, 2014 at 14:04