Skip to content

Instantly share code, notes, and snippets.

@miragedeb
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miragedeb/34aafd27de7360d946e3 to your computer and use it in GitHub Desktop.
Save miragedeb/34aafd27de7360d946e3 to your computer and use it in GitHub Desktop.
TaskOpenerController
public with sharing class TaskOpenerController{
public List<QA_Release__c> releases {get;set;}
public Integer numberOfReleases {get;set;}
public Id qaId {get;set;}
public DateTime creDate {get;set;}
private Id releaseClientId;
public Decimal difference {get;set;}
public TaskOpenerController (ApexPages.StandardController stdcontroller) {
//Extract the Id of the current QA Release record
qaId = stdController.getId();
//Extract the client Id from the above record
QA_Release__c qaRel = [SELECT Client__c,CreatedDate FROM QA_Release__c WHERE Id= :qaId ];
releaseClientId = qaRel.Client__c;
creDate = qaRel.CreatedDate;
System.debug('Record creation date is: ' + creDate);
difference = Decimal.valueOf((DateTime.now().getTime() - creDate.getTime())/1000) ;
System.debug(' Difference between Now and Record Creation is: ' + difference + ' seconds');
//Find all records excluding the current record that have above client as account
releases = [SELECT Id
FROM QA_Release__c
WHERE Id!= :qaId AND (Client__c= :releaseClientId AND
(Status__c='Not Started' OR Status__c = 'In Progress' OR
Status__c = 'On Hold' OR Status__c ='Re-opened'))];
numberOfReleases = releases.size();
System.debug('Number of Releases for this account is: ' + numberOfReleases);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment