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

Lookup filed not update through Batch apex
Hello evey one i want to Update my Lookup filed wich is avilable in opportunity.
i m trying to update my Account name which is conected to opportunity. so can u plz give me suggation how to achive this.
i want to change my Account name from wadia to Bai Jerbai Wadia Hospital for children
plz help me
In Advance Thanks
i m trying to update my Account name which is conected to opportunity. so can u plz give me suggation how to achive this.
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){ } }
String q = 'SELECT Id,name,Account.name FROM Opportunity where Account.name = Wadia'; String s = 'Opportunity'; String f = 'Account.name'; String v = 'Bai Jerbai Wadia Hospital for children'; Id batchInstanceId = Database.executeBatch(new b1(q,s,f,v), 5);
i want to change my Account name from wadia to Bai Jerbai Wadia Hospital for children
plz help me
In Advance Thanks
You can directly query on Account :
If you want to update only those accounts whose Name = Wadia and have atleast one child opportunity then,
Your query is malformed at where condition(Account.name = Wadia).
use below query .
Make it as best answer if it helps.
Thanks.
thanks for your suggation, But as per your suggation i done changes it will update both Account As well as Opportunity.
i want to update only in Opportunity.
so can u please give me suggation for that.