function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chennachenna 

Scheduling Job on custom object......Urgent

Hi,

 

There are two objects opportunity, Distributor data__c

 

There is an amount formula field on Distributor data__c object.

 

So how can i schedule a daily job for that amount field  to update on opportunity object.It needs to  update amout field if distributor data has opportunites  asscociated & there stage needs to be from 1-3 stages only.

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

For scheduling a class Schedulable interface have to be implement to the class and override global void execute(SchedulableContext sc) method.

 

After creating the class schedule the class by following the below steps

 

Develop->Apex Classes-> click on Schedule apex-> follow the instruction

 

For the reference use the below code

 

global class BIPL_fffff implements Schedulable
{
	global void execute(SchedulableContext sc)
	{
		List<AAAA__c> permits = [Select Id from AAAA__c where (Status__c='Open' OR Status__c='Pending' OR Status__c='Processing') and Expiry_Date__c<:System.today()];
		if(permits.size()>0)  
		{
			for(AAAA__c p:permits)
			{
				p.Status__c='Expired';
			}
			update permits;
		}
	}
}

 

 

for detail about the Scheduling Job refer the below link

 

http://salesforcesource.blogspot.com/2010/02/utilizing-power-of-batch-apex-and-async.html

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.