ffrr.ForecastServiceglobal with sharing class ForecastService Methods
generateForecastsglobal static Id generateForecasts(ffrr.ViewService.Tab tab) Starts the Async Apex Job that generates the Draft forecasts and forecast lines for all the source records that match the filter criteria. The Job ID is returned. Input Parameters
Return ValueThis service returns an ID object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Note: This sample demonstrates how to call the generate method for a specific object //within a specific tab, and therefore relies on there being data within the system. //For the sample to run Settings, Templates and data records should be available. If //the data isn't available then the results will vary. //Get the years for which you wish draft forecasts to be generated. List<ffrr__RecognitionYear__c> years = [SELECT Id FROM ffrr__RecognitionYear__c]; List<Id> yearIds = new List<Id>(); for(ffrr__RecognitionYear__c year : years) { yearIds.add(year.Id); } //Setup the items that we'll be filtering by. For the purposes of this sample we //won't add any filters ffrr.ViewService.Tab filters = new ffrr.ViewService.Tab(); ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter(); if (UserInfo.isMultiCurrencyOrganization()) //If this is a multi-currency org... tabFilter.currencyName = UserInfo.getDefaultCurrency(); //...set the currency filter tabFilter.years = yearIds; filters.tabFilter = tabFilter; //Note: The objectType is the object type of the group/tab being queried - adjust as necessary filters.objectType = Opportunity.getSObjectType(); //Call the generate method to start the Async Apex Job and get the Job id. ID asyncJobID = ffrr.ForecastService.generateForecasts(filters); retrieveByForecastIdsglobal static List<ffrr.ForecastService.Forecast> retrieveByForecastIds(List<Id> forecastIds) Retrieves forecasts for the specified forecast ID's. A list of ffrr.ForecastService.Forecast objects is returned. Input Parameters
Return ValueThis service returns a list of ffrr.ForecastService.Forecast objects. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Note: This sample demonstrates how to call the retrieveByForecastIDs method and therefore //relies on there being data within the system (if no data is available, no data //will be retrieved). If you wish to add Settings, Templates, Recognition Years //and Periods, and the corresponding data items then the results that are returned //will alter. //Create a List to hold existing forecast ids. List<ID> forecastIDs = new List<ID>(); forecastIDs.add('a1ga00000111sg1'); forecastIDs.add('a1ga00000111sg2'); forecastIDs.add('a1ga00000111sg3'); //Call the method to retrieve the forecasts List<ffrr.ForecastService.Forecast> forecasts = ffrr.ForecastService.retrieveByForecastIDs(forecastIDs); retrieveByPrimaryRecordIdsglobal static List<ffrr.ForecastService.Forecast> retrieveByPrimaryRecordIds(List<Id> primaryRecordIds) Retieves forecasts by top level parent record ID. A list of ffrr.ForecastService.Forecast objects is returned. Input Parameters
Return ValueThis service returns a list of ffrr.ForecastService.Forecast objects. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Note: This sample demonstrates how to call the retrieveByPrimaryRecordIDs method and therefore //relies on there being data within the system (if no data is available, no data //will be retrieved). If you wish to add Settings, Templates, Recognition Years //and Periods, and the corresponding data items then the results that are returned //will alter. //Create a List to hold existing primary record ids. List<ID> primaryRecordIDs = new List<ID>(); primaryRecordIDs.add('a1ga00000111sg1'); primaryRecordIDs.add('a1ga00000111sg2'); primaryRecordIDs.add('a1ga00000111sg3'); //Call the method to retrieve the forecasts List<ffrr.ForecastService.Forecast> forecasts = ffrr.ForecastService.retrieveByPrimaryRecordIDs(primaryRecordIDs); retrieveDraftsglobal static List<ffrr.ForecastService.ForecastLine> retrieveDrafts(Id parentRecordId, Integer parentLevel, ffrr.ViewService.Tab tab) Retrieves draft forecast line records when expanding a summary item on the Forecast Revenue page for the specified parent item, applying the supplied filters. The returned data includes both detail and summary items (which may then be used to expand deeper into the available data). Input Parameters
Return ValueThis service returns a list of ffrr.ForecastService.ForecastLine objects. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Note: This sample demonstrates how to call the retrieveDrafts method and therefore //relies on there being data within the system (if no data is available, no data //will be retrieved). If you wish to add Settings, Templates, Recognition Years //and Periods, and the corresponding data items then the results that are returned //will alter and, depending on the data, demonstrate drilling down into data //Setup the recognition date that we'll be using Date recognitionDate = Date.newInstance(2013, 01, 05); Id yearId = [SELECT Id FROM ffrr__RecognitionYear__c WHERE Name = '2017'][0].Id; //Setup the items that we'll be filtering by. For the purposes of this sample we //won't add any filters ffrr.ViewService.Tab filters = new ffrr.ViewService.Tab(); ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter(); if (UserInfo.isMultiCurrencyOrganization()) //If this is a multi-currency org... tabFilter.currencyName = UserInfo.getDefaultCurrency(); //...set the currency filter tabFilter.recognitionDate = recognitionDate; tabFilter.years = new List<Id>{yearId}; filters.tabFilter = tabFilter; //Note: The objectType is the object type of the group/tab being queried - adjust as necessary filters.objectType = Opportunity.getSObjectType(); //Extract the top level items (e.g. projects) List<ffrr.ForecastService.ForecastLine> draftForecastLines = ffrr.ForecastService.retrieveDrafts(null, null, filters); ID parentRecordID = null; //Output the retrieved draft lines for(ffrr.ForecastService.ForecastLine draftForecastLine : draftForecastLines ) { System.debug('Forecast line (Root): '+draftForecastLine); //To demonstrate drilling down into data, see if there exists a summary line (i.e. something that we can drill into) //and record the line's record id. if(draftForecastLine.lineType == ffrr.CalculationService.LineType.SUMMARY) { parentRecordID = draftForecastLine.record.id; } } //Note: The following section of code demonstrates how to drill into a summary item. It will only //execute if we identified something to drill into though in the above loop if (parentRecordID != null) { draftForecastLines = ffrr.ForecastService.retrieveDrafts(parentRecordID, 1, filters); //Output each of the child lines that we retrieved for (ffrr.ForecastService.ForecastLine draftForecastLine : draftForecastLines) { System.debug('Forecast line (Child): ' + draftForecastLine); } } retrieveLatestglobal static List<ffrr.ForecastService.ForecastLine> retrieveLatest(Id parentRecordId, Integer parentLevel, ffrr.ViewService.Tab tab, String category) Retrieves the latest version of forecast lines when expanding a summary item on the Forecast Revenue page for the specified parent item and forecast category, applying the supplied filters. The returned data includes both detail and summary items (which may then be used to expand deeper into the available data). Input Parameters
Return ValueThis service returns a list of ffrr.ForecastService.ForecastLine objects. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Note: This sample demonstrates how to call the retrieveLatest method and therefore //relies on there being data within the system (if no data is available, no data //will be retrieved). If you wish to add Settings, Templates, Recognition Years //and Periods, and the corresponding data items then the results that are returned //will alter and, depending on the data, demonstrate drilling down into data //Setup the recognition date that we'll be using Date recognitionDate = Date.newInstance(2013, 01, 05); Id yearId = [SELECT Id FROM ffrr__RecognitionYear__c WHERE Name = '2017'][0].Id; //Setup the items that we'll be filtering by. For the purposes of this sample we //won't add any filters ffrr.ViewService.Tab filters = new ffrr.ViewService.Tab(); ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter(); if (UserInfo.isMultiCurrencyOrganization()) //If this is a multi-currency org... tabFilter.currencyName = UserInfo.getDefaultCurrency(); //...set the currency filter tabFilter.recognitionDate = recognitionDate; tabFilter.years = new List<Id>{yearId}; filters.tabFilter = tabFilter; //Note: The objectType is the object type of the group/tab being queried - adjust as necessary filters.objectType = Opportunity.getSObjectType(); //Extract the top level items (e.g. projects) List<ffrr.ForecastService.ForecastLine> latestForecastLines = ffrr.ForecastService.retrieveLatest(null, null, filters, 'Best'); ID parentRecordID = null; //Output the retrieved draft lines for(ffrr.ForecastService.ForecastLine latestForecastLine : latestForecastLines ) { System.debug('Forecast line (Root): '+latestForecastLine); //To demonstrate drilling down into data, see if there exists a summary line (i.e. something that we can drill into) //and record the line's record id. if(latestForecastLine.lineType == ffrr.CalculationService.LineType.SUMMARY) { parentRecordID = latestForecastLine.record.id; } } //Note: The following section of code demonstrates how to drill into a summary item. It will only //execute if we identified something to drill into though in the above loop if (parentRecordID != null) { latestForecastLines = ffrr.ForecastService.retrieveLatest(parentRecordID, 1, filters, 'Best'); //Output each of the child lines that we retrieved for (ffrr.ForecastService.ForecastLine latestForecastLine : latestForecastLines) { System.debug('Forecast line (Child): ' + latestForecastLine); } } retrieveNewglobal static List<ffrr.ForecastService.ForecastLine> retrieveNew(Id parentRecordId, Integer parentLevel, ffrr.ViewService.Tab tab) Creates zero value forecast lines from the source records with forecast templates attached, that match the filter criteria. The method retrieves those forecast line items when expanding a summary item on the Forecast Revenue page for the specified parent item, applying the supplied filters. The returned data includes both detail and summary items (which may then be used to expand deeper into the available data). Input Parameters
Return ValueThis service returns a list of ffrr.ForecastService.ForecastLine objects. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Note: This sample demonstrates how to call the retrieveNew method and therefore //relies on there being data within the system (if no data is available, no data //will be retrieved). If you wish to add Settings, Templates, Recognition Years //and Periods, and the corresponding data items then the results that are returned //will alter and, depending on the data, demonstrate drilling down into data //Setup the recognition date that we'll be using Date recognitionDate = Date.newInstance(2013, 01, 05); Id yearId = [SELECT Id FROM ffrr__RecognitionYear__c WHERE Name = '2017'][0].Id; //Setup the items that we'll be filtering by. For the purposes of this sample we //won't add any filters ffrr.ViewService.Tab filters = new ffrr.ViewService.Tab(); ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter(); if (UserInfo.isMultiCurrencyOrganization()) //If this is a multi-currency org... tabFilter.currencyName = UserInfo.getDefaultCurrency(); //...set the currency filter tabFilter.recognitionDate = recognitionDate; tabFilter.years = new List<Id>{yearId}; filters.tabFilter = tabFilter; //Note: The objectType is the object type of the group/tab being queried - adjust as necessary filters.objectType = Opportunity.getSObjectType(); //Extract the top level items (e.g. projects) List<ffrr.ForecastService.ForecastLine> newForecastLines = ffrr.ForecastService.retrieveNew(null, null, filters); ID parentRecordID = null; //Output the retrieved draft lines for(ffrr.ForecastService.ForecastLine newForecastLine : newForecastLines ) { System.debug('Forecast line (Root): '+newForecastLine); //To demonstrate drilling down into data, see if there exists a summary line (i.e. something that we can drill into) //and record the line's record id. if(newForecastLine.lineType == ffrr.CalculationService.LineType.SUMMARY) { parentRecordID = newForecastLine.record.id; } } //Note: The following section of code demonstrates how to drill into a summary item. It will only //execute if we identified something to drill into though in the above loop if (parentRecordID != null) { newForecastLines = ffrr.ForecastService.retrieveNew(parentRecordID, 1, filters); //Output each of the child lines that we retrieved for (ffrr.ForecastService.ForecastLine newForecastLine : newForecastLines) { System.debug('Forecast line (Child): ' + newForecastLine); } } retrieveSpecificglobal static List<ffrr.ForecastService.ForecastLine> retrieveSpecific(Id parentRecordId, Integer parentLevel, ffrr.ViewService.Tab tab, Id forecastId) Retrieves saved forecast line records for a specific forecast record when expanding a summary item on the Forecast Revenue page for the specified parent item, applying the supplied filters. The returned data includes both detail and summary items (which may then be used to expand deeper into the available data). Input Parameters
Return ValueThis service returns a list of ffrr.ForecastService.ForecastLine objects. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Note: This sample demonstrates how to call the retrieveSpecific method and therefore //relies on there being data within the system (if no data is available, no data //will be retrieved). If you wish to add Settings, Templates, Recognition Years //and Periods, and the corresponding data items then the results that are returned //will alter and, depending on the data, demonstrate drilling down into data //Setup the recognition date that we'll be using Date recognitionDate = Date.newInstance(2013, 01, 05); Id yearId = [SELECT Id FROM ffrr__RecognitionYear__c WHERE Name = '2017'][0].Id; //Setup the items that we'll be filtering by. For the purposes of this sample we //won't add any filters ffrr.ViewService.Tab filters = new ffrr.ViewService.Tab(); ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter(); if (UserInfo.isMultiCurrencyOrganization()) //If this is a multi-currency org... tabFilter.currencyName = UserInfo.getDefaultCurrency(); //...set the currency filter tabFilter.recognitionDate = recognitionDate; tabFilter.years = new List<Id>{yearId}; filters.tabFilter = tabFilter; //Note: The objectType is the object type of the group/tab being queried - adjust as necessary filters.objectType = Opportunity.getSObjectType(); //Note: The following code implies that there exists a forecast record and we have its id. ID forecastRecordID = 'a0sa00000011op1'; //Extract the top level items (e.g. projects) List<ffrr.ForecastService.ForecastLine> specificForecastLines = ffrr.ForecastService.retrieveSpecific(null, null, filters, forecastRecordID); ID parentRecordID = null; //Output the retrieved draft lines for(ffrr.ForecastService.ForecastLine specificForecastLine : specificForecastLines ) { System.debug('Forecast line (Root): '+specificForecastLine); //To demonstrate drilling down into data, see if there exists a summary line (i.e. something that we can drill into) //and record the line's record id. if(specificForecastLine.lineType == ffrr.CalculationService.LineType.SUMMARY) { parentRecordID = specificForecastLine.record.id; } } //Note: The following section of code demonstrates how to drill into a summary item. It will only //execute if we identified something to drill into though in the above loop if (parentRecordID != null) { specificForecastLines = ffrr.ForecastService.retrieveSpecific(parentRecordID, 1, filters, forecastRecordID); //Output each of the child lines that we retrieved for (ffrr.ForecastService.ForecastLine specificForecastLine : specificForecastLines) { System.debug('Forecast line (Child): ' + specificForecastLine); } } getJobglobal static ffrr.ForecastService.Job getJob(Schema.Sobjecttype groupName) Retrieves the last Generate Forecasting Batch Apex job for the specified group. The returned job will include details such as the status of the job and the number of records processed. Input Parameters
Return ValueThe latest job for the specified group or null if no job exists Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Note: This sample demonstrates how to call the getJob method and therefore relies //on there being data and jobs within the system. If there are no jobs in the system //getJob will return null. //Call the method ffrr.ForecastService.Job jobDetails = ffrr.ForecastService.getJob(Opportunity.SObjectType); //Output the job details System.debug('jobDetails.errorMessage:' + jobDetails.ErrorMessage); System.debug('jobDetails.groupName:' + jobDetails.GroupName); System.debug('jobDetails.lastDataCreation:' + jobDetails.LastCreatedTime); System.debug('jobDetails.progressPercent:' + jobDetails.ProgressPercent); System.debug('jobDetails.status:' + jobDetails.Status); ffrr.ForecastService.Jobglobal with sharing class Job A Job object represents the state of a Generate Forecasts Batch Apex Job. Properties
ffrr.ForecastService.Forecastglobal with sharing class Forecast extends ViewService.Reference Contains the required details of a forecast record. See other constructors of this class in the Apex Classes under ffrr.ForecastService within Salesforce. See the Salesforce help for more information. This class extends ffrr.ViewService.Reference Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Create the forecast, source record and year reference data that we'll need //Create the reference to the forecast ffrr.ViewService.Reference sampleForecast = new ffrr.ViewService.Reference(); sampleForecast.Id = 'a1ga00000111sg6'; sampleForecast.Name = 'My Forecast'; //Create the reference to the source record ffrr.ViewService.Reference sampleRecord = new ffrr.ViewService.Reference(); sampleRecord.Id = 'a0ba00000512cc6'; sampleRecord.Name = 'My Record'; //Create a reference to the year ffrr.ViewService.Reference sampleYear = new ffrr.ViewService.Reference(); sampleYear.Id = 'a0sa00000011op1'; sampleYear.Name = 'My Project'; //Create the Forecast ffrr.ForecastService.Forecast fSample = new ffrr.ForecastService.Forecast(); //Populate the fields specific to the ffrr.ForecastService.Forecast fSample.Id = sampleForecast.Id; fSample.name = sampleForecast.Name; fSample.record = sampleRecord; fSample.year = sampleYear; fSample.version = 1; fSample.locked = false; fSample.description = 'My Description'; fSample.category = 'Best'; fSample.totalForecast = 1000000.00; Properties
Methods
Forecastglobal Forecast() Forecastglobal Forecast(ffrr.ViewService.Reference forecast, ffrr.ViewService.Reference record, ffrr.ViewService.Reference year, Boolean locked, String description, String category, Integer version, Decimal totalForecast) ffrr.ForecastService.ForecastLineglobal with sharing class ForecastLine implements Comparable Contains the required details for the forecast line. See other constructors of this class in the Apex Classes under ffrr.ForecastService within Salesforce. See the Salesforce help for more information. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Create the forecast, source record, account template, period line, parent/item reference data that we'll need //Create the fororecast ffrr.ForecastService.Forecast sampleForecast = new ffrr.ForecastService.Forecast(); sampleForecast.Id = 'a0ba00000512cc6'; sampleForecast.Name = 'My Forecast'; //Create the reference to the source record ffrr.ViewService.Reference sampleRecord = new ffrr.ViewService.Reference(); sampleRecord.Id = 'a0sa00000011op1'; sampleRecord.Name = 'My Record'; //Create the reference to the account ffrr.ViewService.Reference sampleAccount = new ffrr.ViewService.Reference(); sampleAccount.Id = 'a0sa00000011ac1'; sampleAccount.Name = 'My Account'; //Create the template ffrr.CalculationService.Template sampleTemplate = new ffrr.CalculationService.Template(); sampleTemplate.Id = 'a0va00000059tb8'; sampleTemplate.Name = 'My Template'; //Create the period line ffrr.ForecastService.PeriodLine samplePeriodLine = new ffrr.ForecastService.PeriodLine(); samplePeriodLine.Id = 'a0va00000059pl5'; samplePeriodLine.Name = 'My Period Line'; //Create the parent/item references ffrr.ViewService.Reference projectReference = new ffrr.ViewService.Reference(); projectReference.Id = 'a0sa00000011op1'; projectReference.Name = 'My Project'; ffrr.ViewService.Reference milestoneReference = new ffrr.ViewService.Reference(); milestoneReference.Id = 'a0ga00000026abx'; milestoneReference.Name = 'My Milestone'; ffrr.ViewService.Reference timecardReference = new ffrr.ViewService.Reference(); timecardReference.Id = 'a0va00000059tb8'; timecardReference.Name = 'My TimeCard'; //Create the ForecastLine ffrr.ForecastService.ForecastLine flSample = new ffrr.ForecastService.ForecastLine( new List<ffrr.ForecastService.Forecast>{sampleForecast}, sampleRecord, sampleRecord.Id, sampleTemplate, sampleAccount, 1000000.00, 2000000.00, ffrr.CalculationService.LineType.DETAIL, new List<ffrr.ViewService.Reference>{projectReference, milestoneReference, timecardReference}, new List<ffrr.ForecastService.PeriodLine>{samplePeriodLine} ); Properties
Methods
ForecastLineglobal ForecastLine(List<ffrr.ForecastService.Forecast> forecasts, ffrr.ViewService.Reference record, ffrr.CalculationService.Template template, ffrr.ViewService.Reference account, Decimal totalRevenue, Decimal totalForecast, ffrr.CalculationService.LineType lineType, List<ffrr.ViewService.Reference> parentPath, List<ffrr.ForecastService.PeriodLine> periodLines) ForecastLineglobal ForecastLine(List<ffrr.ForecastService.Forecast> forecasts, ffrr.ViewService.Reference record, Id linkRecordId, ffrr.CalculationService.Template template, ffrr.ViewService.Reference account, Decimal totalRevenue, Decimal totalForecast, ffrr.CalculationService.LineType lineType, List<ffrr.ViewService.Reference> parentPath, List<ffrr.ForecastService.PeriodLine> periodLines) ffrr.ForecastService.PeriodLineglobal with sharing class PeriodLine extends ViewService.Reference Contains period information for the associated forecast line record. This class extends ffrr.ViewService.Reference Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Create the year reference data that we'll need ffrr.ViewService.Reference sampleYear = new ffrr.ViewService.Reference(); sampleYear.Id = 'a1ga00000111sg6'; sampleYear.Name = '2014'; //Create the period line ffrr.ForecastService.PeriodLine plSample = new ffrr.ForecastService.PeriodLine(); //Populate the fields specific to ffrr.ForecastService.PeriodLine plSample.Id = 'a1ga00000111pl1'; plSample.Name = '0001/2014'; plSample.percentage = 10.00; plSample.value = 1000000.00; plSample.year = sampleYear; Properties
Methods
PeriodLineglobal PeriodLine() PeriodLineglobal PeriodLine(Id id, String name, Id forecast, Id forecastLine, Decimal percentage, Decimal value, ffrr.ViewService.Reference year) |