• Andrew North
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies

Hi All

Does anyone happen to know of any tools that can be scheduled to automaically download the zip files produced by the Export Service and save them to a specific location?

Thank you

Hi all

I'm attempting to deploy a change within Salesforce but failing to do so as there is this one outstanding issue that appears when validating the deployment.

As an admin I'm struggling to understand what the issue is here. Could somebody kindly shed some light on whats causing the issue or help me understand what the apex classes are doing? My only 'fix' is to commment out the offending line of apex (marked in bold) but I dont want to introduce any new errors by doing so.

Thank you in advance.

 

Test

@isTest
private class BW_RevenueScheduleBatchTest{
        static testMethod void testBW_RevenueScheduleBatch(){
                Profile p;
                User u;
                Account parentAcc;

                Account acc;
                Opportunity opp;
                Profit_Centre_Split__c secondaryPcs;
                Framework__c fw;
                Sector_Head_Mappings__c sectorHeadCS;
                p = TestData.createProfile();

                u = TestData.createTestUser(p);
                                TestData.u=u;
                parentAcc=TestData.createAccount();
                sectorHeadCS = TestData.createSectorCustomSetting(u);

                acc = TestData.createAccount(parentAcc);
                fw =  TestData.createFrameWork(acc);
                opp = TestData.createOpportunity(acc.id,fw.id);
                opp.Legacy_Source_System__c='XYZ';
                update opp;
                secondaryPcs = TestData.createSecondaryProfitCentre(opp);

                    database.executeBatch(new BW_RevenueScheduleBatch());
        }
}
 
global class BW_RevenueScheduleBatch implements Database.Batchable<sObject> {
   
    global Database.QueryLocator start(Database.BatchableContext bc) {
            String query = 'select id,Contract_Length_Mths__c,Contract_start_date__c  from opportunity where Legacy_Source_System__c=\'XYZ\'';
            //String query = 'select id,Contract_Length_Mths__c,Contract_start_date__c   from opportunity where id=\'0069E00000BCdj3QAD\'';
            return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext bc, List<opportunity> scope) {
            list<Profit_Centre_Split__c > lstProfitCenterSplits = new list<Profit_Centre_Split__c >();


               for(opportunity opp: scope){

                for(Profit_Centre_Split__c pcs:[select id,Opportunity__c,Opportunity__r.Contract_Length_Mths__c  , PCAmount__c, Share__c, Profit_Centre__c, Revenue_Schedule_Type__c
                from Profit_Centre_Split__c
                where Opportunity__c =:opp.id]){

                        // BW_PCRevenueController ctrl = new BW_PCRevenueController();
                         List<Double> vals = new list<Double>();
                         system.debug('@@'+pcs.Opportunity__r.Contract_Length_Mths__c);
                         vals = RevenueDistributionHelper.getMonthlyPercentages('Flat', pcs.Opportunity__r.Contract_Length_Mths__c.intValue());  
                         Decimal totalAllocated = 0;
                         Integer i = 0;
                         List<Revenue_Schedule__c> schedules= new list<Revenue_Schedule__c>();
                         /*We check if there are schedules in system if yes we skip that record else we enter into logic at line 27*/
                         schedules=[select id from Revenue_Schedule__c  where Opportunity__c=:pcs.Opportunity__c];
                         if(schedules.isEmpty()){
                         schedules = createNewFlatSchedule(pcs.PCAmount__c, pcs.Id,opp);
                             for(Revenue_Schedule__c rs : schedules){
                                    rs.Opportunity__c=pcs.Opportunity__c;
    
                                    if(i == vals.size() - 1){
                                        rs.Amount__c = pcs.PCAmount__c - totalAllocated;                
                                    }
                                    else{
                                        rs.Amount__c = pcs.PCAmount__c * vals[i];
                                    }
                                    totalAllocated += rs.Amount__c;
                                    i++;
                                }
                              
                            if(!schedules.isEmpty()){
                               upsert schedules;
                            }
                      }
                     }
                     }
               
    }
    global void finish(Database.BatchableContext bc) {
    }
    global List<Revenue_Schedule__c> createNewFlatSchedule(Decimal amount, Id pcsId,opportunity opp){
        List<Revenue_Schedule__c> newSchedules = new List<Revenue_Schedule__c>();
        Integer scheduleamount;
        if(opp.Contract_Length_Mths__c!=null){
            scheduleamount= (amount / opp.Contract_Length_Mths__c).intValue();
            }
        decimal totalAllocated = 0;
        //selectedRevenueType = 'Flat';

        for(Integer i = 0; i < opp.Contract_Length_Mths__c ; i++){
            Revenue_Schedule__c schedule = new Revenue_Schedule__c();
            schedule.Schedule_Frequency__c = 'Monthly';
            schedule.Profit_Centre_Split__c = pcsId;
            schedule.Payment_Date__c = opp.Contract_start_date__c.addMonths(i);
            
            if(i == opp.Contract_Length_Mths__c - 1){
                schedule.Amount__c = amount - totalAllocated;
                totalAllocated += schedule.Amount__c;
            }
            else{
                schedule.Amount__c = scheduleAmount;
                totalAllocated += scheduleAmount;
            }
            
            newSchedules.add(schedule);
        }

        return newSchedules;
    }
}



Error:

Class name: BW_RevenueScheduleBatchTest

Method Name: testBW_RevenueScheduleBatch

System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityTrigger: execution of AfterUpdate caused by: System.AsyncException: Future method cannot be called from a future or batch method: SubscriberHelper.evaluateOpptyRulesFuture(Set<Id>) Trigger.OpportunityTrigger: line 29, column 1: []
Stack Trace: Class.BW_RevenueScheduleBatch.execute: line 44, column 1

Hey all

Hope you can help, I'm currently reviewing the Accounts that we hold within My Org and have found that we have almost 25k.

I'm planning on tidying this mess up.

At the moment, I've restricted the rights so that it's only myself and a colleague who can create new Accounts, this forces end users or ourselves to first search for an account to check if it exists, if not then we will create it on their behalf.

How would be best to approach this scenario?

I'm thinking to first delete any 'dead' accounts e.g. those that do not hold any information or linked objects such as Opp's, Frameworks, contacts etc.

Is there an option to filter all of the duplicate or similar Account names so that they can be merged?

If anyone has any ideas, documentation, best practices or advice then please point me in the right direction.

Thank you

Hi Guys, I really hope you can help

I'm attampting to push a change (2 apex classes) from my 'Config' sandbox to the production environment.

However, when i push my change I get 2 errors, as I'm not a Salesforce developer I'm having a hard time resolving these issues.

The Code is as follows

1)
@isTest
private class BW_RevenueScheduleBatchTest{
        static testMethod void testBW_RevenueScheduleBatch(){
                Profile p;
                User u;
                Account parentAcc;

                Account acc;
                Opportunity opp;
                Profit_Centre_Split__c secondaryPcs;
                Framework__c fw;
                Sector_Head_Mappings__c sectorHeadCS;
                p = TestData.createProfile();

                u = TestData.createTestUser(p);
                                TestData.u=u;
                parentAcc=TestData.createAccount();
                sectorHeadCS = TestData.createSectorCustomSetting(u);

                acc = TestData.createAccount(parentAcc);
                fw =  TestData.createFrameWork(acc);
                opp = TestData.createOpportunity(acc.id,fw.id);
                opp.Legacy_Source_System__c='Capsule';
                update opp;
                secondaryPcs = TestData.createSecondaryProfitCentre(opp);

                    database.executeBatch(new BW_RevenueScheduleBatch());
        }
}

 



2)
@isTest (seeAllData = true) 
public class HomePageReportControllerTest{ 

static testMethod void testHomePageReportcontroller(){         
TestData.createAll();          

System.runAs(TestData.u){  
//create an opp closing in the future...
Opportunity o = TestData.createOpportunity(TestData.acc.Id, TestData.fw.Id);            o.closeDate = system.today().addDays(5);
o.Contract_start_date__c = System.today().addDays(5);            o.Latest_status_and_next_steps__c = 'updated date';
update o;       

 PageReference pageRef = Page.MyRecentDashboard;           Test.setCurrentPage(pageRef);           
HomePageReportController hprc = new HomePageReportcontroller();           system.assert(hprc.pipelineReportId != null);           system.assert(hprc.revenueReportId != null);           system.assert(hprc.winlossReportId != null);                   
 }             
 } 
}



The errors I receive are below

1) System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityTrigger: execution of AfterUpdate caused by: System.AsyncException: Future method cannot be called from a future or batch method: SubscriberHelper.evaluateOpptyRulesFuture(Set<Id>) Trigger.OpportunityTrigger: line 29, column 1: []
Stack Trace: Class.BW_RevenueScheduleBatch.execute: line 44, column 1

2) System.QueryException: List has no rows for assignment to SObject
Stack Trace: Class.HomePageReportController.getReportId: line 18, column 1 Class.HomePageReportController.<init>: line 10, column 1 Class.HomePageReportControllerTest.testHomePageReportcontroller: line 17, column 1

If anyone could kindly advise or point me in the right direction of how this can be resolved I would be extremely grateful.

Thank you
Hi

We have a visualforce section on all of our Opportortunity page layouts.
This section shows a particular image depending on what has been selected within the stage field.
Below is a sample of the code that we have in place.
Is it possible to split it up so that depending on which Opportunity Record Type is selected different images can be displayed against each stage?

For example if record type = X and the stage is Closed Won then show image A
If record type = Y and the Stage is closed Won then show image B

Thank you
 
<apex:page standardController="Opportunity" showHeader="true" sidebar="true">

<div align="center">

></apex:image> <apex:image id="won" value="{!$Resource.stageWon}" height="60" rendered="{!Opportunity.stageName = 'Closed Won'}"

 ></apex:image> <apex:image id="lost" value="{!$Resource.stageLost}" height="60" rendered="{!Opportunity.stageName = 'Closed Lost'}" 

</div>

</apex:page>

 

Hi

We have a visualforce section on all of our Opportortunity page layouts.
This section shows a particular image depending on what has been selected within the stage field.

Below is a sample of the code that we have in place.
Is it possible to split it up so that depending on which Opportunity Record Type is selected different images can be displayed against each stage?

For example if record type = X and the stage is Closed Won then show image A

If record type = Y and the Stage is closed Won then show image B

Thank you

<apex:page standardController="Opportunity" showHeader="true" sidebar="true">

<div align="center">

></apex:image> <apex:image id="won" value="{!$Resource.stageWon}" height="60" rendered="{!Opportunity.stageName = 'Closed Won'}" ></apex:image> <apex:image id="lost" value="{!$Resource.stageLost}" height="60" rendered="{!Opportunity.stageName = 'Closed Lost'}" 

</div>

</apex:page>

Hi all

I'm attempting to deploy a change within Salesforce but failing to do so as there is this one outstanding issue that appears when validating the deployment.

As an admin I'm struggling to understand what the issue is here. Could somebody kindly shed some light on whats causing the issue or help me understand what the apex classes are doing? My only 'fix' is to commment out the offending line of apex (marked in bold) but I dont want to introduce any new errors by doing so.

Thank you in advance.

 

Test

@isTest
private class BW_RevenueScheduleBatchTest{
        static testMethod void testBW_RevenueScheduleBatch(){
                Profile p;
                User u;
                Account parentAcc;

                Account acc;
                Opportunity opp;
                Profit_Centre_Split__c secondaryPcs;
                Framework__c fw;
                Sector_Head_Mappings__c sectorHeadCS;
                p = TestData.createProfile();

                u = TestData.createTestUser(p);
                                TestData.u=u;
                parentAcc=TestData.createAccount();
                sectorHeadCS = TestData.createSectorCustomSetting(u);

                acc = TestData.createAccount(parentAcc);
                fw =  TestData.createFrameWork(acc);
                opp = TestData.createOpportunity(acc.id,fw.id);
                opp.Legacy_Source_System__c='XYZ';
                update opp;
                secondaryPcs = TestData.createSecondaryProfitCentre(opp);

                    database.executeBatch(new BW_RevenueScheduleBatch());
        }
}
 
global class BW_RevenueScheduleBatch implements Database.Batchable<sObject> {
   
    global Database.QueryLocator start(Database.BatchableContext bc) {
            String query = 'select id,Contract_Length_Mths__c,Contract_start_date__c  from opportunity where Legacy_Source_System__c=\'XYZ\'';
            //String query = 'select id,Contract_Length_Mths__c,Contract_start_date__c   from opportunity where id=\'0069E00000BCdj3QAD\'';
            return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext bc, List<opportunity> scope) {
            list<Profit_Centre_Split__c > lstProfitCenterSplits = new list<Profit_Centre_Split__c >();


               for(opportunity opp: scope){

                for(Profit_Centre_Split__c pcs:[select id,Opportunity__c,Opportunity__r.Contract_Length_Mths__c  , PCAmount__c, Share__c, Profit_Centre__c, Revenue_Schedule_Type__c
                from Profit_Centre_Split__c
                where Opportunity__c =:opp.id]){

                        // BW_PCRevenueController ctrl = new BW_PCRevenueController();
                         List<Double> vals = new list<Double>();
                         system.debug('@@'+pcs.Opportunity__r.Contract_Length_Mths__c);
                         vals = RevenueDistributionHelper.getMonthlyPercentages('Flat', pcs.Opportunity__r.Contract_Length_Mths__c.intValue());  
                         Decimal totalAllocated = 0;
                         Integer i = 0;
                         List<Revenue_Schedule__c> schedules= new list<Revenue_Schedule__c>();
                         /*We check if there are schedules in system if yes we skip that record else we enter into logic at line 27*/
                         schedules=[select id from Revenue_Schedule__c  where Opportunity__c=:pcs.Opportunity__c];
                         if(schedules.isEmpty()){
                         schedules = createNewFlatSchedule(pcs.PCAmount__c, pcs.Id,opp);
                             for(Revenue_Schedule__c rs : schedules){
                                    rs.Opportunity__c=pcs.Opportunity__c;
    
                                    if(i == vals.size() - 1){
                                        rs.Amount__c = pcs.PCAmount__c - totalAllocated;                
                                    }
                                    else{
                                        rs.Amount__c = pcs.PCAmount__c * vals[i];
                                    }
                                    totalAllocated += rs.Amount__c;
                                    i++;
                                }
                              
                            if(!schedules.isEmpty()){
                               upsert schedules;
                            }
                      }
                     }
                     }
               
    }
    global void finish(Database.BatchableContext bc) {
    }
    global List<Revenue_Schedule__c> createNewFlatSchedule(Decimal amount, Id pcsId,opportunity opp){
        List<Revenue_Schedule__c> newSchedules = new List<Revenue_Schedule__c>();
        Integer scheduleamount;
        if(opp.Contract_Length_Mths__c!=null){
            scheduleamount= (amount / opp.Contract_Length_Mths__c).intValue();
            }
        decimal totalAllocated = 0;
        //selectedRevenueType = 'Flat';

        for(Integer i = 0; i < opp.Contract_Length_Mths__c ; i++){
            Revenue_Schedule__c schedule = new Revenue_Schedule__c();
            schedule.Schedule_Frequency__c = 'Monthly';
            schedule.Profit_Centre_Split__c = pcsId;
            schedule.Payment_Date__c = opp.Contract_start_date__c.addMonths(i);
            
            if(i == opp.Contract_Length_Mths__c - 1){
                schedule.Amount__c = amount - totalAllocated;
                totalAllocated += schedule.Amount__c;
            }
            else{
                schedule.Amount__c = scheduleAmount;
                totalAllocated += scheduleAmount;
            }
            
            newSchedules.add(schedule);
        }

        return newSchedules;
    }
}



Error:

Class name: BW_RevenueScheduleBatchTest

Method Name: testBW_RevenueScheduleBatch

System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityTrigger: execution of AfterUpdate caused by: System.AsyncException: Future method cannot be called from a future or batch method: SubscriberHelper.evaluateOpptyRulesFuture(Set<Id>) Trigger.OpportunityTrigger: line 29, column 1: []
Stack Trace: Class.BW_RevenueScheduleBatch.execute: line 44, column 1

Hey all

Hope you can help, I'm currently reviewing the Accounts that we hold within My Org and have found that we have almost 25k.

I'm planning on tidying this mess up.

At the moment, I've restricted the rights so that it's only myself and a colleague who can create new Accounts, this forces end users or ourselves to first search for an account to check if it exists, if not then we will create it on their behalf.

How would be best to approach this scenario?

I'm thinking to first delete any 'dead' accounts e.g. those that do not hold any information or linked objects such as Opp's, Frameworks, contacts etc.

Is there an option to filter all of the duplicate or similar Account names so that they can be merged?

If anyone has any ideas, documentation, best practices or advice then please point me in the right direction.

Thank you

Hi

We have a visualforce section on all of our Opportortunity page layouts.
This section shows a particular image depending on what has been selected within the stage field.
Below is a sample of the code that we have in place.
Is it possible to split it up so that depending on which Opportunity Record Type is selected different images can be displayed against each stage?

For example if record type = X and the stage is Closed Won then show image A
If record type = Y and the Stage is closed Won then show image B

Thank you
 
<apex:page standardController="Opportunity" showHeader="true" sidebar="true">

<div align="center">

></apex:image> <apex:image id="won" value="{!$Resource.stageWon}" height="60" rendered="{!Opportunity.stageName = 'Closed Won'}"

 ></apex:image> <apex:image id="lost" value="{!$Resource.stageLost}" height="60" rendered="{!Opportunity.stageName = 'Closed Lost'}" 

</div>

</apex:page>