• ranadheer reddy chaduvu
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 2
    Replies
trigger preventingdeletion on Apple__c (before delete) {

  for(Apple__C a:[select id,name,(select id from Orange__r ) from Apple__C where id in:Trigger.oldmap.keyset()]){
   if(a.Orange__r!=null&&a.Orange__r.size()>0){
    Apple__c actualRecord = Trigger.oldMap.get(a.Id);
   actualRecord.adderror('dont delete');
   }
   }

}



The above trigger is to prevent the parentobjectrecord from deletion if there is any child exists ...Here my parent object is Apple__C,and my child object is Orange__C,,help me ..thanks
Am trying to Access the mule with salesforce ..at the global elements ..after giving username,password and security token am trying for Test Connection  then the result is successful...but when trying to  "OK " its showing below error and unable to ok it

Error is :Retrieve list of object types failed
Reason:Unspecified connection error :java.lang.runtimeexception.sforce.connectionException..failed to send request to //ap1.salesforce.com----------
am trying to access mule with salesforce ...there i gave my credentials but when i tryinbg test connection anm getting this error is fail to send request to https://login.salesforce.com/services/Soap/u/28.0..what is meant by that

I have a trigger that prevents deletion of parent record if child exists ...here my parent object name is Apple__c......,my child object api name is Orange__c....sohere i wrote a trigger on parent object

trigger preventingdeletion on Apple__c (before delete) {

  for(Apple__C a:[select id,name,(select id from Orange__r ) from Apple__C where id in:Trigger.oldmap.keyset()]){
   if(a.Orange__r!=null&&a.Orange__r.size()>0){
   a.adderror('dont delete');
   }
   }

}



The above one is my trigger .....here the problem is trigger saved but its not showing the desired validation error message 

its showing the below error while deleteing the parent record its showing below error ....but my error message in trigger is "dont delete"


There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger preventingdeletion caused an unexpected exception, contact your administrator: preventingdeletion: execution of BeforeDelete caused by: System.FinalException: SObject row does not allow errors: Trigger.preventingdeletion: line 5, column 1".


how to solve this thanks.





I have 2 objects 1 is Trig1__c,second one s Trig2__c......in Trig1__C i have a numberfield called No_of_Trig2__c(Numberfield)....so here what i need is if i enter the 10 in No_of_Trig2__c then 10 records should be created autometically in Trig2__c,......so here is my trrigger

trigger Cretaingrecontrig2 on Trig1__c (after insert) {
  List<Trig2__c>Listtri=New List<Trig2__C>();

  for(Trig1__c tr:Trigger.new){
        if(Trig1__c.No_of_Trig2__c!=null){
        for(integer i=0;i<Trig1__C.No_of_Trig2__c;i++){
            Trig2__c tri=New List Trig2__c();
            tri.id=tr.id;
            tri.Name=tr.Name;
        Listtri.add(tri);
  }
  if(!Listtri.Isempty()){
  insert Listtri;
  }
  }
  }
  }



so here the trigger is saved fine ...but the problem is while saving the record am getting below error

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Cretaingrecontrig2 caused an unexpected exception, contact your administrator: Cretaingrecontrig2: execution of AfterInsert caused by: System.TypeException: Invalid integer: common.apex.runtime.impl.ApexFieldToken@7bce7881: Trigger.Cretaingrecontrig2: line 6, column 1



what may be the problem

I have 2 objects 1 is Trig1__c,second one s Trig2__c......in Trig1__C i have a numberfield called No_of_Trig2__c(Numberfield)....so here what i need is if i enter the 10 in No_of_Trig2__c then 10 records should be created autometically in Trig2__c,......so here is my trrigger

trigger Cretaingrecontrig2 on Trig1__c (after insert) {
  List<Trig2__c>Listtri=New List<Trig2__C>();

  for(Trig1__c tr:Trigger.new){
        if(Trig1__c.No_of_Trig2__c!=null){
        for(integer i=0;i<Trig1__C.No_of_Trig2__c;i++){
            Trig2__c tri=New List Trig2__c();
            tri.id=tr.id;
            tri.Name=tr.Name;
        Listtri.add(tri);
  }
  if(!Listtri.Isempty()){
  insert Listtri;
  }
  }
  }
  }



so here the trigger is saved fine ...but the problem is while saving the record am getting below error

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Cretaingrecontrig2 caused an unexpected exception, contact your administrator: Cretaingrecontrig2: execution of AfterInsert caused by: System.TypeException: Invalid integer: common.apex.runtime.impl.ApexFieldToken@7bce7881: Trigger.Cretaingrecontrig2: line 6, column 1



what may be the problem

am trying to access mule with salesforce ...there i gave my credentials but when i tryinbg test connection anm getting this error is fail to send request to https://login.salesforce.com/services/Soap/u/28.0..what is meant by that

I have 2 objects 1 is Trig1__c,second one s Trig2__c......in Trig1__C i have a numberfield called No_of_Trig2__c(Numberfield)....so here what i need is if i enter the 10 in No_of_Trig2__c then 10 records should be created autometically in Trig2__c,......so here is my trrigger

trigger Cretaingrecontrig2 on Trig1__c (after insert) {
  List<Trig2__c>Listtri=New List<Trig2__C>();

  for(Trig1__c tr:Trigger.new){
        if(Trig1__c.No_of_Trig2__c!=null){
        for(integer i=0;i<Trig1__C.No_of_Trig2__c;i++){
            Trig2__c tri=New List Trig2__c();
            tri.id=tr.id;
            tri.Name=tr.Name;
        Listtri.add(tri);
  }
  if(!Listtri.Isempty()){
  insert Listtri;
  }
  }
  }
  }



so here the trigger is saved fine ...but the problem is while saving the record am getting below error

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Cretaingrecontrig2 caused an unexpected exception, contact your administrator: Cretaingrecontrig2: execution of AfterInsert caused by: System.TypeException: Invalid integer: common.apex.runtime.impl.ApexFieldToken@7bce7881: Trigger.Cretaingrecontrig2: line 6, column 1



what may be the problem