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
Karthik TathiReddyKarthik TathiReddy 

Should not delete records from the object if I delete them from the related list...

public with sharing class TitleListModified { 
        public Program__c Program;
        public List<Wrapper> wraplist{get;set;}
        public TitleListModified(ApexPages.StandardController controller) { 
        program = (Program__c) Controller.getRecord(); 
        wraplist = new List<Wrapper>(); 
        for(Title__c t1 : [SELECT id,name,Program__c FROM Title__c where Program__c != :program.Id]){ 

	    wraplist.add( new wrapper(t1)); 


    public class Wrapper{ 

	public Boolean Selected{get;set;} 

	public title__c title{get;set;} 

			public wrapper(Title__c ti){ 

				title = ti; 

        public PageReference addTitle(){ 

		List<Title__c> newTitle = new List<Title__c>(); 

		for(Wrapper wrap :WrapList){ 


				wrap.title.Program__c = program.Id; 




		update newtitle;	 

		PageReference programPage = new ApexPages.StandardController(program).view(); 		


             return programPage; 



*************VF Page***************

<apex:page StandardController="Program__c" extensions="TitleListModified">
<apex:form >
  <apex:pageBlock >
  <apex:pageBlockButtons >
  <apex:commandButton action="{!addTitle}" value="Add Title" />
  <apex:pageBlockSection >
  <apex:pageBlockTable value="{!WrapList}" var="w">
  <apex:column headerValue="Action">
  <apex:inputCheckbox value="{!w.Selected}"/>
  <apex:column value="{!}"/>


The above page and controller is to add records from the child object "Title" to the related list of "Program" object record. For this process I created a Button for Title__c object and added that button to the program related list. To the button I gave this page url. 


Now the thing is when I delete any record from the related list which added from the title object throught the button those records are being deleted from the title object also. What logic could over come this? Please help me out...