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
kk_mkk_m 

First exception on row 0; first error: ENTITY_IS_DELETED, entity is deleted: []s

Hi All,

 

I wrote two class One is Create envelop it is webservice for restful (POST) sending data to third party  application

2nd one is for controller extension for catch that response display it on visualforce page.

 

I am trying to write a test class for the controller extension but i got this error

 

 

System.DmlException: Insert failed. First exception on row 0; first error: ENTITY_IS_DELETED, entity is deleted: []

 

Class.Test_YesMailExtention.testYesMailExtention: line 23, column 1

 

 

my class is

 

 

public class YesMailExtention {
    private final Yes_Mail_Master__c master { get ; set; }
    ApexPages.StandardController controller{ get; set ; }
    public String ActiveTab {get; set;} { ActiveTab = '1';}
    public string campaignId { get; set ; }
    public string strMsg { get ; set ; }  
    //public string Existedlist { get; set; }
    public YesMailExtention (ApexPages.StandardController controller) {
        
        campaignId= apexpages.currentpage().getparameters().get('cid');
        
                 
              if ( campaignId <> null) {
                  
                      campaign CampaignRow=[select Id,Name, Campaign_Members__c from campaign where id = '70190000000LJbr'];
                      
                      strMsg = 'Total Campaign Members add to this list is '+ CampaignRow.campaign_members__c ;
                      
                      this.controller = controller;
                      
                      this.master = (Yes_Mail_Master__c)controller.getRecord();
                      
                      this.master.Campaign__c = CampaignId;
           
          } else {

            
                    this.controller = controller;
                    
                    this.master = (Yes_Mail_Master__c)controller.getRecord();
        }
    }
    
      public PageReference nextTab(){
     // this.ActiveTab = 'Content'; 
      this.ActiveTab = String.valueOf(Integer.valueOf(ActiveTab)+1); 
      return null;
     }
     
    public PageReference saveMaster() {
      
       String mmid = CreateMasterEnvelope.postEnvelope(master);
       system.debug('Create envop mmid==========='+ mmid);
       master.MMID__c = mmid;
       //upsert master;
       controller.save();
       PageReference viewPage = this.controller.view();
       viewPage.setRedirect(true);
       return viewPage ;
     }



my testclass code



@isTest
Private class Test_YesMailExtention {

static testMethod void testYesMailExtention() {

//PageReference pageRef = Page.yesmailsend3;
PageReference pageRef =new PageReference('/apex/yesmailsend3?cid=70190000000EBYz');
Test.setCurrentPageReference(pageRef);

Yes_Mail_Master__c lst_yes = new Yes_Mail_Master__c (
       Name='pk_test_1001',
       Description__c='pk_test_1001',
       Subject__c='pk_test_1001',
       Content__c='pk_test_1001',
       Friendly_From__c='pk_test_1001',
       From_Domain__c='email@division1.wstest.com',
       //mmid__c = '123456',
       Campaign__c='70190000000EC3u',
       Delivery_Type__c='Auto-Detect delivery',
       Encoding__c= 'Any Country (UTF-8)',
       Division__c='DivisionOne');
         
        insert lst_yes;
      
       ApexPages.StandardController sc = new ApexPages.standardController(lst_yes);
        YesMailExtention myPageCon = new YesMailExtention (sc);
        
          
        myPageCon.campaignId ='70190000000EC3u';
         myPageCon.strMsg='Total campaign Members is';
          myPageCon.campaignId ='';
        myPageCon.ActiveTab ='1';
   
        ApexPages.StandardController controller=sc;
            myPageCon.controller = sc ;
            myPageCon.SetController(sc);
      
        
        myPageCon.saveMaster();
      
        }
         
        }




can any one can solve this
thanks in advance





 

 





jd123jd123

Hi

 

 

Yes_Mail_Master__c lst_yes = new Yes_Mail_Master__c (
Name='pk_test_1001',
Description__c='pk_test_1001',
Subject__c='pk_test_1001',
Content__c='pk_test_1001',
Friendly_From__c='pk_test_1001',
From_Domain__c='email@division1.wstest.com',
//mmid__c = '123456',
Campaign__c='70190000000EC3u',
Delivery_Type__c='Auto-Detect delivery',
Encoding__c= 'Any Country (UTF-8)',
Division__c='DivisionOne');

insert lst_yes;

 

you are giving Campaign id i think this record is alredy deleted. You should not hardcode just insert Campaign.

then you can use that id.

 

example 

 

       Campaign c=new Capaign (you can give);

 

insert c;

 

like Campaign__c=c.id;

 

 

karnakarna

Thnak you so much for help me to solve ....

jd123jd123

please mark it accept as a solution