You need to sign in to do that
Don't have an account?
Dev Rana 16
Batch apex not updateing filed
Hi every one. i m using batch apex to update value. when i run the code it gives me a success msg but cant update filed. plz tell me what is the problem..
My Code
My Code
global class b1 implements Database.Batchable<Sobject>{ global final string query; global final string s_object; global final string Field; global final string field_value; global b1(string q, string s,string f, string v){ Query = q; s_object = s; Field = f; field_value = v; } //start method has a return type of database query locater it will takes a query and return data global Database.QueryLocator start(Database.BatchableContext BC){ return Database.getQueryLocator(query); } //this method processing the data global void execute(Database.BatchableContext BC, List<sObject> batch ){ for(sObject o : batch){ o.put(Field, field_value); } update batch; } global void finish(Database.BatchableContext BC){ } }And in anonymous window i m pasing this prameter
String q = 'SELECT Description FROM Account LIMIT 10'; String s = 'Account'; String f = 'Description'; String v = 'updated'; Id batchInstanceId = Database.executeBatch(new b1(q,s,f,v), 5);
your Code work fine nothing issue in your code.
in anonymous window also makr checkbox (tick) for Open Log like below.
in your Developer Console you able to see the log like belwo check the conform update with this string
after conform these thing go to Account and and select Recently modified from right side Dropdown see below,
click the first record and check the Desciption Field value. so you came to know your code works..
hope i helped you Mark Best ANSWER if its work for you.
Thanks
karthik
Check how many Account records are in org And if it is more then 10 don't give any limt .
Regards ,
Harish.R
https://developer.salesforce.com/forums/ForumsMain?id=9060G000000XZcVQAW