• Alex Groag
  • NEWBIE
  • 15 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi - I'm trying to write a trigger that will update Recurring Donations when a related opportunity is created or edited.  We need to map encrypted credit card fields on the opportunity to encrypted fields on the Recurring Donation.  I'm a novice when it comes to trigger/apex and have been trying to repurpose from other people's post but I'm not having any luck.  Below is the starting point using test checkbox fields.  If we can get this to work then I can modify it for more fields.  In the developer console I'm not getting any errors - but when I edit an Opportunity the Recurring Donation is not updating. 

Here is the code I was using. 

trigger TestRD1 on Opportunity (after insert, after update) {
    List<Opportunity> opps = new List<Opportunity>(); 
    List<npe03__Recurring_Donation__c> RDs = new List<npe03__Recurring_Donation__c>();
    
    
    for (Opportunity opp : Trigger.new) {
        opps = [SELECT Id, Test_Checkbox__c FROM Opportunity LIMIT 1];
        RDs = [SELECT Id, Test_Checkbox__c FROM npe03__Recurring_Donation__c WHERE Id =: opp.npe03__Recurring_Donation__c];
    }

    for( Opportunity O : opps) {
    for (npe03__Recurring_Donation__c RD: RDs){
        if(O.Test_Checkbox__c== true ){
            RD.Test_Checkbox__c=true;
        }
            
    }
        update RDs;
    }} 
We have 3 Javascript buttons which change the record type and reassigns the case to a queue. Here is an example 

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 

var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 
caseObj.RecordTypeId = '012400000009FQA';
caseObj.OwnerId = '00G40000001dp2s'

var result = sforce.connection.update([caseObj]);

if (result[0].success =='false') {
alert (result[0].errors.message);
} else {
location.reload(true);
}

I am looking for detailed step-by-step instructions/tutorial to convert this to Lightning Component. 

Thank you in advance. 
Hi - I'm trying to write a trigger that will update Recurring Donations when a related opportunity is created or edited.  We need to map encrypted credit card fields on the opportunity to encrypted fields on the Recurring Donation.  I'm a novice when it comes to trigger/apex and have been trying to repurpose from other people's post but I'm not having any luck.  Below is the starting point using test checkbox fields.  If we can get this to work then I can modify it for more fields.  In the developer console I'm not getting any errors - but when I edit an Opportunity the Recurring Donation is not updating. 

Here is the code I was using. 

trigger TestRD1 on Opportunity (after insert, after update) {
    List<Opportunity> opps = new List<Opportunity>(); 
    List<npe03__Recurring_Donation__c> RDs = new List<npe03__Recurring_Donation__c>();
    
    
    for (Opportunity opp : Trigger.new) {
        opps = [SELECT Id, Test_Checkbox__c FROM Opportunity LIMIT 1];
        RDs = [SELECT Id, Test_Checkbox__c FROM npe03__Recurring_Donation__c WHERE Id =: opp.npe03__Recurring_Donation__c];
    }

    for( Opportunity O : opps) {
    for (npe03__Recurring_Donation__c RD: RDs){
        if(O.Test_Checkbox__c== true ){
            RD.Test_Checkbox__c=true;
        }
            
    }
        update RDs;
    }} 

Hi, I am wondering if there is a way to hide opportunities or accounts or other objects for a user with a specific profile or role based on field values on the particular object?

 

Thanks / Niklas