• Presb
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
We have a data sync process that normally takes 10 minutes. We are testing changes to that process, and with each test, the amount of time it takes to retrive data from the API increases. The latest tests are taking 90 minutes. Does anyone know why our performance could be degrading?
 
  • March 17, 2016
  • Like
  • 0

Hi All,

 

I have a custom object by name 'Portfolio__c'. I have a picklist field 'Status_c' with values 'New' and 'Activated'.

When the record is first created the Status value is New. 

After 30 minutes of the record creation, I need to update the Status to Activated automatically.

 

I have written the following trigger, but still not able to update the field.

trigger portfolioAfterInsertAfterUpdate on Portfolio__c (after insert, after update) {

	List<Portfolio__c> Pfs = new List<Portfolio__c>();
	for (Integer i=0;i<trigger.new.size();i++) {	
		Pfs = [Select Name, Status__c, CreatedDate, Id from Portfolio__c where Status__c =: 'New' limit 1];	
	    if(Pfs.size() > 0 && Pfs.get(0).Status__c == 'New'){
	    	Datetime dt = Pfs.get(0).CreatedDate;
	    	dt = dt.addMinutes(30);
	    	if(dt == system.now()){
		    	Portfolio__c pf = new Portfolio__c(id=Pfs.get(0).id, Status__c = 'Activated');
		        update pf;
	    	}
	    }
	}
}

Could you please tell me where I have gone wrong or any work around to do the same.

Any help will be highly appreciated.