• Eelco Litjens
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Salesforce Administrator
  • Twinfield international


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 23
    Replies
i edited 2 triggers for my org. i tried to deploy them to production, but got code coverage error.
Is ther anybody who can help me with writing a test class for them. I must confess i don't get how to write that..

the first trigger: 
	trigger updateQuoteLine1 on QuoteLineItem (before insert,before update) {

    string vMenuinformation;
    string vOptyId;
    string vPricebookEntryId;
    string vQuote;
 
    for(QuoteLineItem quoteLine : Trigger.new){
           
        vOptyId = quoteLine.OpportunityId__c;
        vPricebookEntryId = quoteLine.PricebookEntryId;
        
        for(OpportunityLineItem oppLine : [select Id, Menu_chart_Product_description__c from OpportunityLineItem where (OpportunityId = :vOptyId and PricebookEntryId = :vPricebookEntryId)]){
            vMenuinformation = oppLine.Menu_chart_Product_description__c;
        }
        
        quoteLine.Menu_chart_description__c = vMenuinformation;
   
    }
}

Second: 
trigger updateQuoteLine on OpportunityLineItem (after insert,after update) {

    string vMenuinformation;
    //string vOptyId;
    string vPricebookEntryId;
    string vQuoteId;
 
    for(OpportunityLineItem oppLine : Trigger.new){
    
        vMenuinformation = oppLine.Menu_chart_Product_description__c;
        //vOptyId = oppLine.OpportunityId;
        vPricebookEntryId = oppLine.PricebookEntryId;
        vQuoteId = oppLine.QuoteId__c;
    }
    for(QuoteLineItem quoteLine : [select Id from QuoteLineItem where (QuoteId = :vQuoteId and PricebookEntryId = :vPricebookEntryId)]){
        quoteLine.Menu_chart_description__c = vMenuinformation;
        update(quoteLine);
    }
    
}
I would like to auto-select a checkbox .....i am not so well known with code.
is this something i can use?  How must i write this?
<apex:actionFunction value="{!item.Alert_SMS_sent__c}" immediate="true" />

 
Hi, i was reading this question: https://developer.salesforce.com/forums/?id=906F000000094QPIAY 
and thought i might change the used field to my own field, and give it a go, but it doesn't work.
Should i change something to the recordtypes etc?
i want this for 1 recordtype.
Is there anybody that can help me?
trigger opportunityLineItemsQuantity on Opportunity (after update) {
    //Get list of record types from Opportunity
    list<RecordType> rTypes = [Select Name, Id from RecordType Where SObjectType= 'Opportunity'];
    
    //Create a Map for the Opportunity record types
    Map<String,Id> OppRecordTypes = new Map<String, Id>{};
    for(RecordType rt: rtypes)
    OppRecordTypes.put(rt.Name,rt.Id);
       
    //Create a map for Opportunity records
    //Map<String, Decimal> oppList = new Map<String, Decimal>{};
    Map<ID, Opportunity> oppList = new Map<ID, Opportunity>();
    
    //Iterate through the Opportunities
    for(Opportunity opp : Trigger.New)  
    if(opp.RecordTypeId == OppRecordTypes.get('Consultancy')){
    if(Opp.Consultinghours_spent2__c != Null){
    //oppList.put(opp.Id,Opp.Consultinghours_spent2__c);
     oppList.put(opp.Id,Opp);
    }
    }
     list<OpportunityLineItem> listOfOpportunityLineItems = new list<OpportunityLineItem>();
    //Get Opportunity Line Items that are associated to the Opportunity
    for(OpportunityLineItem oli :  [Select OpportunityId, Quantity From OpportunityLineItem Where OpportunityId In : oppList.keyset()]){
   //This is where the code is failing. This is where I want the OpportunityLineItem Quantity to be the same as the Opportunity Expected_Number_Of_Sudents__c value.

    //oli.Quantity = oppList.get(oppList.Expected_Number_Of_Students__c);
    Opportunity OppObj = oppList.get(oli.OpportunityId);
       if(OppObj != NUll){
           oli.Quantity = OppObj.Consultinghours_spent2__c;
       }
       listOfOpportunityLineItems.add(oli);
    }
    Update listOfOpportunityLineItems;

}

 
Hi all,
we have had devlopment done for us, but not anymore, and i'm trying to change a VF page and controller to lookup a training participant based upon his/her email address.
What do i have to change to search on email instead of D-Number. can anyone help me out?
the controller i have now is:

"
public class TrainingController {

   String searchText;
   List<Deelnemer_Evenement_Training__c> results;

   public String getSearchText() {
      return searchText;
   }

   public void setSearchText(String s) {
      searchText = s;
   }

   public List<Deelnemer_Evenement_Training__c> getResults() {
      return results;
   }

   public PageReference doSearch() {
      results = (List<Deelnemer_Evenement_Training__c>)[FIND :searchText RETURNING Deelnemer_Evenement_Training__c(First_name__c, Last_name__c, E_mail_deelnemer__c, Evenement_Trainings_sessie__c)][0];
      return null;
   }
   
public String participantId {get; set;}
    public boolean reset {get; set;}
    public boolean alreadyAttending {get; set;}
    public boolean UpdateError {get; set;}
    public boolean Updated {get; set;}
    public Deelnemer_Evenement_Training__c participantion {get; set;}
    
    
    public TrainingController(){
        reset = false;
        alreadyAttending = false; 
        Updated = false;
        UpdateError = false; 
        participantId = '';
    }
    
    public pageReference getRegistration ()
    {
        reset = true;
        Updated = false;
        string participantIdSQL  = 'D-'+participantId;
        alreadyAttending = false; 
        participantion = new Deelnemer_Evenement_Training__c();
        try{
            participantion = [SELECT /*Event / Trainings session */  
                              Evenement_Trainings_sessie__r.name, 
                              Evenement_Trainings_sessie__r.Startdatum__c, /*start Date*/
                              Evenement_Trainings_sessie__r.Aantal_inschrijvingen__c, /*num inscrições*/
                              /* Participant */  
                              Deelnemer__r.Name,
                              Deelnemer__r.Email,
                              Deelnemer__r.Account.name,
                              /* Participantion */
                              Aanwezig_tijdens_sessie__c     
                              FROM Deelnemer_Evenement_Training__c
                              WHERE Name = :participantIdSQL];
                              
            if(participantion.Aanwezig_tijdens_sessie__c == 'Ja') 
            {
               alreadyAttending = true; 
            }
        } catch (Exception e) {
             participantion = null;
        }
        return null;                  
    }
    
    public pageReference Present()
    {
        participantion.Aanwezig_tijdens_sessie__c = 'Ja';
        try{
            update(participantion);
            Updated = true;
        } catch (Exception e) {
             UpdateError = true;
        }
        return null;
    }
    
    public pageReference reset()
    {
        reset = false;
        Updated = false;
        alreadyAttending = false; 
        UpdateError = false; 
        participantId = '';
        participantion = null;
        return null;
    }
}
"
 
i edited 2 triggers for my org. i tried to deploy them to production, but got code coverage error.
Is ther anybody who can help me with writing a test class for them. I must confess i don't get how to write that..

the first trigger: 
	trigger updateQuoteLine1 on QuoteLineItem (before insert,before update) {

    string vMenuinformation;
    string vOptyId;
    string vPricebookEntryId;
    string vQuote;
 
    for(QuoteLineItem quoteLine : Trigger.new){
           
        vOptyId = quoteLine.OpportunityId__c;
        vPricebookEntryId = quoteLine.PricebookEntryId;
        
        for(OpportunityLineItem oppLine : [select Id, Menu_chart_Product_description__c from OpportunityLineItem where (OpportunityId = :vOptyId and PricebookEntryId = :vPricebookEntryId)]){
            vMenuinformation = oppLine.Menu_chart_Product_description__c;
        }
        
        quoteLine.Menu_chart_description__c = vMenuinformation;
   
    }
}

Second: 
trigger updateQuoteLine on OpportunityLineItem (after insert,after update) {

    string vMenuinformation;
    //string vOptyId;
    string vPricebookEntryId;
    string vQuoteId;
 
    for(OpportunityLineItem oppLine : Trigger.new){
    
        vMenuinformation = oppLine.Menu_chart_Product_description__c;
        //vOptyId = oppLine.OpportunityId;
        vPricebookEntryId = oppLine.PricebookEntryId;
        vQuoteId = oppLine.QuoteId__c;
    }
    for(QuoteLineItem quoteLine : [select Id from QuoteLineItem where (QuoteId = :vQuoteId and PricebookEntryId = :vPricebookEntryId)]){
        quoteLine.Menu_chart_description__c = vMenuinformation;
        update(quoteLine);
    }
    
}
I would like to auto-select a checkbox .....i am not so well known with code.
is this something i can use?  How must i write this?
<apex:actionFunction value="{!item.Alert_SMS_sent__c}" immediate="true" />

 
Hi, i was reading this question: https://developer.salesforce.com/forums/?id=906F000000094QPIAY 
and thought i might change the used field to my own field, and give it a go, but it doesn't work.
Should i change something to the recordtypes etc?
i want this for 1 recordtype.
Is there anybody that can help me?
trigger opportunityLineItemsQuantity on Opportunity (after update) {
    //Get list of record types from Opportunity
    list<RecordType> rTypes = [Select Name, Id from RecordType Where SObjectType= 'Opportunity'];
    
    //Create a Map for the Opportunity record types
    Map<String,Id> OppRecordTypes = new Map<String, Id>{};
    for(RecordType rt: rtypes)
    OppRecordTypes.put(rt.Name,rt.Id);
       
    //Create a map for Opportunity records
    //Map<String, Decimal> oppList = new Map<String, Decimal>{};
    Map<ID, Opportunity> oppList = new Map<ID, Opportunity>();
    
    //Iterate through the Opportunities
    for(Opportunity opp : Trigger.New)  
    if(opp.RecordTypeId == OppRecordTypes.get('Consultancy')){
    if(Opp.Consultinghours_spent2__c != Null){
    //oppList.put(opp.Id,Opp.Consultinghours_spent2__c);
     oppList.put(opp.Id,Opp);
    }
    }
     list<OpportunityLineItem> listOfOpportunityLineItems = new list<OpportunityLineItem>();
    //Get Opportunity Line Items that are associated to the Opportunity
    for(OpportunityLineItem oli :  [Select OpportunityId, Quantity From OpportunityLineItem Where OpportunityId In : oppList.keyset()]){
   //This is where the code is failing. This is where I want the OpportunityLineItem Quantity to be the same as the Opportunity Expected_Number_Of_Sudents__c value.

    //oli.Quantity = oppList.get(oppList.Expected_Number_Of_Students__c);
    Opportunity OppObj = oppList.get(oli.OpportunityId);
       if(OppObj != NUll){
           oli.Quantity = OppObj.Consultinghours_spent2__c;
       }
       listOfOpportunityLineItems.add(oli);
    }
    Update listOfOpportunityLineItems;

}

 
Hi all,
we have had devlopment done for us, but not anymore, and i'm trying to change a VF page and controller to lookup a training participant based upon his/her email address.
What do i have to change to search on email instead of D-Number. can anyone help me out?
the controller i have now is:

"
public class TrainingController {

   String searchText;
   List<Deelnemer_Evenement_Training__c> results;

   public String getSearchText() {
      return searchText;
   }

   public void setSearchText(String s) {
      searchText = s;
   }

   public List<Deelnemer_Evenement_Training__c> getResults() {
      return results;
   }

   public PageReference doSearch() {
      results = (List<Deelnemer_Evenement_Training__c>)[FIND :searchText RETURNING Deelnemer_Evenement_Training__c(First_name__c, Last_name__c, E_mail_deelnemer__c, Evenement_Trainings_sessie__c)][0];
      return null;
   }
   
public String participantId {get; set;}
    public boolean reset {get; set;}
    public boolean alreadyAttending {get; set;}
    public boolean UpdateError {get; set;}
    public boolean Updated {get; set;}
    public Deelnemer_Evenement_Training__c participantion {get; set;}
    
    
    public TrainingController(){
        reset = false;
        alreadyAttending = false; 
        Updated = false;
        UpdateError = false; 
        participantId = '';
    }
    
    public pageReference getRegistration ()
    {
        reset = true;
        Updated = false;
        string participantIdSQL  = 'D-'+participantId;
        alreadyAttending = false; 
        participantion = new Deelnemer_Evenement_Training__c();
        try{
            participantion = [SELECT /*Event / Trainings session */  
                              Evenement_Trainings_sessie__r.name, 
                              Evenement_Trainings_sessie__r.Startdatum__c, /*start Date*/
                              Evenement_Trainings_sessie__r.Aantal_inschrijvingen__c, /*num inscrições*/
                              /* Participant */  
                              Deelnemer__r.Name,
                              Deelnemer__r.Email,
                              Deelnemer__r.Account.name,
                              /* Participantion */
                              Aanwezig_tijdens_sessie__c     
                              FROM Deelnemer_Evenement_Training__c
                              WHERE Name = :participantIdSQL];
                              
            if(participantion.Aanwezig_tijdens_sessie__c == 'Ja') 
            {
               alreadyAttending = true; 
            }
        } catch (Exception e) {
             participantion = null;
        }
        return null;                  
    }
    
    public pageReference Present()
    {
        participantion.Aanwezig_tijdens_sessie__c = 'Ja';
        try{
            update(participantion);
            Updated = true;
        } catch (Exception e) {
             UpdateError = true;
        }
        return null;
    }
    
    public pageReference reset()
    {
        reset = false;
        Updated = false;
        alreadyAttending = false; 
        UpdateError = false; 
        participantId = '';
        participantion = null;
        return null;
    }
}
"
 

Good Morning,

 

I am fairly new to apex and have been trying to create a Trigger that updates all OpportunityLineItem Quantity field to a specific value from a named Expected_Number_Of_Students__c on the related Opportunity.

 

I have got the following  compile error:

 

Error: Initial term of field expression must be a concrete SObject: MAP<String,Decimal> at line 23 column 32

 

The code is as follows.

 

trigger opportunityLineItemsQuantity on Opportunity (after update) {
    //Get list of record types from Opportunity
    list<RecordType> rTypes = [Select Name, Id from RecordType Where SObjectType= 'Opportunity'];
    
    //Create a Map for the Opportunity record types
    Map<String,Id> OppRecordTypes = new Map<String, Id>{};
    for(RecordType rt: rtypes)
    OppRecordTypes.put(rt.Name,rt.Id);
       
    //Create a map for Opportunity records
    Map<String, Decimal> oppList = new Map<String, Decimal>{};
    
    //Iterate through the Opportunities
    for(Opportunity opp : Trigger.New)  
    if(opp.RecordTypeId == OppRecordTypes.get('ELT Digital Products Opportunity')){
    if(Opp.Expected_Number_of_Students__c != Null){
    oppList.put(opp.Id,Opp.Expected_Number_Of_Students__c);
    }
    }

    //Get Opportunity Line Items that are associated to the Opportunity
    for(OpportunityLineItem oli :  [Select OpportunityId, Quantity From OpportunityLineItem Where OpportunityId In : oppList.keyset()]){
   //This is where the code is failing. This is where I want the OpportunityLineItem Quantity to be the same as the Opportunity Expected_Number_Of_Sudents__c value.

   oli.Quantity = oppList.get(oppList.Expected_Number_Of_Students__c);
    
    }

}

 

 

I am not sure how to resolve this on line 23 I would be very grateful for some guidance on this.

 

Thanks