• XIO
  • NEWBIE
  • 130 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 30
    Questions
  • 32
    Replies
Hello,

We have a visualforce page called Safesend Returns in a Lightning tab. When we hit save it redirects to the Details tab. Is there a way to make the visualforce page stay in the Safesend Returns tab after save?

User-added image


Visualforce Page
<apex:page standardController="Account" lightningStylesheets="true">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="2">
            


<apex:outputField value="{!Account.TaxSoftware__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Est_of_tax_returns__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Demo__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1040s__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Total_Revenue__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1041s__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Opportunity_Date__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1120__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Original_Purchase_Date__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1120S__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Client_Status__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1065s__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Next_Steps__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Verified_of_Returns__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
  • July 30, 2019
  • Like
  • 0
Hello,

I would like the Visualforce Page below to stay in the same tab after Save. Any assistance is greatly appreciated.
 
<apex:page standardController="Account" lightningStylesheets="true">
    <apex:form >
        <apex:pageBlock >
             <apex:pageBlockSection title="SafeSend Returns" columns="2">
            
<apex:outputField value="{!Account.TaxSoftware__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Est_of_tax_returns__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Demo__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1040s__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Locked_Return__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>


<apex:outputField value="{!Account.of_1041s__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>


<apex:outputField value="{!Account.SSR_Total_Revenue__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>


<apex:outputField value="{!Account.of_1120__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>


<apex:outputField value="{!Account.SSR_Opportunity_Date__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1120S__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>


<apex:outputField value="{!Account.SSR_Original_Purchase_Date_Roll_Up__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1065s__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Start_Group__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>


<apex:outputField value="{!Account.Verified_of_Returns__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>


<apex:outputField value="{!Account.SSR_Next_Steps__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>


<apex:outputField value="{!Account.E_Signing_Entity_E_File_Forms__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>


<apex:outputField value="{!Account.Client_Success_Manager__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="SS Returns Onboarding/Client Info" columns="2">
            
<apex:outputField value="{!Account.SSR_Client_Status__c}" >  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Post_Tax_Season_Call__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Consulting_Discussion_Date__c}" >  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Firm_Issues__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>


<apex:outputField value="{!Account.SSR_Power_User_Training__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Technology_Issues__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Staff_Training_Date__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Increased__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Momentum_Call__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Dev_Info_VSTS__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Partner_Training__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Refresher_Training_Notes__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Live_Mode__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Onboarding_Training_Notes__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Refresher_Training__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Client_Next_Steps__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_FU_Date__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Process__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"  />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
  • July 16, 2019
  • Like
  • 0
Hello Developers!

I need help merging the two (2) triggers below into one (1) trigger. Any assistance is greatly appreciated. Thank you!

Trigger 1:
Trigger OpptyProducts_Spring on Opportunity (before update) {

list<opportunity> sl = trigger.new;

list<opportunityLineItem> slnu = new list<opportunityLineItem>([select id ,product2.name, opportunityId from opportunitylineitem where IsSpring__c = TRUE AND  opportunityId =: trigger.new[0].id]);

string productName='';

for(opportunityLineItem opp : slnu){

 productName += opp.product2.name + '\n'; // + operator for concatenation.

}

for(Opportunity opp : trigger.new){

 opp.Spring_Products__c = productName;


}


}

Trigger 2:
Trigger OpptyProducts_Fall on Opportunity (before update) {

list<opportunity> sl = trigger.new;

list<opportunityLineItem> slnu = new list<opportunityLineItem>([select id ,product2.name, opportunityId from opportunitylineitem where IsFall__c = TRUE AND  opportunityId =: trigger.new[0].id]);

string productName='';

for(opportunityLineItem opp : slnu){

 productName += opp.product2.name + '\n'; 

}

for(Opportunity opp : trigger.new){

 opp.Fall_Products__c = productName;


}


}

 
  • June 27, 2019
  • Like
  • 0
Hello,

I'm getting the error below.

Error: Compile Error: Constructor not defined: [ApexPages.StandardSetController].<Constructor>(Login_Information_Object__c) at line 22 column 46

for the Test Class below. The Test Class is for a Visualforce Page controller. Any assistance is greatly appreciated.
 
@isTest
public class VFTSIAITSplashPageController_UT {

    
    static testMethod void myTest() {
        Login_Information_Object__c lio=new Login_Information_Object__c();
       
        lio.LIO_Content__c='test';
        lio.LIO_End_Date__c=Date.today() + 30;
        lio.LIO_Start_Date__c=Date.today() + 1;
        lio.Show_On_Login__c=TRUE;
        lio.Subject__c='testing';
        insert lio;   
        
        PageReference pageRef1 = Page.TSIAInformationSplashPage;
        Test.setCurrentPage(pageRef1);
        pageRef1.getParameters().put('id',lio.Id);

        ApexPages.StandardSetController sc = new ApexPages.StandardSetController(lio);
        VFTSIAITSplashPageController testlio = new VFTSIAITSplashPageController (sc);
        
        testlio.save();    
 
        
        
    }
}

 
  • June 12, 2019
  • Like
  • 0
Hello, 

I need the trigger below to only run for a specific opportunity record type called 'Conference'. Any assistance is greatly appreciated.
 
trigger UpdateOpportunityProduct on Opportunity (before insert, before update ){

    Map<String, Opportunity> discCodeToOppMap = new Map<String, Opportunity>();

    for(Opportunity opp:Trigger.new){

    discCodeToOppMap.put(opp.Discount_Code__c, opp);

    }

    List<Product2> prodLst = [SELECT ID, ProductCode FROM Product2 where ProductCode in :discCodeToOppMap.keySet()];

    for(Product2 prod : prodLst){
    
        discCodeToOppMap.get(prod.ProductCode).Discount_Code_LU__c = prod.ID;
    }
}

 
  • May 28, 2019
  • Like
  • 0
Hello,

I need the trigger below to only find the duplicate record if the Status__c is 'Active' on both records. Status__c is a picklist field. Any assistance is greatly appreciated!
trigger DuplicateExecutiveContact on Committee_Board_Member__c (before insert. before update) {
        for(Committee_Board_Member__c c:Trigger.new)
        {
      
            List<Committee_Board_Member__c> comm=[select ID from Committee_Board_Member__c where Account__c=:c.Account__c and Committee_Board__c=:c.Committee_Board__c and Service_Discipline__c=:c.Service_Discipline__c and Status__c=:c.Status__c];
            if(comm.size()>0)
            {
                c.adderror('Duplicate Record');
            }
        }
    }

 
  • April 09, 2019
  • Like
  • 0
Hello,

We are trying to deploy apex class below for Communities but it's only convering 45% of the code. Any assistance is greatly appreciated!

Controller:
/**
 * An apex page controller that supports self registration of users in communities that allow self registration
 */
public with sharing class CommunitiesSelfRegController {

  public String firstName {get; set;}
  public String lastName {get; set;}
  public String email {get; set;}
  public String password {get; set {password = value == null ? value : value.trim(); } }
  public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
  public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
  
  public CommunitiesSelfRegController() {}
  
  private boolean isValidPassword() {
    return password == confirmPassword;
  }

  public PageReference registerUser() {
  
    // it's okay if password is null - we'll send the user a random password in that case
    if (!isValidPassword()) {
      System.debug(System.LoggingLevel.DEBUG, '## DEBUG: Password is invalid - returning null');
      ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
      ApexPages.addMessage(msg);
      return null;
    }  

    // 25-Jun-2013 Manu Erwin - Fixing insufficient code coverage for default Communities Apex Tests
    //String profileId = ''; // To be filled in by customer.
    //String roleEnum = ''; // To be filled in by customer.
    //String accountId = ''; // To be filled in by customer.

    // Set this to your main Communities Profile API Name
    String profileApiName = 'PowerCustomerSuccess';
    String profileId = [SELECT Id FROM Profile WHERE UserType = :profileApiName LIMIT 1].Id;
    List<Account> accounts = [SELECT Id FROM Account LIMIT 1];
    System.assert(!accounts.isEmpty(), 'There must be at least one account in this environment!');
    String accountId = accounts[0].Id;
    
    String userName = email;

    User u = new User();
    u.Username = userName;
    u.Email = email;
    u.FirstName = firstName;
    u.LastName = lastName;
    u.CommunityNickname = communityNickname;
    u.ProfileId = profileId;
    
    String userId = Site.createPortalUser(u, accountId, password);
   
    if (userId != null) { 
      if (password != null && password.length() > 1) {
        System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation successful and password ok - returning site.login');
        return Site.login(userName, password, null);
      }
      else {
        System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation successful but password not ok - redirecting to self reg confirmation');
        PageReference page = System.Page.CommunitiesSelfRegConfirm;
        page.setRedirect(true);
        return page;
      }
    }
    System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation not successful - returning null');
    return null;
  }
}

Test Class:
/**
 * An apex page controller that supports self registration of users in communities that allow self registration
 */
@IsTest public with sharing class CommunitiesSelfRegControllerTest {
  @IsTest(SeeAllData=true) 
  public static void testCommunitiesSelfRegController() {
    CommunitiesSelfRegController controller = new CommunitiesSelfRegController();

    // 25-Jun-2013 Manu Erwin - Fixing insufficient code coverage for default Communities Apex Tests
    controller.firstName = 'Bob';
    controller.lastName = 'Jones';
    controller.email = 'bob@jones.com';
    controller.password = '8yhMsHDN&ituQgO$WO';
    controller.confirmPassword = '8yhMsHDN&ituQgO$WO';
    controller.communityNickname = 'bob-jones-testing';

    PageReference pageRef = controller.registerUser();
  }
  // 25-Jun-2013 Manu Erwin - Fixing insufficient code coverage for default Communities Apex Tests
  @IsTest(SeeAllData=true) 
  public static void testInvalidPassword() {
    CommunitiesSelfRegController controller = new CommunitiesSelfRegController();
    controller.firstName = 'Bob';
    controller.lastName = 'Jones';
    controller.email = 'bob@jones.com';
    controller.password = '8yhMsHDN&ituQgO$WO';
    controller.confirmPassword = 'not the same';
    controller.communityNickname = 'bob-jones-testing';

    PageReference pageRef = controller.registerUser();
    System.assert(pageRef == null, 'The returned page reference should be null');
  }
  // 25-Jun-2013 Manu Erwin - Fixing insufficient code coverage for default Communities Apex Tests
  @IsTest(SeeAllData=true) 
  public static void testNullPassword() {
    CommunitiesSelfRegController controller = new CommunitiesSelfRegController();
    controller.firstName = 'Bob';
    controller.lastName = 'Jones';
    controller.email = 'bob@jones.com';
    controller.communityNickname = 'bob-jones-testing';

    PageReference pageRef = controller.registerUser();
    System.assert(pageRef == null, 'The returned page reference should be null');
  }
}

 
  • April 01, 2019
  • Like
  • 0
Hello,

I have the trigger below thats retrieving the FeedItem File ID but I need it to only retrieve the file ID from files that have the word "SOW" in the file name. Any assistance is greatly appreciated.
 
trigger FeedItemIDOppty on FeedItem (after insert, after update) {
List<Opportunity> O = [select id, File_ID__c from Opportunity where id =: Trigger.new[0].ParentId];
        for(FeedItem fi : trigger.new){
    FeedItem fiii =[SELECT Body, (SELECT RecordId, Title, Type, Value FROM FeedAttachments) 
FROM FeedItem 
WHERE Id =: fi.Id];
        
        O[0].File_ID__c=fiii.FeedAttachments[0].Id ; 
        update O ;
        
        }
   

   }

 
  • March 01, 2019
  • Like
  • 0
Hello,

I have the trigger below that is retreving the FeedItem ID but I need it to retrieve the File ID when a file is attached to the feed. Any assistancw will be greatly appreciated.

 
trigger FeedItemIDOppty on FeedItem (before insert,after insert, before update,after update) {
List<Opportunity> O = [select id, File_ID__c from Opportunity where id =: Trigger.new[0].ParentId];
        for(FeedItem fi : trigger.new)
        if(O.size()>0)
            O[0].File_ID__c = fi.ID;
                                    update O;
                        }


 
  • February 22, 2019
  • Like
  • 0
Hello everyone!

I have a trigger (below) that is excluding the User Role 'Research' so that role can perform bulk updates on that object. The triggers works fine when you update individual records and up to 100 records for bulk updates. If we exceed 100 records for our bulk updates we receive the following error:

 System.LimitException: Too many SOQL queries: 101

Any assistance with this trigger is greatly appreciated!!
trigger SurveyHandling on Relationship_to_Initiative_Research__c (after insert,after delete,after update) {

list<Id> rlist4=new list<Id> ();
list<Initiatives__c > rlsit5=new list<Initiatives__c >();

//////////// insert and update operation


if(trigger.isinsert || trigger.isupdate){
for(Relationship_to_Initiative_Research__c i : trigger.new)


{UserInfo.getUserRoleId(); 

List<String> exemptedRoles = new List<String>();
exemptedRoles.add('ATeam');

list<UserRole> IsItExemptedRole=[select id,name from UserRole where name in :exemptedRoles and id=:UserInfo.getUserRoleId()];

if(IsItExemptedRole.size()<=0){


{

rlist4.add(i.Initiative_Title__c );     
}


Initiatives__c ini=[select id,Action_ItemsRICHTEXT__c,Progress__c,Timeframe__c,Owner__c from Initiatives__c where id in:rlist4];


for(Relationship_to_Initiative_Research__c rr:trigger.new){

ini.Action_ItemsRICHTEXT__c=rr.Action_Item_ScriptRICHTEXT__c ;
ini.Progress__c=rr.Progress__c ;
ini.Timeframe__c=rr.Timeframe__c ;
ini.Owner__c=rr.Owner__c ;


rlsit5.add(ini);
} update rlsit5; 

}


/////////////// Delete operation start   




if(trigger.isdelete){
for(Relationship_to_Initiative_Research__c ii : trigger.old)

{

rlist4.add(ii.Initiative_Title__c );     
}


Initiatives__c ini=[select id,Action_ItemsRICHTEXT__c,Progress__c,Timeframe__c,Owner__c  from Initiatives__c where id in:rlist4];


for(Relationship_to_Initiative_Research__c rr:trigger.old){

ini.Action_ItemsRICHTEXT__c=rr.Action_Item_ScriptRICHTEXT__c ;
ini.Progress__c=rr.Progress__c ;
ini.Timeframe__c=rr.Timeframe__c ;
ini.Owner__c=rr.Owner__c ;
rlsit5.add(ini);
} update rlsit5; 

}


}
}
}

 
  • March 13, 2018
  • Like
  • 0
Hi All,

I have a apex controller that I need to deploy into our production org. The current test class is only covering 40%. Any assistance is increasing the coverage for the controller below is much appreciated. Controller and test class below - thank you!!

Controller
public class AnnualTouchpointPlanningController {

    Public List<Task> TaskList{get;set;}
   // public String contId{get;set;} 
   // public String dcid{get;set;}
   // public task task{get;set;}
   // Public string editid{get;set;} 
    public opportunity oo;
  //      public Id selectedDetailID { get;set; }

    
    String currentRecordId ; 
    public AnnualTouchpointPlanningController(ApexPages.StandardController controller) {
       
        
        currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
       
     TaskList = [Select subject,id, Type, EarliestDate__c,Who.Type,whatID,priority,status,ActivityDate,ATP_Task__c,Completion_Date__c,Task_Record__c FROM Task WHERE Whatid=:currentRecordId and ATP_Task__c=true ];
     
    
     
     if(TaskList.size() == 0)
{
    Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No ATP Tasks to Display'));
   } 
 }
 
 public pagereference saveProject(){
 

  system.debug('ssssss'+TaskList );
    
    upsert TaskList ; // the LIST
  
     PageReference pageRef = new PageReference('/apex/AnnualTouchpointPlanning');
    pageRef.setRedirect(true);
    return null;
}    
     
    public PageReference save()
    {
        upsert TaskList ;
        
        return new PageReference('/apex/AnnualTouchpointPlanning');
    }  
     
     
       public pagereference deleteCon() {
       String s1 = System.CurrentPageReference().getParameters().get('dtlIdParam');
       task t=[ select id,status From task Where id=:s1];
       t.status= 'completed';
       upsert t;
       PageReference pageRef = new PageReference('/apex/AnnualTouchpointPlanning');
       pageRef.setRedirect(true);
       return null;
   } 
    
 
   
   
}
Test Class
@isTest
public class AnnualTouchpointPlanningController_UT {

    
    static testMethod void myTest() {
        Account a=new Account();
        a.Name='test';
        a.Type='Member';
        a.Major_Market__c='Other';
        a.AnnualRevenue=1000;
        a.Member_Services_Representative__c='00550000006Rkqu';
        insert a;       
 
        Service_Discipline__c sd=new Service_Discipline__c();
        sd.Name='sd test';
        sd.Service_Discipline_Acronym__c='test acc';
        insert sd;
           
        Opportunity opp=new Opportunity();
        opp.AccountID=a.Id;
        opp.Name='test';
        opp.Type='New';
        opp.Subscription_Start_Date__c = Date.today() + 1;
        opp.First_Service_Discipline__c=sd.Id;
        opp.Subscription_Expiration_Date__c = Date.today() + 30;
        opp.RecordTypeId='01250000000HjVK';
        opp.Deal_Status__c='Budget Approved';
        opp.StageName='PC - Pre-Contact';
        opp.CloseDate= Date.today() + 45;
        opp.Amount = 500;
        insert opp;
        
        Task tsk = new Task();
        tsk.WhatId = opp.Id;
        tsk.Subject = 'Test Subject';
        tsk.Status = 'Completed';
        tsk.ATP_Task__c = true;
        tsk.Type = 'Vision & Strategy Call (180)';
        tsk.Priority = 'Normal'; 
        tsk.ActivityDate = Date.today() + 30;
        insert tsk;
        delete tsk;
        
     
        
        PageReference pageRef = Page.AnnualTouchpointPlanning;
        Test.setCurrentPage(pageRef);
        pageRef.getParameters().put('id',opp.Id);


        ApexPages.StandardController sc = new ApexPages.StandardController(tsk);
        AnnualTouchpointPlanningController testAccPlan = new AnnualTouchpointPlanningController(sc);
        
        testAccPlan.save();
       
       //testAccPlan.deleteCon();
        
    
      //  testAccPlan.
         
        
        
    }
}

 
  • March 02, 2018
  • Like
  • 0
Hello,

I need help with the apex trigger below. I need this trigger to only fire for Opportunity RecordTypeId '01250000000HjVU'

Any assistance is greatly appreciated!!
 
trigger AttendeesHandling on Opportunity (after insert,after delete,after update) {

list<Id> rlist1=new list<Id> ();
        list<Product2 > rlsit=new list<Product2>();
        
//////////// insert and update operation
        
 if(trigger.isinsert || trigger.isupdate){
    for(Opportunity o : trigger.new)
   
    {
        
        rlist1.add(o.Discount_code_LU__c);     
    }
 
  Product2 p2=[select id,Attendees__c from Product2 WHERE id in:rlist1];
    
  
  for(Opportunity opp:trigger.new){
   
   p2.Attendees__c=opp.Attendee_Name__c ;
  

   rlsit.add(p2);
    } update rlsit; 
    
  }
   
 /////////////// Delete operation start   
 
    if(trigger.isdelete){
    for(Opportunity o : trigger.old)
   
        
    {
        
        rlist1.add(o.Discount_code_LU__c );     
    }

  Product2 p2=[select id,Attendees__c from Product2 WHERE id in:rlist1 LIMIT 1];
    
  
  for(Opportunity opp:trigger.old){
   
   p2.Attendees__c=opp.Attendee_Name__c ;
 
   rlsit.add(p2);
    } update rlsit; 
    
    }
}

 
  • December 01, 2017
  • Like
  • 0
I need the trigger below to activate only if the opportunity is RecordType "Conference". Any assistance is greatly apprecitated!

 
trigger RollUpOpportunity on Opportunity (after insert,after update, after delete,after undelete) {
    
    List<id> ParentIds = new List<id>();
    if(Trigger.isInsert || Trigger.isUndelete || Trigger.isupdate){
        For(Opportunity Opp : Trigger.new){
            ParentIds.add(Opp.Discount_code_LU__c);
        }
    }
    if(Trigger.isDelete){
        For(Opportunity Opp : Trigger.old){
            ParentIds.add(Opp.Discount_code_LU__c);
        }
    }
    List<Product2> ProductsToUpdate = new List<Product2>();
    decimal sum = 0;
    if(Trigger.isInsert || Trigger.isUndelete || Trigger.isupdate|| trigger.isdelete){
        For(Product2 q : [SELECT Related_Conference_Opportunities__c ,(SELECT id FROM Opportunities__r WHERE Voucher_Canceled__c = False)
         FROM Product2 WHERE id =: ParentIds]){
            sum = 0;
            for(Opportunity p : q.Opportunities__r){
                
                   sum = sum + 1;
            }
            q.Related_Conference_Opportunities__c = sum;
            ProductsToUpdate.add(q);
        }
        try{
            update ProductsToUpdate;
        }Catch(Exception e){
            System.debug('Exception :'+e.getMessage());
        }
    }
}


 
  • November 02, 2017
  • Like
  • 0
Hello,

I'm having an issue with the Visualforce page below. When I inline-edit from the VFpage and refresh, the data from the text fields on the child records copy accross all child records. Any assistance is will be greatly appreciated!!

BEFORE VFPage Inline-Edit
Before Edit
AFTER VFPage Inline-Edit
After Edit

Controller:
public class SuccessPlanningController {

    Public List<Initiatives__c> IntList{get;set;}
    
    public String contId{get;set;} 
    public String dcid{get;set;}
    public Initiatives__c Intobj{get;set;}
    Public string editid{get;set;} 
    public Success_Plan__c SP {get;set;}
    public Id selectedDetailID { get;set; }
    public String s{get;set;}
    
   
    String currentRecordId ; 
    public SuccessPlanningController (ApexPages.StandardController controller) {
       // this.oppty= (Success_Plan__c)controller.getRecord();
   s='';
   currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
   SP=[Select id,name,(select id,name,Name_Formula__c,Source_Formula__c,Status_Formula__c,SBC_Formula__c,Confirmed_Formula__c,TimeframeINSERT__c,Action_ItemINSERT__c,ProgressINSERT__c,OwnerINSERT2__c,OwnerINSERT__c,Description__c,Owner__c,FreeText__c,Timeframe__c,Progress__c,Confirmed__c,Action_Items__c,Action_ItemF__c,Action_ItemsRICHTEXT__c,Source__c,Service_Business_Challenge__c,Initiative_Owner__c, Service_Discipline__c,In_Success_Plan__c,Initiative_Record__c,Status__c,Order__c from Initiatives__r where In_Success_Plan__c=True  ORDER BY Order__c ASC) from Success_Plan__c where id=:currentRecordId ];
     
    
   if(SP==null)
   {
    Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No Initiatives to Display'));
   } 
 }
     
    public PageReference save()
    {
    system.debug('sssssssssssssuuuu'+SP);
        upsert SP.Initiatives__r;
        
    PageReference pageRef = new PageReference('/apex/SuccessPlanning');
    pageRef.setRedirect(true);
    return null;    }  
     
     
       public pagereference deleteCon() {
       String s1 = System.CurrentPageReference().getParameters().get('dtlIdParam');
       Initiatives__c t=[ select id,In_Success_Plan__c From Initiatives__c Where id=:s1];
       t.In_Success_Plan__c =false;
      
       upsert t;
       PageReference pageRef = new PageReference('/apex/SuccessPlanning');
       pageRef.setRedirect(true);
       return null;
   } 
    
 
   
   
}

Visualforce Page:
<apex:page standardController="Success_Plan__c" extensions="SuccessPlanningController"  >
<apex:sectionHeader title="Initiatives"/>
<apex:form >
<div align="center">
<apex:commandButton value="Save" action="{!save}" id="saveButton" />
</div>
<apex:pageBlock id="pb">
<apex:pageMessages />
<!--  <div align="center" draggable="false" >
<apex:commandButton action="{!save}" value="Save" id="theButton"  /> </div> -->

<apex:pageBlockTable value="{!SP.Initiatives__r}" var="d">

<apex:column headerValue="Order">   
<apex:outputField value="{!d.Order__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Initiatives">   
<apex:outputField value="{!d.Name_Formula__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Source">   
<apex:outputField value="{!d.Source__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Status">   
<apex:outputField value="{!d.Status__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Service Business Challenge">   
<apex:outputField value="{!d.Service_Business_Challenge__c  }">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Action Items">   
<apex:outputField value="{!d.Action_ItemsRICHTEXT__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Owner">   
<apex:outputField value="{!d.Owner__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Timeframe">   
<apex:outputField value="{!d.Timeframe__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Progress">   
<apex:outputField value="{!d.Progress__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Confirmed">   
<apex:outputField value="{!d.Confirmed__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Action">   
<apex:outputField value="{!d.Initiative_Record__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Action">
<apex:commandLink value="Remove" action="{!deleteCon}" reRender="pb"  oncomplete="window.top.location = '/{!Success_Plan__c.id}';">
<apex:param value="{!d.id}" assignTo="{!dcid}" name="dtlIdParam"/>
</apex:commandLink>
</apex:column>                
<apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" /> 
</apex:pageBlockTable>

</apex:pageblock>
</apex:form>
</apex:page>


 
  • October 02, 2017
  • Like
  • 0
Hello,

I have the Apex Trigger below the checkmarks the Has_Attachement__c field on the Case record when there in an attachement on the case BUT I'm only getting 50% code coverage with the Test Class below. I need help from the community to assist me on increasing the code coverage so that I can deploy the trigger into production. Any assistance is greatly appreciated, thank you!

Apex Trigger 
trigger CaseHasAttachement on Attachment (after insert) {
            {
                        List<Case> cs = [select id, Has_Attachment__c from Case where id =: Trigger.New[0].ParentId];
                        if(cs.size()>0)
                        {
                                    cs[0].Has_Attachment__c = true;
                                    update cs;
                        }                                                                   
            }
            }

Test Class
@isTest
public class CaseHasAttachement_UT {

    
    static testMethod void myTest() {
    
            Account a=new Account();
        a.Name='test';
        a.Type='Member';
        a.Major_Market__c='Other';
        a.AnnualRevenue=1000;
        insert a;  
        
        Contact c=new Contact();
        c.RecordTypeID='01250000000HdFN';
        c.FirstName='ferasfd';
        c.LastName='testeringglowoski';
        c.phone='123456';
        c.AccountId=a.id;
        c.Level_in_Account__c='VP';
        c.Primary_Job_Function__c='Unknown';
        c.LeadSource='Sales';
        insert c;
        
        Case testCase = TestDataUtils.createCase(false);
        testCase.ContactId = c.id;
        testCase.AccountId = a.id;
        testCase.Web_Primary_Service_Discipline__c = 'Field Services';
        testCase.Type = 'Research Inquiry';
        testCase.Has_Attachment__c = FALSE;
        insert testCase;
    
        Attachment attach=new Attachment(); 
        attach.Name='Unit Test Attachment'; 
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body'); 
        attach.body=bodyBlob; 
        attach.parentId=a.Id; 
        attach.ContentType = 'application/msword'; 
        attach.IsPrivate = false; 
        attach.Description = 'Test'; 
        insert attach; 
        System.debug('Inserted: '+ attach.Id); 
        
    }
}

 
  • September 24, 2017
  • Like
  • 0
Hello Developers,

I have the Visualforce Page below that is suppose to be able to perform inline editing but when I click on Save it reverts back to the account record and does not save the data that was entered. Any assistance is greatly appreciated!

Thank you,
Gerald
 
<apex:page standardController="Account" >
<apex:sectionHeader title="Membership" subtitle="Entitlements"/>
<apex:form >
<div align="left">
<apex:commandButton value="Save" action="{!save}" id="saveButton" />
</div>
<apex:pageBlock id="pb">
<apex:pageMessages />
<!--  <div align="center" draggable="false" >
<apex:commandButton action="{!save}" value="Save" id="theButton"  /> </div> -->

<apex:pageBlockTable value="{!Account.SEMs__r}" var="A">

<apex:column headerValue="Service Discipline">   
<apex:outputField value="{!A.Name}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>  

<apex:column headerValue="Entitlement Status">   
<apex:outputField value="{!A.Membership_Status__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Qualification Status">   
<apex:outputField value="{!A.Status__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Service Entitlement">   
<apex:outputField value="{!A.Service_Entitlement__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column>

<apex:column headerValue="Opportunity">   
<apex:outputField value="{!A.Opportunity__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column> 

<apex:column headerValue="Notes">   
<apex:outputField value="{!A.Notes__c}">  
<apex:inlineEditSupport event="ondblclick" />                      
</apex:outputField> </apex:column> 
                            
<apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" /> 
</apex:pageBlockTable>

</apex:pageblock>
</apex:form>
</apex:page>

 
  • August 17, 2017
  • Like
  • 0
Hello Developers,

I have the Apex Trigger below ​that is mixing the fileds data with the other records data when you edit from the Visualforcepage. Screenshots below. Notice the Action Item field in the Before screenshot compared to the Action Item field in the After screenshot. The data mixed after edit and this should not be happening. Any assistance will be greatly appreciated!

Before
Before
After
After
 
trigger InitiativeHandling on Initiatives__c(before update) {

    
    list<Id> rlist1=new list<Id> ();
    list<id> rlist=new list<id> ();list<String> summm;String sss='';

    for(Initiatives__c i : trigger.new)
        
    {
        
        rlist1.add(i.id);     
    }
    
    
  list<Relationship_to_Initiative_Outcome_Chain__c> ini= [select id,Progress__c from  Relationship_to_Initiative_Outcome_Chain__c  where Initiative_Title__c in: rlist1];
    
 for(Relationship_to_Initiative_Outcome_Chain__c riiP:ini){ 
      
     sss+= riiP.Progress__c + '\n' ;
    
    }    
     
   list<Relationship_to_Initiative_DM__c > rti= [select id,Progress__c from  Relationship_to_Initiative_DM__c where Initiative_Title__c in: rlist1];
   for(Relationship_to_Initiative_DM__c riiP1:rti){ 
    
     sss+= riiP1.Progress__c + '\n' ;
    }

    list<Relationship_to_Initiative_Research__c> rir= [select id,Progress__c from  Relationship_to_Initiative_Research__c where Initiative_Title__c in: rlist1];  
    for(Relationship_to_Initiative_Research__c riiP2:rir){ 
    
     sss+= riiP2.Progress__c + '\n' ;
 
    }
    
 for(Initiatives__c i : trigger.new)
        
    {   
            
        i.Progress__c=sss;

    
    }
    list<Id> rlist2=new list<Id> ();
    list<id> rlist3=new list<id> ();list<String> summmm;String sss2='';

    for(Initiatives__c i : trigger.new)
        
    {
        
        rlist2.add(i.id);     
    }   
   list<Relationship_to_Initiative_Outcome_Chain__c> ini1= [select id,Action_Item_ScriptRICHTEXT__c  from  Relationship_to_Initiative_Outcome_Chain__c  where Initiative_Title__c in: rlist2];   
 for(Relationship_to_Initiative_Outcome_Chain__c riiAIS:ini1){ 
      
     sss2+= riiAIS.Action_Item_ScriptRICHTEXT__c + '<br/>';
    
    }  
       list<Relationship_to_Initiative_DM__c > rti1= [select id,Action_Item_ScriptRICHTEXT__c from  Relationship_to_Initiative_DM__c where Initiative_Title__c in: rlist2];
    for(Relationship_to_Initiative_DM__c riiAIS1:rti1){ 
    
     sss2+= riiAIS1.Action_Item_ScriptRICHTEXT__c + '<br/>';
    }   
      list<Relationship_to_Initiative_Research__c> rir1= [select id,Action_Item_ScriptRICHTEXT__c from  Relationship_to_Initiative_Research__c where Initiative_Title__c in: rlist2];  
    for(Relationship_to_Initiative_Research__c riiAIS2:rir1){ 
    
    sss2+= riiAIS2.Action_Item_ScriptRICHTEXT__c + '<br/>';     
}
 for(Initiatives__c i : trigger.new)
        
    {        
        i.Action_ItemsRICHTEXT__c=sss2;    
    
    }
    list<Id> rlist4=new list<Id> ();
    list<id> rlist5=new list<id> ();list<String> summmmm;String sss3='';

    for(Initiatives__c i : trigger.new)
        
    {
        
        rlist4.add(i.id);     
    }   
   list<Relationship_to_Initiative_Outcome_Chain__c> ini2= [select id,Timeframe__c  from  Relationship_to_Initiative_Outcome_Chain__c  where Initiative_Title__c in: rlist4];   
 for(Relationship_to_Initiative_Outcome_Chain__c riiTF:ini2){ 
      
     sss3+= riiTF.Timeframe__c + '\n' ;
    
    }  
       list<Relationship_to_Initiative_DM__c > rti2= [select id,Timeframe__c from  Relationship_to_Initiative_DM__c where Initiative_Title__c in: rlist4];
    for(Relationship_to_Initiative_DM__c riiTF1:rti2){ 
    
     sss3+= riiTF1.Timeframe__c + '\n' ;
    }   
      list<Relationship_to_Initiative_Research__c> rir2= [select id,Timeframe__c from  Relationship_to_Initiative_Research__c where Initiative_Title__c in: rlist4 ];  
    for(Relationship_to_Initiative_Research__c riiTF2:rir2){ 
    
    sss3+= riiTF2.Timeframe__c + '\n' ;   
}
 for(Initiatives__c i : trigger.new)
        
    {        
        i.Timeframe__c=sss3;    
    
    }
    list<Id> rlist6=new list<Id> ();
    list<id> rlist7=new list<id> ();list<String> summmmmm;String sss4='';

    for(Initiatives__c i : trigger.new)
        
    {
        
        rlist6.add(i.id);     
    }   
    
   list<Relationship_to_Initiative_Outcome_Chain__c> ini3= [select id,Owner__c  from  Relationship_to_Initiative_Outcome_Chain__c  where Initiative_Title__c in: rlist6];   
   for(Relationship_to_Initiative_Outcome_Chain__c riiO:ini3){ 
      
   sss4+= riiO.Owner__c + '\n' ;
    
    }  
    
    list<Relationship_to_Initiative_DM__c > rti3= [select id,Owner__c from  Relationship_to_Initiative_DM__c where Initiative_Title__c in: rlist6];
    for(Relationship_to_Initiative_DM__c riiO1:rti3){ 
    
     sss4+= riiO1.Owner__c + '\n' ;
     
    }   
    
    list<Relationship_to_Initiative_Research__c> rir3= [select id,Owner__c from  Relationship_to_Initiative_Research__c where Initiative_Title__c in: rlist6];  
    for(Relationship_to_Initiative_Research__c riiO2:rir3){ 
    
    sss4+= riiO2.Owner__c + '\n' ;   
}
    for(Initiatives__c i : trigger.new)
        
    {        
        i.Owner__c=sss4;    
    
    }
    }

 
  • June 12, 2017
  • Like
  • 0
I have created 4 triggers that I merged into 1 trigger for "best practice." The trigger ​works very well in the sandbox but I don't believe I have merged the triggers correctly. Any assistance or suggestions to help me merge these triggers correctly is greatly appreciated!

Merged trigger below.
trigger SurveyHandling on Relationship_to_Initiative_Research__c (after insert,after delete,after update) {

        list<Id> rlist1=new list<Id> ();String sss='';
        list<Initiatives__c > rlsit=new list<Initiatives__c >();
        
//////////// insert and update operation
        
 if(trigger.isinsert || trigger.isupdate){
    for(Relationship_to_Initiative_Research__c  i : trigger.new)
        
    {
        
        rlist1.add(i.Initiative_Title__c );     
    }
    
    
  Initiatives__c ini=[select id,Action_ItemsRICHTEXT__c  from Initiatives__c where id in:rlist1];
    
  
  for(Relationship_to_Initiative_Research__c  rr:trigger.new){
   
   ini.Action_ItemsRICHTEXT__c=rr.Action_Item_ScriptRICHTEXT__c ;
   rlsit.add(ini);
    } update rlsit; }
    
   
 /////////////// Delete operation start   
    
    
    if(trigger.isdelete){
    for(Relationship_to_Initiative_Research__c  i : trigger.old)
        
    {
        
        rlist1.add(i.Initiative_Title__c );     
    }
    
    
  Initiatives__c ini=[select id,Action_ItemsRICHTEXT__c  from Initiatives__c where id in:rlist1];
    
  
  for(Relationship_to_Initiative_Research__c  rr:trigger.old){
   
   ini.Action_ItemsRICHTEXT__c=rr.Action_Item_ScriptRICHTEXT__c ;
   rlsit.add(ini);
    } update rlsit; }
        list<Id> rlist2=new list<Id> ();String ssss='';
        list<Initiatives__c > rlist3=new list<Initiatives__c >();
        
//////////// insert and update operation
        
 if(trigger.isinsert || trigger.isupdate){
    for(Relationship_to_Initiative_Research__c  i : trigger.new)
        
    {
        
        rlist2.add(i.Initiative_Title__c );     
    }
    
    
  Initiatives__c iniTF=[select id,Timeframe__c  from Initiatives__c where id in:rlist2];
    
  
  for(Relationship_to_Initiative_Research__c  rrr:trigger.new){
   
   iniTF.Timeframe__c=rrr.Timeframe__c ;
   rlist3.add(iniTF);
    } update rlist3; }
    
   
 /////////////// Delete operation start   
    
    
    if(trigger.isdelete){
    for(Relationship_to_Initiative_Research__c  i : trigger.old)
        
    {
        
        rlist2.add(i.Initiative_Title__c );     
    }
    
    
  Initiatives__c iniTF=[select id,Timeframe__c  from Initiatives__c where id in:rlist2];
    
  
  for(Relationship_to_Initiative_Research__c  rrr:trigger.old){
   
   iniTF.Timeframe__c=rrr.Timeframe__c ;
   rlist3.add(iniTF);
    } update rlist3; }
    
    

list<Id> rlist4=new list<Id> ();String sssss='';
        list<Initiatives__c > rlist5=new list<Initiatives__c >();
        
//////////// insert and update operation
        
 if(trigger.isinsert || trigger.isupdate){
    for(Relationship_to_Initiative_Research__c i : trigger.new)
        
    {
        
        rlist4.add(i.Initiative_Title__c );     
    }
    
    
  Initiatives__c iniO=[select id,Owner__c,Initiative_Owner__c from Initiatives__c where id in:rlist4 Limit 1];
    
  
  for(Relationship_to_Initiative_Research__c  rrrr:trigger.new){
   
   iniO.Owner__c=rrrr.Owner__c ;
   rlist5.add(iniO);
    } update rlist5; }
    
   
 /////////////// Delete operation start   
    
    
    if(trigger.isdelete){
    for(Relationship_to_Initiative_Research__c  i : trigger.old)
        
    {
        
        rlist4.add(i.Initiative_Title__c );     
    }
    
    
  Initiatives__c iniO=[select id,Owner__c,Initiative_Owner__c  from Initiatives__c where id in:rlist4];
    
  
  for(Relationship_to_Initiative_Research__c  rrrr:trigger.old){
   
   iniO.Owner__c=rrrr.Owner__c ;
   rlist5.add(iniO);
    } update rlist5; }
    



        list<Id> rlist7=new list<Id> ();String ssssss='';
        list<Initiatives__c > rlist8=new list<Initiatives__c >();
        
//////////// insert and update operation
        
 if(trigger.isinsert || trigger.isupdate){
    for(Relationship_to_Initiative_Research__c  i : trigger.new)
        
    {
        
        rlist7.add(i.Initiative_Title__c );     
    }
    
    
  Initiatives__c iniP=[select id,Progress__c  from Initiatives__c where id in:rlist7];
    
  
  for(Relationship_to_Initiative_Research__c  rrrrr:trigger.new){
   
   iniP.Progress__c=rrrrr.Progress__c ;
   rlist8.add(iniP);
    } update rlist8; }
    
   
 /////////////// Delete operation start   
    
    
    if(trigger.isdelete){
    for(Relationship_to_Initiative_Research__c  i : trigger.old)
        
    {
        
        rlist7.add(i.Initiative_Title__c );     
    }
    
    
  Initiatives__c iniP=[select id,Progress__c  from Initiatives__c where id in:rlist7];
    
  
  for(Relationship_to_Initiative_Research__c  rrrrr:trigger.old){
   
   iniP.Progress__c=rrrrr.Progress__c ;
   rlist8.add(iniP);
    } update rlist8; }
    
    
}

 
  • May 29, 2017
  • Like
  • 0
Hello Developers,

I have the test class below that is receiving this error: "Line -1 Expression cannot be assigned​"

Your assistance is greatly appreciated!
@isTest
public class testClassSuccessPlan
{
    static testMethod void test()
    {      
                  
            //Create success plan record
            test.startTest();
            Success_Plan__c Success_Plan = new Success_Plan__c();
            Success_Plan__c.Name = 'Test Plan';
            Success_Plan__c.Account__c = '0015000000SsYnN';
            Success_Plan__c.Member_Success_Manager__c = '00550000006Rkqu';
            insert Success_Plan;  

            //Create initiative record
            Initiatives__c Initiative = new Initiatives__c();
            Initiatives__c.Name = 'Test Int';
            Initiatives__c.Service_Discipline__c = 'a035000000BdWzV';
            insert Initiative;           
         
          
                
            test.stopTest();
    }
}

 
  • April 17, 2017
  • Like
  • 0
Hello Developers!

I need assistance with my Apex Class. I'm getting the error below for the Apex Class below. Any assistance will be gladly appreciated!

Error: Compile Error: Didn't understand relationship 'Products__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 16 column 6
 
public class StockroomConfVouchersController {

    Public List<Product2> Product2List{get;set;}
    public String contId{get;set;} 
    public String dcid{get;set;}
    public Product2 Product2Obj{get;set;}
    Public string editid{get;set;} 
    public Stockroom__c S {get;set;}
        public Id selectedDetailID { get;set; }

    
    String currentRecordId ; 
    public StockroomConfVouchersController (ApexPages.StandardController controller) {
    
   currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
   S=[SELECT ID,Name,(SELECT ID,Name,Balance__c,Capacity__c,UsedNEW__c,IsActive,Start_Date__c,End_Date__c, Status__c FROM Products__r WHERE Status__c = 'Active') FROM Stockroom__c WHERE ID=:currentRecordId ];
     
     
     
     
        system.debug('ssssssssss'+Product2List);
        system.debug('uuuuu'+currentRecordId );

     
   if(S==null)
   {
    Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No Confernce Vouchers to Display'));
   } 
 }
 

     
    public PageReference save()
    {
    system.debug('sssssssssssssuuuu'+S);
        upsert S.Products__r;
        
    PageReference pageRef = new PageReference('/apex/StockroomConfVouchers');
    pageRef.setRedirect(true);
    return null;    }  
     
     
       public pagereference deleteCon() {
       String s1 = System.CurrentPageReference().getParameters().get('dtlIdParam');
       Product2 p=[ select id,IsActive From Product2 Where id=:s1];
       p.IsActive = false;
      
       upsert p;
       PageReference pageRef = new PageReference('/apex/StockroomConfVouchers');
       pageRef.setRedirect(true);
       return null;
   } 
    
 
   
   
}ß

 
  • April 13, 2017
  • Like
  • 0
Hello,

I'm trying to create a Visualforce page that only displays related Tasks that are of a certain type or status.This is what I have so far and I'm getting errors. Any assistance would be very much appreciated.

Extension:
public class AnnualTouchpointPlanningController {

    private List<Task> task;
    private Opportunity oppty; 
    public AnnualTouchpointPlanningController(ApexPages.StandardController controller) {
        this.oppty= (Opportunity)controller.getRecord();
    }
    public List<Task> getTask()
    {
       Opportunity opp = [Select id, Account.id FROM Opportunity where id = :oppty.id];
        if (opp.Account == null)
         return null;
        task = [Select id, Type, EarliestDate__c, DeadlineDate__c, ActualDate__c from Task where Account.id = :opp.Account.id];
        return task;
    }
}

Page:
<apex:page standardController="Opportunity" extensions="AnnualTouchpointPlanningController">
<style>
.fewerMore { display: none;}
</style>
<apex:form >
 <apex:pageMessages />
 <apex:detail relatedList="true"></apex:detail>
<apex:pageblock id="CustomList" title="Related Tasks"  >
   <apex:pageBlockTable value="{!task}" var="t" rendered="{!NOT(ISNULL(task))}">
        <apex:column value="{!t.EarliestDate__c}"/>
        <apex:column value="{!t.DeadlineDate__c}"/>
        <apex:column value="{!t.ActualDate__c}"/>
       <apex:column value="{!t.Type}"></apex:column>
       <apex:column value="{!t.Owner}"/>
   </apex:pageBlockTable>
   <apex:outputLabel value="No records to display" rendered="{!(ISNULL(task))}" styleClass="noRowsHeader"></apex:outputLabel>
 </apex:pageblock>
</apex:form>
</apex:page>



 
  • January 23, 2017
  • Like
  • 1
Hello,

We have a visualforce page called Safesend Returns in a Lightning tab. When we hit save it redirects to the Details tab. Is there a way to make the visualforce page stay in the Safesend Returns tab after save?

User-added image


Visualforce Page
<apex:page standardController="Account" lightningStylesheets="true">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="2">
            


<apex:outputField value="{!Account.TaxSoftware__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Est_of_tax_returns__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Demo__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1040s__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Total_Revenue__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1041s__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Opportunity_Date__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1120__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Original_Purchase_Date__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1120S__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Client_Status__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.of_1065s__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.SSR_Next_Steps__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

<apex:outputField value="{!Account.Verified_of_Returns__c}">  
<apex:inlineEditSupport event="ondblclick" /> 
</apex:outputField>

            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
  • July 30, 2019
  • Like
  • 0
Hello Developers!

I need help merging the two (2) triggers below into one (1) trigger. Any assistance is greatly appreciated. Thank you!

Trigger 1:
Trigger OpptyProducts_Spring on Opportunity (before update) {

list<opportunity> sl = trigger.new;

list<opportunityLineItem> slnu = new list<opportunityLineItem>([select id ,product2.name, opportunityId from opportunitylineitem where IsSpring__c = TRUE AND  opportunityId =: trigger.new[0].id]);

string productName='';

for(opportunityLineItem opp : slnu){

 productName += opp.product2.name + '\n'; // + operator for concatenation.

}

for(Opportunity opp : trigger.new){

 opp.Spring_Products__c = productName;


}


}

Trigger 2:
Trigger OpptyProducts_Fall on Opportunity (before update) {

list<opportunity> sl = trigger.new;

list<opportunityLineItem> slnu = new list<opportunityLineItem>([select id ,product2.name, opportunityId from opportunitylineitem where IsFall__c = TRUE AND  opportunityId =: trigger.new[0].id]);

string productName='';

for(opportunityLineItem opp : slnu){

 productName += opp.product2.name + '\n'; 

}

for(Opportunity opp : trigger.new){

 opp.Fall_Products__c = productName;


}


}

 
  • June 27, 2019
  • Like
  • 0
Hello,

I'm getting the error below.

Error: Compile Error: Constructor not defined: [ApexPages.StandardSetController].<Constructor>(Login_Information_Object__c) at line 22 column 46

for the Test Class below. The Test Class is for a Visualforce Page controller. Any assistance is greatly appreciated.
 
@isTest
public class VFTSIAITSplashPageController_UT {

    
    static testMethod void myTest() {
        Login_Information_Object__c lio=new Login_Information_Object__c();
       
        lio.LIO_Content__c='test';
        lio.LIO_End_Date__c=Date.today() + 30;
        lio.LIO_Start_Date__c=Date.today() + 1;
        lio.Show_On_Login__c=TRUE;
        lio.Subject__c='testing';
        insert lio;   
        
        PageReference pageRef1 = Page.TSIAInformationSplashPage;
        Test.setCurrentPage(pageRef1);
        pageRef1.getParameters().put('id',lio.Id);

        ApexPages.StandardSetController sc = new ApexPages.StandardSetController(lio);
        VFTSIAITSplashPageController testlio = new VFTSIAITSplashPageController (sc);
        
        testlio.save();    
 
        
        
    }
}

 
  • June 12, 2019
  • Like
  • 0
Hello,

I need the trigger below to only find the duplicate record if the Status__c is 'Active' on both records. Status__c is a picklist field. Any assistance is greatly appreciated!
trigger DuplicateExecutiveContact on Committee_Board_Member__c (before insert. before update) {
        for(Committee_Board_Member__c c:Trigger.new)
        {
      
            List<Committee_Board_Member__c> comm=[select ID from Committee_Board_Member__c where Account__c=:c.Account__c and Committee_Board__c=:c.Committee_Board__c and Service_Discipline__c=:c.Service_Discipline__c and Status__c=:c.Status__c];
            if(comm.size()>0)
            {
                c.adderror('Duplicate Record');
            }
        }
    }

 
  • April 09, 2019
  • Like
  • 0
Hello,

I have the trigger below thats retrieving the FeedItem File ID but I need it to only retrieve the file ID from files that have the word "SOW" in the file name. Any assistance is greatly appreciated.
 
trigger FeedItemIDOppty on FeedItem (after insert, after update) {
List<Opportunity> O = [select id, File_ID__c from Opportunity where id =: Trigger.new[0].ParentId];
        for(FeedItem fi : trigger.new){
    FeedItem fiii =[SELECT Body, (SELECT RecordId, Title, Type, Value FROM FeedAttachments) 
FROM FeedItem 
WHERE Id =: fi.Id];
        
        O[0].File_ID__c=fiii.FeedAttachments[0].Id ; 
        update O ;
        
        }
   

   }

 
  • March 01, 2019
  • Like
  • 0
Hello,

I have the trigger below that is retreving the FeedItem ID but I need it to retrieve the File ID when a file is attached to the feed. Any assistancw will be greatly appreciated.

 
trigger FeedItemIDOppty on FeedItem (before insert,after insert, before update,after update) {
List<Opportunity> O = [select id, File_ID__c from Opportunity where id =: Trigger.new[0].ParentId];
        for(FeedItem fi : trigger.new)
        if(O.size()>0)
            O[0].File_ID__c = fi.ID;
                                    update O;
                        }


 
  • February 22, 2019
  • Like
  • 0
Hi All,

I have a apex controller that I need to deploy into our production org. The current test class is only covering 40%. Any assistance is increasing the coverage for the controller below is much appreciated. Controller and test class below - thank you!!

Controller
public class AnnualTouchpointPlanningController {

    Public List<Task> TaskList{get;set;}
   // public String contId{get;set;} 
   // public String dcid{get;set;}
   // public task task{get;set;}
   // Public string editid{get;set;} 
    public opportunity oo;
  //      public Id selectedDetailID { get;set; }

    
    String currentRecordId ; 
    public AnnualTouchpointPlanningController(ApexPages.StandardController controller) {
       
        
        currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
       
     TaskList = [Select subject,id, Type, EarliestDate__c,Who.Type,whatID,priority,status,ActivityDate,ATP_Task__c,Completion_Date__c,Task_Record__c FROM Task WHERE Whatid=:currentRecordId and ATP_Task__c=true ];
     
    
     
     if(TaskList.size() == 0)
{
    Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No ATP Tasks to Display'));
   } 
 }
 
 public pagereference saveProject(){
 

  system.debug('ssssss'+TaskList );
    
    upsert TaskList ; // the LIST
  
     PageReference pageRef = new PageReference('/apex/AnnualTouchpointPlanning');
    pageRef.setRedirect(true);
    return null;
}    
     
    public PageReference save()
    {
        upsert TaskList ;
        
        return new PageReference('/apex/AnnualTouchpointPlanning');
    }  
     
     
       public pagereference deleteCon() {
       String s1 = System.CurrentPageReference().getParameters().get('dtlIdParam');
       task t=[ select id,status From task Where id=:s1];
       t.status= 'completed';
       upsert t;
       PageReference pageRef = new PageReference('/apex/AnnualTouchpointPlanning');
       pageRef.setRedirect(true);
       return null;
   } 
    
 
   
   
}
Test Class
@isTest
public class AnnualTouchpointPlanningController_UT {

    
    static testMethod void myTest() {
        Account a=new Account();
        a.Name='test';
        a.Type='Member';
        a.Major_Market__c='Other';
        a.AnnualRevenue=1000;
        a.Member_Services_Representative__c='00550000006Rkqu';
        insert a;       
 
        Service_Discipline__c sd=new Service_Discipline__c();
        sd.Name='sd test';
        sd.Service_Discipline_Acronym__c='test acc';
        insert sd;
           
        Opportunity opp=new Opportunity();
        opp.AccountID=a.Id;
        opp.Name='test';
        opp.Type='New';
        opp.Subscription_Start_Date__c = Date.today() + 1;
        opp.First_Service_Discipline__c=sd.Id;
        opp.Subscription_Expiration_Date__c = Date.today() + 30;
        opp.RecordTypeId='01250000000HjVK';
        opp.Deal_Status__c='Budget Approved';
        opp.StageName='PC - Pre-Contact';
        opp.CloseDate= Date.today() + 45;
        opp.Amount = 500;
        insert opp;
        
        Task tsk = new Task();
        tsk.WhatId = opp.Id;
        tsk.Subject = 'Test Subject';
        tsk.Status = 'Completed';
        tsk.ATP_Task__c = true;
        tsk.Type = 'Vision & Strategy Call (180)';
        tsk.Priority = 'Normal'; 
        tsk.ActivityDate = Date.today() + 30;
        insert tsk;
        delete tsk;
        
     
        
        PageReference pageRef = Page.AnnualTouchpointPlanning;
        Test.setCurrentPage(pageRef);
        pageRef.getParameters().put('id',opp.Id);


        ApexPages.StandardController sc = new ApexPages.StandardController(tsk);
        AnnualTouchpointPlanningController testAccPlan = new AnnualTouchpointPlanningController(sc);
        
        testAccPlan.save();
       
       //testAccPlan.deleteCon();
        
    
      //  testAccPlan.
         
        
        
    }
}

 
  • March 02, 2018
  • Like
  • 0
Hello,

I need help with the apex trigger below. I need this trigger to only fire for Opportunity RecordTypeId '01250000000HjVU'

Any assistance is greatly appreciated!!
 
trigger AttendeesHandling on Opportunity (after insert,after delete,after update) {

list<Id> rlist1=new list<Id> ();
        list<Product2 > rlsit=new list<Product2>();
        
//////////// insert and update operation
        
 if(trigger.isinsert || trigger.isupdate){
    for(Opportunity o : trigger.new)
   
    {
        
        rlist1.add(o.Discount_code_LU__c);     
    }
 
  Product2 p2=[select id,Attendees__c from Product2 WHERE id in:rlist1];
    
  
  for(Opportunity opp:trigger.new){
   
   p2.Attendees__c=opp.Attendee_Name__c ;
  

   rlsit.add(p2);
    } update rlsit; 
    
  }
   
 /////////////// Delete operation start   
 
    if(trigger.isdelete){
    for(Opportunity o : trigger.old)
   
        
    {
        
        rlist1.add(o.Discount_code_LU__c );     
    }

  Product2 p2=[select id,Attendees__c from Product2 WHERE id in:rlist1 LIMIT 1];
    
  
  for(Opportunity opp:trigger.old){
   
   p2.Attendees__c=opp.Attendee_Name__c ;
 
   rlsit.add(p2);
    } update rlsit; 
    
    }
}

 
  • December 01, 2017
  • Like
  • 0
I need the trigger below to activate only if the opportunity is RecordType "Conference". Any assistance is greatly apprecitated!

 
trigger RollUpOpportunity on Opportunity (after insert,after update, after delete,after undelete) {
    
    List<id> ParentIds = new List<id>();
    if(Trigger.isInsert || Trigger.isUndelete || Trigger.isupdate){
        For(Opportunity Opp : Trigger.new){
            ParentIds.add(Opp.Discount_code_LU__c);
        }
    }
    if(Trigger.isDelete){
        For(Opportunity Opp : Trigger.old){
            ParentIds.add(Opp.Discount_code_LU__c);
        }
    }
    List<Product2> ProductsToUpdate = new List<Product2>();
    decimal sum = 0;
    if(Trigger.isInsert || Trigger.isUndelete || Trigger.isupdate|| trigger.isdelete){
        For(Product2 q : [SELECT Related_Conference_Opportunities__c ,(SELECT id FROM Opportunities__r WHERE Voucher_Canceled__c = False)
         FROM Product2 WHERE id =: ParentIds]){
            sum = 0;
            for(Opportunity p : q.Opportunities__r){
                
                   sum = sum + 1;
            }
            q.Related_Conference_Opportunities__c = sum;
            ProductsToUpdate.add(q);
        }
        try{
            update ProductsToUpdate;
        }Catch(Exception e){
            System.debug('Exception :'+e.getMessage());
        }
    }
}


 
  • November 02, 2017
  • Like
  • 0
Hello,

I have the Apex Trigger below the checkmarks the Has_Attachement__c field on the Case record when there in an attachement on the case BUT I'm only getting 50% code coverage with the Test Class below. I need help from the community to assist me on increasing the code coverage so that I can deploy the trigger into production. Any assistance is greatly appreciated, thank you!

Apex Trigger 
trigger CaseHasAttachement on Attachment (after insert) {
            {
                        List<Case> cs = [select id, Has_Attachment__c from Case where id =: Trigger.New[0].ParentId];
                        if(cs.size()>0)
                        {
                                    cs[0].Has_Attachment__c = true;
                                    update cs;
                        }                                                                   
            }
            }

Test Class
@isTest
public class CaseHasAttachement_UT {

    
    static testMethod void myTest() {
    
            Account a=new Account();
        a.Name='test';
        a.Type='Member';
        a.Major_Market__c='Other';
        a.AnnualRevenue=1000;
        insert a;  
        
        Contact c=new Contact();
        c.RecordTypeID='01250000000HdFN';
        c.FirstName='ferasfd';
        c.LastName='testeringglowoski';
        c.phone='123456';
        c.AccountId=a.id;
        c.Level_in_Account__c='VP';
        c.Primary_Job_Function__c='Unknown';
        c.LeadSource='Sales';
        insert c;
        
        Case testCase = TestDataUtils.createCase(false);
        testCase.ContactId = c.id;
        testCase.AccountId = a.id;
        testCase.Web_Primary_Service_Discipline__c = 'Field Services';
        testCase.Type = 'Research Inquiry';
        testCase.Has_Attachment__c = FALSE;
        insert testCase;
    
        Attachment attach=new Attachment(); 
        attach.Name='Unit Test Attachment'; 
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body'); 
        attach.body=bodyBlob; 
        attach.parentId=a.Id; 
        attach.ContentType = 'application/msword'; 
        attach.IsPrivate = false; 
        attach.Description = 'Test'; 
        insert attach; 
        System.debug('Inserted: '+ attach.Id); 
        
    }
}

 
  • September 24, 2017
  • Like
  • 0
Hello Developers!

I need assistance with my Apex Class. I'm getting the error below for the Apex Class below. Any assistance will be gladly appreciated!

Error: Compile Error: Didn't understand relationship 'Products__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 16 column 6
 
public class StockroomConfVouchersController {

    Public List<Product2> Product2List{get;set;}
    public String contId{get;set;} 
    public String dcid{get;set;}
    public Product2 Product2Obj{get;set;}
    Public string editid{get;set;} 
    public Stockroom__c S {get;set;}
        public Id selectedDetailID { get;set; }

    
    String currentRecordId ; 
    public StockroomConfVouchersController (ApexPages.StandardController controller) {
    
   currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
   S=[SELECT ID,Name,(SELECT ID,Name,Balance__c,Capacity__c,UsedNEW__c,IsActive,Start_Date__c,End_Date__c, Status__c FROM Products__r WHERE Status__c = 'Active') FROM Stockroom__c WHERE ID=:currentRecordId ];
     
     
     
     
        system.debug('ssssssssss'+Product2List);
        system.debug('uuuuu'+currentRecordId );

     
   if(S==null)
   {
    Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No Confernce Vouchers to Display'));
   } 
 }
 

     
    public PageReference save()
    {
    system.debug('sssssssssssssuuuu'+S);
        upsert S.Products__r;
        
    PageReference pageRef = new PageReference('/apex/StockroomConfVouchers');
    pageRef.setRedirect(true);
    return null;    }  
     
     
       public pagereference deleteCon() {
       String s1 = System.CurrentPageReference().getParameters().get('dtlIdParam');
       Product2 p=[ select id,IsActive From Product2 Where id=:s1];
       p.IsActive = false;
      
       upsert p;
       PageReference pageRef = new PageReference('/apex/StockroomConfVouchers');
       pageRef.setRedirect(true);
       return null;
   } 
    
 
   
   
}ß

 
  • April 13, 2017
  • Like
  • 0
Hello Developers,

I have the trigger below that counts the number of Opportunities that are assigned to the Account and displays them on the Contact redord. I need this trigger to only count the Opportunities that the Contact is assigned to via the Opportunity Contact Role and the field in the Opportunity called STS Currently Engaged is TRUE. Any assistance will be greatly appreciated!!
trigger RollUpSTSOpportunity on Opportunity (after delete, after insert, after update) 
{
    set<Id> setAccountIds = new set<Id>();
    map<Id, Integer> mapAccountToOpp = new map<Id, Integer>();
    List<Contact> lstContactUpdate = new List<Contact>();
    
    if(trigger.isInsert || trigger.isUpdate)
    {
        for(Opportunity o : trigger.new)
        {
            setAccountIds.add(o.AccountId); // take all the related Account Id's in a set from trigger.new in case of insert/update
        }
    }
    else
    {
        for(Opportunity o : trigger.old)
        {
            setAccountIds.add(o.AccountId); // take all the related Account Id's in a set from trigger.old in case of delete
        }
    }
    
    for(Account a : [Select Id, (Select Id From Opportunities) From Account Where Id In :setAccountIds])
    {
        mapAccountToOpp.put(a.Id, a.Opportunities.size()); // add each account id with the number of opportunities related to it
    }
    
    for(Contact c : [Select Id, AccountId, Related_STS_Opportunities__c  From Contact Where AccountId In :mapAccountToOpp.keySet()])
    {
        c.Related_STS_Opportunities__c  = mapAccountToOpp.get(c.AccountId);  // from the contact, we can get the number of opp related to it's parent account
        lstContactUpdate.add(c);
    }
    
    if(lstContactUpdate.size() > 0)
        update lstContactUpdate; // update the contacts
}

 
  • February 13, 2017
  • Like
  • 0
Hello Developers!

I have been working on a trigger that needs to count the number of related "conference" Opportunities that are associated with a Product voucher. This allows tracking of Product vouchers of a particular conference. Basically I need to count the number of Opportunities (ConferenceOppty = TRUE) that are associated with the Product (Product2).

The rollup count field is in the Product object and it's called "Related_Conference_Opportunities__c." 

Any assistance will be greatly appreciated!
trigger RelatedVoucherOpportunity on Product2 (after insert, after update, after delete, after undelete) {
  
  Set<Id> oppIds = new Set<Id>();
 
  Map<Id,Opportunity> oppRecords = new Map<Id,Opportunity>();
  
  for(Product2 p2:Trigger.isDelete?Trigger.old:Trigger.new)
    oppIds.add(p2.oppIds);
 
  oppIds.remove(null);

  for(Id oppId:oppIds)
    oppRecords.put(oppId,new Opportunity(Id=oppId,ConferenceOppty__c = TRUE));
 
  for(Product2 c:[select id,Related_Conference_Opportunities__c from Product2 where id in :oppIds])
    oppRecords.get(p2.oppIds).ConferenceOppty__c += p2.Related_Conference_Opportunities__c;
  
  Database.update(oppRecords.values());
}

 
  • February 08, 2017
  • Like
  • 0