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

Action Plans app - help with test class for trigger



Short version:

Is there a way for my test class to utilize the code in the "ActionPlansUtilitiesTest" class in an EE org running the managed version of Action Plans?


Long version:

Our company is utilizing the managed version of Action Plans.  I've written a trigger to give us more flexibility with the app, but I'm having trouble getting the test class to pass testing.


Initially, I made the trigger and test class based on the unmanaged version, but we want to be able to upgrade the app if there are new releases, so I altered the object and field names in my trigger and test class to work with the managed version.


In my test class, I pasted a lot of code from the "ActionPlansUtilitiesTest" class...and this worked with the unmanaged package.  But with the managed version, my code coverage drops dramatically.  It looks a method (within the code I pasted) is unable to make calls to the "ActionPlansUtilities" class.


Classes and methods are pretty new to me, so maybe (hopefully) there's something simple I'm missing.  Any help would be greatly appreciated though.


I didn't include code here b/c it's quite a bit, but I'd be happy to provide.




Best Answer chosen by Admin (Salesforce Developers) 

Hi Aaron,


Unfortunately, the managed package doesn't expose the test utility class in a way that's accessible when it's a managed package. 





All Answers


Hi Aaron,


Unfortunately, the managed package doesn't expose the test utility class in a way that's accessible when it's a managed package. 





This was selected as the best answer

Thanks Reid!  I can stop banging my head against the wall now  :)



Meghana yarlagaddaMeghana yarlagadda

HI Asron,

Any luck with writing a test class for Action plans?

I am facing the same issue.

I am getting Internal Salesforce Error: 1611540542-162816 (1198250675) (1198250675) for the following test class on Action plan

public class ActionPlan_Trigger_Handler_Test {
    public static testmethod void test1(){
         Lead LeadRec = TestDataFactory.insertLead('test', 'lead', 'New','','test','test','New York','100015','4046782345');
        LeadRec.MobilePhone = '4046782345';
        insert LeadRec; 
        ActionPlanTemplate actplantemp = new ActionPlanTemplate();
        actplantemp.Name = 'AccountActionPlan';
        actplantemp.TargetEntityType = 'Lead';
        insert actplantemp; 
        integer sn = [select count() from ActionPlanTemplate];
        system.assertEquals(1, sn);
           ActionPlanTemplate APT = [select id from ActionPlanTemplate limit 1];
        // once an ActionPlanTemplate is inserted system automatically creates ActionPlanTemplateVersion        
        ActionPlanTemplateVersion acttempvers = [select id from ActionPlanTemplateVersion limit 1];
        //now add a task
        ActionPlanTemplateItem APTI = new ActionPlanTemplateItem();
        APTI.Name = 'Unique';
        APTI.ActionPlanTemplateVersionId = acttempvers.Id;
        APTI.IsActive = true;
        APTI.IsRequired = false;
        APTI.ItemEntityType = 'Task';
        insert APTI;       
        update acttempvers;
        ActionPlan AP = new ActionPlan();
        AP.ActionPlanState='Not Started';
       insert AP;

João AlmeidaJoão Almeida

Hi agaber and Meghana,

you have to also create templateItemValues. Check the following:

ActionPlanTemplate template = new ActionPlanTemplate();
        template.Name = 'Test Template 1';
        template.ActionPlanType = 'Industries';
        template.TargetEntityType = 'pmdm__ProgramEngagement__c';
        template.UniqueName = 'TEST_X1_de6b5f14_64ff_11ed_8a0a_255fb2da7046';

        insert template;

        ActionPlanTemplateVersion templateVersion = [SELECT Id, ActionPlanTemplateId, Name, Status, Version FROM ActionPlanTemplateVersion WHERE ActionPlanTemplateId =:template.Id];
        ActionPlanTemplateItem templateItem1 = new ActionPlanTemplateItem();
        templateItem1.Name = 'Test Action Task 1';
        templateItem1.ItemEntityType = 'Task';
        templateItem1.UniqueName = 'Test1_1_448a9990_6501_11ed_8a0a_213b76b4dbca';
        templateItem1.ActionPlanTemplateVersionId = templateVersion.Id;

        insert templateItem1;

        ActionPlanTemplateItemValue templateItem1value1 = new ActionPlanTemplateItemValue();
        templateItem1value1.ActionPlanTemplateItemId = templateItem1.Id;
        templateItem1value1.ItemEntityFieldName = 'Task.Subject';
        templateItem1value1.Name = 'templateItem1value1';
        templateItem1value1.ValueLiteral = 'Test Action Task 1';
        insert templateItem1value1;

        ActionPlanTemplateItemValue templateItem1value2 = new ActionPlanTemplateItemValue();
        templateItem1value2.ActionPlanTemplateItemId = templateItem1.Id;
        templateItem1value2.ItemEntityFieldName = 'Task.Priority';
        templateItem1value2.Name = 'templateItem1value2';
        templateItem1value2.ValueLiteral = 'Normal';
        insert templateItem1value2;

        ActionPlanTemplateItemValue templateItem1value3 = new ActionPlanTemplateItemValue();
        templateItem1value3.ActionPlanTemplateItemId = templateItem1.Id;
        templateItem1value3.ItemEntityFieldName = 'Task.ActivityDate';
        templateItem1value3.Name = 'templateItem1value3';
        templateItem1value3.ValueFormula = 'StartDate + 10';
        insert templateItem1value3;

        ActionPlanTemplateItem templateItem2 = new ActionPlanTemplateItem();
        templateItem2.Name = 'Test Action Task 2';
        templateItem2.ItemEntityType = 'Task';
        templateItem2.UniqueName = 'Test2_1_448a9990_6501_11ed_8a0a_213b76b4dbca';
        templateItem2.ActionPlanTemplateVersionId = templateVersion.Id;

        insert templateItem2;
        ActionPlanTemplateItemValue templateItem2value1 = new ActionPlanTemplateItemValue();
        templateItem2value1.ActionPlanTemplateItemId = templateItem2.Id;
        templateItem2value1.ItemEntityFieldName = 'Task.Subject';
        templateItem2value1.Name = 'templateItem2value1';
        templateItem2value1.ValueLiteral = 'Test Action Task Value 2';
        insert templateItem2value1;

        ActionPlanTemplateItemValue templateItem2value2 = new ActionPlanTemplateItemValue();
        templateItem2value2.ActionPlanTemplateItemId = templateItem2.Id;
        templateItem2value2.ItemEntityFieldName = 'Task.Priority';
        templateItem2value2.Name = 'templateItem2value2';
        templateItem2value2.ValueLiteral = 'Normal';
        insert templateItem2value2;

        ActionPlanTemplateItemValue templateItem2value3 = new ActionPlanTemplateItemValue();
        templateItem2value3.ActionPlanTemplateItemId = templateItem2.Id;
        templateItem2value3.ItemEntityFieldName = 'Task.ActivityDate';
        templateItem2value3.Name = 'templateItem2value3';
        templateItem2value3.ValueFormula = 'StartDate + 10';
        insert templateItem2value3;

        templateVersion.Status = 'Final';
        update templateVersion;