• Tamika King 5
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
Hello i'm trying to transfer all contributions from contribution object over to my plans object. I'm able to transfer everything else except for the contributions. I haven't received an error but not sure why they don't come over. Please see my code below and my attachment.


//Query plans from last year that have not been created for facilities in new year (to prevent duplicates).
List<Plan__c> plansthisYear = [
    SELECT Approved_Amount__c,Donation_Year__c,Facility__c,Id,Name,Plan_Status__c,Proposed_amount__c
    FROM Plan__c
    WHERE Donation_Year__c = :newYear
    ];

//Placeholder for all new contributions
List<Contribution__c> contributionList = new List<Contribution__c>();

//Loop through all new plans.
for (Plan__c p : plansthisYear) {

    String myId = p.Name;
 //get contributions for this plan
 List<Contribution__c> contributionsFromLastYear = [
 SELECT Amount__c,Community_Organization__c,Contribution_Status__c,Name,Project_Title__c FROM Contribution__c where Plan__c = :myId ];
 
 //Loop through all contributions from last year for this plan
 for(Contribution__c cont : contributionsFromLastYear ){

 //add the values to a new contribution
 Contribution__c contributions = new Contribution__c();
 contributions.Previous_Amount__c = cont.Amount__c;
 contributions.Contribution_Status__c =  cont.Contribution_Status__c;
 contributions.Community_Organization__c = cont.Community_Organization__c;
 contributions.Project_Title__c = cont.Project_Title__c;
 contributions.Plan__c =  myId; 
       
 contributionList.add(contributions);
 } 


insert contributionList;

}User-added image
/{!Plan__c.Name}/e?clone=1&retURL=%2F{!Plan__c.Name}&{!User.Id }&{!Plan__c.Donation_Year__c}&{!Plan__c.Facility__c}&{!Plan__c.Plan_Status__c}&{!Plan__c.Approved_Amount__c}&{!Plan__c.Proposed_amount__c}
 
I've even tried removing the field names and using there id instead but still no luck
 
/{00B46000002vEz2}/e?clone=1&retURL=/{00B46000002vEz2} &cloneli=1
&00N46000006jQ7w=
&00N46000006jPuW=
&00N46000006l5Or=
&00N4600000B6l9n=
&00N4600000B6l9d=
 
Please advise if you see anything wrong or if this is something that can be done in salesforce.
Hello i'm trying to transfer all contributions from contribution object over to my plans object. I'm able to transfer everything else except for the contributions. I haven't received an error but not sure why they don't come over. Please see my code below and my attachment.


//Query plans from last year that have not been created for facilities in new year (to prevent duplicates).
List<Plan__c> plansthisYear = [
    SELECT Approved_Amount__c,Donation_Year__c,Facility__c,Id,Name,Plan_Status__c,Proposed_amount__c
    FROM Plan__c
    WHERE Donation_Year__c = :newYear
    ];

//Placeholder for all new contributions
List<Contribution__c> contributionList = new List<Contribution__c>();

//Loop through all new plans.
for (Plan__c p : plansthisYear) {

    String myId = p.Name;
 //get contributions for this plan
 List<Contribution__c> contributionsFromLastYear = [
 SELECT Amount__c,Community_Organization__c,Contribution_Status__c,Name,Project_Title__c FROM Contribution__c where Plan__c = :myId ];
 
 //Loop through all contributions from last year for this plan
 for(Contribution__c cont : contributionsFromLastYear ){

 //add the values to a new contribution
 Contribution__c contributions = new Contribution__c();
 contributions.Previous_Amount__c = cont.Amount__c;
 contributions.Contribution_Status__c =  cont.Contribution_Status__c;
 contributions.Community_Organization__c = cont.Community_Organization__c;
 contributions.Project_Title__c = cont.Project_Title__c;
 contributions.Plan__c =  myId; 
       
 contributionList.add(contributions);
 } 


insert contributionList;

}User-added image
/{!Plan__c.Name}/e?clone=1&retURL=%2F{!Plan__c.Name}&{!User.Id }&{!Plan__c.Donation_Year__c}&{!Plan__c.Facility__c}&{!Plan__c.Plan_Status__c}&{!Plan__c.Approved_Amount__c}&{!Plan__c.Proposed_amount__c}
 
I've even tried removing the field names and using there id instead but still no luck
 
/{00B46000002vEz2}/e?clone=1&retURL=/{00B46000002vEz2} &cloneli=1
&00N46000006jQ7w=
&00N46000006jPuW=
&00N46000006l5Or=
&00N4600000B6l9n=
&00N4600000B6l9d=
 
Please advise if you see anything wrong or if this is something that can be done in salesforce.