You need to sign in to do that
Don't have an account?

Updating a column of a table
can anyone tell me how to update a column of a table through apex classes?
I have created a method for updating and i used update(list type variable) command. It is throwing a run time error like "Illegal view ID update. The ID must begin with / "
what does this mean? please suggest...
Make sure that you properly bind your action with something in your controller,
action="{!theColumnRefreshAction}"
rather than
action="theColumnRefreshAction
See the followingthread for more details:
Possible Solution
All Answers
Here is the method that i ve included in an apex class:
public PageReference updatecheck() {
list<Product_PT__c> updates = new list<Product_PT__c>();
list<Product_PT__c> values;
integer k = 0;
values = [select id, check__c from Product_PT__c where check__c = TRUE limit 50];
Integer j = [select count() from Product_PT__c where check__c = TRUE];
for(k =0; k<j; k++){
values[k].check__c = FALSE;
updates.add(values[k]);
}
update updates;
return null;
}
Well, the first issue I see is that you are only querying 50 Product_PT__c records in the first SOQL query and then your FOR loop will iterate through potentially more than 50 recors since there is no LIMIT clause on the 2 query (select count()...)
So my first question is: What does j equal in your scenario?
And why not change the for loop to read:
for(k =0; k<values.size(); k++){
The count that i have right now is well below the limit. I am not worrying about that. The fact is I got the error before i put the limit clause.
what i think might be the reason is there is an id that is associated with every record. so i have to retrieve those ids and update the same while updating another column of the table. Do u have any idea about how to retrive the record ids in apex method. In javascript we can use GETRECORDIDS method. In apex coding, i dont know.
Make sure that you properly bind your action with something in your controller,
action="{!theColumnRefreshAction}"
rather than
action="theColumnRefreshAction
See the followingthread for more details:
Possible Solution