Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7625265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:10:09+00:00 2026-05-31T05:10:09+00:00

I have a trigger which initiates an approval process when certain criteria are met:

  • 0

I have a trigger which initiates an approval process when certain criteria are met:

trigger AddendumAfterIHMS on Addendum__c (after update) {

  for (integer i = 0; i<Trigger.new.size(); i++){

    if(Trigger.new[i].RecordTypeId != '012V0000000CkQA'){

        if(Trigger.new[i].From_IHMS__c != null && Trigger.old[i].From_IHMS__c == null){

            ID addendumId = Trigger.new[i].Id;

            // Start next approval process
            Approval.ProcessSubmitRequest request = new Approval.ProcessSubmitRequest();
            request.setObjectId(addendumId);
            Approval.ProcessResult requestResult = Approval.process(request);

        }
    }
  }
}

It works perfectly, but now i need to create a test class for it. I have created a class which brings the code up to 75% coverage, which is the minimum, but I’m picky and like to have 100% coverage on my code. The test class I have now gets stuck on the line request.setObjectId(addendumId); and doesn’t move past it. The error I receive is:

System.DmlException: Update failed. First exception on row 0 with id a0CV0000000B8cgMAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AddendumAfterIHMS: execution of AfterUpdate

Here is the test class that I have written so far, most of the class actually tests some other triggers, but the important line which is throwing the error is the very last line update addendumTierFeature;

@isTest
private class AddendumTest {

static testMethod void myUnitTest() {

    // Query Testing Account, will need ID changed before testing to place into production
    Account existingAccount = [SELECT Id FROM Account LIMIT 1];
    Model__c existingModel = [SELECT Id FROM Model__c WHERE Active__c = TRUE LIMIT 1];
    Pricebook2 existingPricebook = [SELECT Id,Name FROM Pricebook2 WHERE IsActive = TRUE LIMIT 1];
    List<Contact> existingContacts = [SELECT Id,Name FROM Contact LIMIT 2];

    Contact existingContactPrimary = existingContacts[0];
    Contact existingContactSecondary = existingContacts[1];

    Opportunity newOpportunity = new Opportunity(

        Name = 'New Opportunity',
        Account = existingAccount,
        CloseDate = Date.today(),
        Order_Proposed__c = Date.today(),
        StageName = 'Branch Visit - Not Responding',
        Opportunity_Follow_Up__c = 'Every 120 Days',
        LeadSource = 'Farm Lists',
        Source_Detail__c = 'FSBO',
        Model_Name__c = existingModel.Id,
        Processing_Fee__c = 100.50,
        Site_State__c = 'OR',
        base_Build_Zone__c = 'OR',
        Pricebook_from_Lead__c = existingPricebook.Name

    );

    insert newOpportunity;
    //system.assert(newOpportunity.Id != null);

    ID newOppId = newOpportunity.Id;

    OpportunityContactRole contactPrimary = new OpportunityContactRole(
        Role = 'Primary',
        IsPrimary = true,
        OpportunityId = newOppId,
        ContactId = existingContactPrimary.Id
    );

    OpportunityContactRole contactSecondary = new OpportunityContactRole(
        Role = 'Primary',
        IsPrimary = false,
        OpportunityId = newOppId,
        ContactId = existingContactPrimary.Id
    );

    insert contactPrimary;
    insert contactSecondary;

    newOpportunity.Name = 'Different - Updating';
    newOpportunity.Order_Accepted__c = Datetime.now();

    update newOpportunity;

    Addendum__c addendumCustomOption = new Addendum__c(
        RecordTypeId = '012V0000000CkQA', //Pre Priced Custom Option
        Opportunity__c = newOppId,
        Item_Pre_Priced_Description__c = 'a1eV00000004DNu',
        Reason__c = 'This is a reason',
        Item__c = 'This is an Item',
        Quantity__c = 1
    );

    Addendum__c addendumTierFeature = new Addendum__c(
        RecordTypeId = '012V0000000Cjks', //Tier Feature
        Opportunity__c = newOppId,
        Category__c = 'Countertops',
        Reason__c = 'This is a reason',
        Item__c = 'This is an Item',
        Quantity__c = 1
    );

    insert addendumCustomOption;
    insert addendumTierFeature;

    addendumCustomOption.Quantity__c = 2;
    addendumTierFeature.Quantity__c = 2;

    update addendumCustomOption;
    update addendumTierFeature;
    update newOpportunity;

    addendumTierFeature.To_IHMS__c = system.now();

    update addendumTierFeature;

    addendumTierFeature.From_IHMS__c = system.now();


    update addendumTierFeature;

  }
}

Any help on this matter would be greatly appreciated. I believe the problem is in the way I am testing the approval process start. Is there by chance a special testing function for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:10:10+00:00Added an answer on May 31, 2026 at 5:10 am

    After fiddling around for a little while I discovered that the error was actually tied into my approval process. I kept digging into the error logs until I got to the error: caused by: System.DmlException: Process failed. First exception on row 0; first error: MANAGER_NOT_DEFINED, Manager undefined.: []. This phrase indicates that there is no one defined for the next step in my approval process.

    When I created the opportunity, I did not set the owner and somehow this created an opportunity which had an owner without a manager. The addendum was also created without an owner/manager. So when I tried to launch the next approval process, there was no manager to send the approval to and an error was thrown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a trigger AFTER INSERT inside which I must update the value of
I have written an update trigger which works fine when i update only one
I have been trying to use an update trigger which checks for the title_id
hi i have created a trigger which i want to update a table field
I have within my Sql Server 2008 database a trigger which will run on
I have below trigger ALTER TRIGGER [dbo].[DeleteUserData] ON [dbo].[site_users] AFTER DELETE AS BEGIN SET
If I have a trigger before the update on a table, how can I
I have a trigger which deals with some data for logging purposes like so:
I have an Oracle trigger which is calling a stored procedure that has PRAGMA
I have a simple trigger which pulls data from the lead object and places

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.