You need to sign in to do that
Don't have an account?
Doubt Scheduled
Hi all ,
I have written the apex scheduled class and which will fire everyday and it will fetch the records from the custom object of certain criteria and try to update the account to which the record is associated .
I just paste my code below is it possible to write like :
global class AccountStatusUpdat Implements Schedulable
{
global void execute(SchedulableContext sc)
{
List<Online_Application__c> oa=new List<Online_Application__c>();
List<Online_Application__c> os=new List<Online_Application__c>();
oa=[Select id,Account__r.Account_Status__c from Online_Application__c where StatusUpdatedDate__c < Last_N_Days:15 ];
for(Online_Application__c oo: oa)
{
oo.Account__r.Account_Status__c='Disengaged';
os.add(oo);
}
update os;
}
}
My question is :
I have queried the like
Select id,Account__r.Account_Status__c from Online_Application__c where StatusUpdatedDate__c < Last_N_Days:15 through i get the account status of the application and i try to update the status of the account below
like this
oo.Account__r.Account_Status__c='Disengaged'; Is it right way of doing this ?
oo.Account_Status__c='Disengaged '; is enough .
Can anyone help me out of this ..
Thanks in advance
Well you are doing it correctlyoo.Account__r.Account_Status__c='Disengaged';Because Account_Status__c is field of account you have to traverse all the way to account using the relationship field ("Account__c") to access its values
Sorry I didnt read the question properly.To do update
Hi avidev,
Nice to hear from you ,
Its correct way , thats great to hear ,
but i just update the custom object records list i mean os list in my case
How come it will update the associated account record for custom object records .
List<Online_Application__c> oa=new List<Online_Application__c>();
List<Online_Application__c> os=new List<Online_Application__c>();
oa=[Select id,Account__r.Account_Status__c from Online_Application__c where StatusUpdatedDate__c < Last_N_Days:15 ];
for(Online_Application__c oo: oa)
{
oo.Account__r.Account_Status__c='Disengaged';
os.add(oo);
}
update os;
Thanks in advance.
Hi Avidev,
I need the same as you specified in the comment and i want to know whether upating account via custom object is possible or not.
Anyway thank you so much .
You cannot directly update using the relationship
Hi
I need a help on this . I have go through lot of things in the board but couldn't find the solutions and after viewing the solutions for the above question , I can see the light at the head.
It will work with less effort and can you take a look on it .
http://boards.developerforce.com/t5/Apex-Code-Development/Doubt-Bulkification-of-wonderful-trigger/m-p/664790