• kirubakaran viswanathan
  • NEWBIE
  • 155 Points
  • Member since 2015

  • Chatter
    Feed
  • 4
    Best Answers
  • 1
    Likes Received
  • 3
    Likes Given
  • 11
    Questions
  • 41
    Replies
  1. trigger oppTr on Opportunity (after update,after insert){
  2.         
  3.     Map<Id,Opportunity> OppStage = new Map<Id,Opportunity>();
  4.     List<Account> AccList = new List<Account>();
  5.     
  6.     for(Opportunity opp : trigger.new){        
  7.         if(opp.StageName == 'Closed Lost' && trigger.oldMap.get(opp.Id).StageName == 'Closed Won'){
  8.            OppStage.put(opp.AccountId, opp);
  9.         }
  10.     }
  11.     System.debug('OppStage'+OppStage);
  12.    try {            
  13.    if(OppStage.size()>0){
  14.        System.debug('OppStage'+OppStage.size());
  15.         for(Opportunity opp2 : OppStage.values()){
  16.            System.debug('opp2'+opp2);
  17.            Account acc = new Account();
  18.            acc.Id = opp2.AccountId;
  19.            acc.Status__c = 'Lost';
  20.            AccList.add(acc);
  21.            System.debug('AccList'+acc.Status__c);
  22.         } 
  23.        update AccList;
  24.        System.debug('AccList'+AccList);
  25.     } 
  26.    } catch (System.NullPointerException e){
  27.      String s;
  28.         s.toLowerCase();
  29.    }   
  30.  
  31. }
Hi,

I am using the following snippet in a Test Class. When I copy it in Developer Console, it works just fine ! But in the test class, the size of pbe list is zero !
List<PriceBookEntry> pbe = new List<PriceBookEntry>( );
    pbe = [Select Id,Name,PriceBook2ID, Product2Id from PriceBookEntry where ProductCode = 'NRG-HF-89-C0' and CURRENCYISOCODE='USD'];

System.Debug(pbe.size());
Opportunity o= new Opportunity(Name = 'Test Opportunity', StageName = 'Drop In', CloseDate = system.today() + 30);
        insert o;
        Quote q= new Quote(Name = 'Test Quote', Status = 'Draft', OpportunityId = o.Id, Pricebook2Id=pbe[0].PriceBook2Id);
        insert q;
        QuoteLineItem qli= new QuoteLineItem (Quantity=1, QuoteId=q.Id,UnitPrice=100.00, Discount = 50, PriceBookEntryId = pbe[0].Id, Product2Id=pbe[0].Product2Id);
        
        insert qli;
        System.assertNotEquals(null,q); 
        
          
        // Retrieve the create quote line item
        qli = [SELECT Id,TotalPrice,Discount,Discount_Amount__c FROM QuoteLineItem WHERE Id =:qli.Id];  
    
        System.assertEquals(50,qli.Discount_Amount__c);
        
        qli.Discount = 25;
        
        update qli;
        
        // Retrieve the create quote line item
        qli = [SELECT Id,TotalPrice,Discount,Discount_Amount__c FROM QuoteLineItem WHERE Id =:qli.Id];  
    
        System.assertEquals(25,qli.Discount_Amount__c);

delete o;

Thanks !
Hey Everyone,
New to APEX here and I'm trying to update records on the same Object which the Before Update and Before Insert trigger is fired.
Basically, I have a Communication Method object which stores email addresses.  When an email address is stored or updated with the same type (Work, Personal, Other) and it is marked as as Roll Up = true, any records with the same type associated with the Contact should be updated with Roll Up = false.  I'm using this Roll Up field to roll these values up to the Contact to three specific fields (Not covered in this code).
I wrote the following:
trigger ComMethRollup on Communication_Method__c (after insert, after update) {

    if(checkRecursive.runOnce())
    {
//Pull together List of Object Records 
    List<Communication_Method__c> allComMeth = new List <Communication_Method__c>();
    for (Communication_Method__c newComMeth: Trigger.new) {
//Query for Parent Contact and fields associated with Communication Method Record
	List<Contact> conList = [SELECT Home_Email__c,Other_Email__c,Work_Email__c from Contact WHERE Id = :newComMeth.Name__c];
	Contact assoContact = conList.get(0);
//Query for all Communication Method Records associated with the Contact with same type
	List<Communication_Method__c> assoMeth = [SELECT Id,Email__c,Roll_Up__c,Type__c from Communication_Method__c WHERE Name__c = :assoContact.ID AND Type__c = :newComMeth.Type__c];
        for (Communication_Method__c c: assoMeth)
//Check if new Communication Method record has rollup checked
        if (newComMeth.Roll_Up__c = TRUE) {
            c.Roll_Up__c = FALSE;
        	}
         UPDATE assoMeth;   
   		}
    
	}
}

and then got a dreaded
 Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger ComMethRollup caused an unexpected exception, contact your administrator: ComMethRollup: execution of AfterInsert caused by: System.FinalException: Record is read-only: Trigger.ComMethRollup: line 15, column 1

I then found an article (https://help.salesforce.com/HTViewSolution?id=000133752&language=en_US) to create a Static Boolean check class and refer to this at the start of my trigger.
I did do this, but am getting the same error.
Any help would be appreciated.
Thanks!
Hello all, I have the following code to roll-up summary products name to an opportunity text-long field, I need a summary of purchased products separated by commas.
Everything runs good with no errors, however I get no results, nothing happens, can you please take a look and help me?

Trigger:
trigger OppProductsTrigger on OpportunityLineItem (after delete, after insert, after update) {

    // fires after both insert and update
    if((Trigger.isInsert || Trigger.isUpdate) && Trigger.isAfter){

      // find the ids of all opps that were affected
      Set<Id> oppIds = new Set<Id>();
      for (OpportunityLineItem ar : [select Id, name, OpportunityId from OpportunityLineItem 
        where Id IN :Trigger.newMap.keySet()])
        oppIds.add(ar.OpportunityId);

      // process the opps  
      OppProductsTriggerHandler.ProcessProductsAsync(oppIds);


    // fires when records are deleted. may want to do undelete also?
    } else if(Trigger.isDelete && Trigger.isAfter){

      // find the ids of all opps that were affected
      Set<Id> oppIds = new Set<Id>();
      for (ID id : Trigger.oldMap.keySet())
        oppIds.add(Trigger.oldMap.get(id).OpportunityId);

      // process the opps
      OppProductsTriggerHandler.ProcessProductsAsync(oppIds);

    }

  }

Class: 
public with sharing class OppProductsTriggerHandler {

  @future 
  public static void ProcessProductsAsync(Set<ID> oppIds){

    // holds a map of the opp id and comma separated products to build
    Map<Id, String> oppProductMap = new Map<Id, String>();

    // get ALL of the products for all affected opps so we can build
    List<OpportunityLineItem> oppProducts = [select id, name, OpportunityId 
      from OpportunityLineItem 
      where OpportunityId IN :oppIds order by Name];

    for (OpportunityLineItem ar : oppProducts) {
      if (!oppProductMap.containsKey(ar.OpportunityId)) {
        // if the key (opp) doesn't exist, add it with product name
        oppProductMap.put(ar.OpportunityId,ar.Name);
      } else {
        // if the key (opp) already exist, add ", product-name"
        oppProductMap.put(ar.OpportunityId,oppProductMap.get(ar.OpportunityId) + 
          ', ' + ar.Name);
      }
    }

    // get the opps that were affected
    List<Opportunity> opps = [select id from Opportunity where Id IN :oppIds];

    // add the comma separated list of regions
    for (Opportunity a : opps)
      a.Products_Purchased__c = oppProductMap.get(a.id);

    // update the opps
    update opps;

  }  

}

Thank you!
Ron
I have the start and end DateTime field in Opportunity, I need to split that into date and time based on customers' country in the record.

Eg: UTC : 2021-04-26T09:00:00.000+0000

Country is UK
Output:
Date : 26-04-2021
Time : 10 AM

If the country is Germany
Output:
Date : 26-04-2021
Time : 11 AM
 
I need to override the list of recordtypes displaying in the selection panel when the user clicks the "New" button.
Ex: I have recordtype A, B, C in Opportunity, whenever the user clicks "New" the selection window need to display only A and B. But he should have access to C recordtype. Because I have another quick action button in the detail page to create records with C recordtype for the user. 
Is that possible to override the selection window to display specific record type?
For example, I have a text " Hello World", I need to use this text in the places in the VF page based on the Output render conditions at least 4-5 times in a page. I don't want to repeat this text hardcoded in the multiple places.

How can we achieve this without any extension/custom controller? Because in future I may need to change the text in Prod directly, rather than pushing the changes through Changeset.

P.S: I have really long text and I have multiple texts like this to be repeated.
I need to display the email id with link based on program name in a para. How can I acheive in VF?
<p class = "doc-preview__copy txindent">
               If you have any questions regarding your next steps, please contact the {!TargetX_SRMb__Application__c.Program_Name__c} 
               admissions team  
                <apex:outputText value="{!IF(app.Program_Name__c == "abc", <a href="mailto:abc@abc.com">abc@abc.com</a>.,a href="mailto:123@abc.com">123@abc.com</a>
                                        ')}" />
   </p>
I am getting syntax error or EL Expression unbalanced error.


 
Hi,
I need to read the email template content alone into the VF page, is that possible?
 
I have 2 objects (Contact and SLM) both has their AFTER triggers. On each triggers we have that recursive trigger logic which we set the static variable at the end to avoid the recurssion.

I have a  batch class, which is updating the contact record and update the SLM records in a single transaction.  While doing that operation, I see the after update trigger for Contact object is working good and at the end it set the Static variable to true. When the SLM update happens, I am not seeing the SLM trigger is executing, may be because the static variable is set as true. 

I need this recursive check in both objects trigger because we have lot other Workflow and process builder to  update both object.
How to handle this? any thoughts. Thanks
I tried to convert the lead through batch processing, which need to update the existing contact based on the contact id. But the value in the contact record is not overwritten with the Lead value.
Can anyone help on this? Even I set the setOverwriteLeadSource(true); 
for(Lead record: scope) {
            Database.LeadConvert lc = new Database.LeadConvert();
            lc.setLeadId(record.Id);
            lc.setConvertedStatus(convertedStatus);
            
            if(matchAcct.containsKey(record.company))
            {
                lc.setAccountID(matchAcct.get(record.company).id);
            }
            if(matchCont.containsKey(record.Email))
            {
                lc.setContactID(matchCont.get(record.Email).id);
            }
            
            lc.setDoNotCreateOpportunity(true);
            lc.setOverwriteLeadSource(true);
            converts.add(lc);
        }
        
        system.debug('ConvertsLeads:' +converts);
       // Database.LeadConvertResult lcr ;
       List<Database.LeadConvertResult> lcr = Database.convertLead(converts,false);

 
I am rendering the boolean value to the Outputfield, which displays as a checkbox (checked or not checked). But I need to increase the size of the checkbox for visibility
I tried below code,  with and without style attribute inside the Outputfield.
​<apex:column
<span style="height: 40px !important; width: 40px !important;">
<apex:outputField value="{!a.aAttendee.evt__Attended__c}" style="height: 40px !important; width: 40px !important;" />
</span>
                            
 </apex:column>

But still the checkbox display as a default size of 21 X 16.

User-added image
Can anyone help me to increase the size of the checkbox ?

Thanks,
Kiruba
whenever new application comes in from students, need to check whether student contact is already there or not, if yes then update the contact record with any new field value and create application related record to contact.
if no contact is present, then create new contact record and create a application related record.

We have application id as a external id, which is tagged to application related record. No external id is mapped to Contact.

Wrote some logic, but it is working for insert operation, but it is failing for update the contact record.
Can anyone suggest some workaround? Thanks.

public with sharing class ContactSLMCreateHelper {
    
    public static void createSLM(List<TY_Imports__c> Imports){     
        List<Admission__c> insertSLMList = new List<Admission__c>();
        Set<String> contactIds = new Set<String>();
        Map<String, Contact> contactsToInsert = new Map<String, Contact>();
        Map<String, Contact> contactsToUpdate = new Map<String, Contact>();
        List<Contact> con=[select Id,FirstName,LastName from Contact ];
        // Contact copied form TY import class
        for(TY_Imports__c TY : Imports) 
        {
            for(integer i=0; i < con.size();i++)
            {
                  if (con[i].FirstName ==TY.First_Name__c  && con[i].LastName==TY.Last_or_Family_Name__c) {
         
                     system.debug('updating the record');
                    Contact c = new Contact();
                       if (TY.Last_or_Family_Name__c!= null) {
                     c.LastName = TY.Last_or_Family_Name__c;
                    }     
                    else { 
                     c.LastName='No Last Name';
                         }  
                c.FirstName= TY.First_Name__c;
                c.GU_ID__c= TY.GUID__c;
                c.Ethnicity__c= TY.Ethnicity__c;
                contactsToupdate.put(TY.Applicant_Client_ID__c , c);
                }
               
         
                else{
                    system.debug('creating new record');
                    contact c = new Contact();
                    if (TY.Last_or_Family_Name__c!= null) {
                     c.LastName = TY.Last_or_Family_Name__c;
                    }     
                    else { 
                     c.LastName='No Last Name';
                         }  
                c.FirstName= TY.First_Name__c;
                c.GU_ID__c= TY.GUID__c;
                c.Ethnicity__c= TY.Ethnicity__c;
                contactsToInsert.put(TY.Applicant_Client_ID__c , c);
                    
                }
            }}
         System.debug('Testing for contact.') ;  
        if ( contactsToupdate.values()!= null )
        {
            System.debug('About to update Contact ' + contactsToupdate.values());
            update contactsToupdate.values(); 
            System.debug('AFTER update of contact Records');
        }
          if(contactsToinsert.values()!= null){
              System.debug('About to insert Contact ' + contactsToInsert.values());
             insert contactsToInsert.values(); 
              System.debug('AFTER insert of contact Records');
            }
        RecordType SLMRecordType;
        List<RecordType> SLMRecordTypes = [ select Id, Name, DeveloperName from RecordType where SObjectType = 'Admission__c' ];
        
        if ( SLMRecordTypes != null && SLMRecordTypes .size() > 0 )
        {
            SLMRecordType = SLMRecordTypes [0];        
        }
        else
        {
            SLMRecordType = new RecordType(id='01240000000UcwV');
        }
        
        for(TY_Imports__c TY : Imports) {
            if (TY.Applicant_Client_ID__c != NULL) {
                Admission__c adm = new Admission__c();
        
                adm.Applicant_Client_ID__c = TY.Applicant_Client_ID__c;
                adm.Age_at_Time_of_Enrollment__c = TY.Age_at_Time_of_Enrollment__c;
                adm.RecordTypeId = SLMRecordType.Id;
                adm.TY_Application_Term__c= TY.Application_Term__c;
                adm.TY_Admitted_Date__c= TY.TY_Admitted_Date__c;
                adm.TY_Enrolled_Date__c= TY.TY_Enrolled_Date__c;
                adm.Decision_Date__c = TY.Decision_Date__c;
                adm.Enrollment_Decision__c = TY.Enrollment_Decision__c;
                adm.Months_of_work_NEW__c= TY.Months_of_work_NEW__c;
                if (contactsToInsert.containsKey(TY.Applicant_Client_ID__c)) {
                adm.ContactLookUp__c= contactsToInsert.get(TY.Applicant_Client_ID__c).id;
                }
            insertSLMList.add(adm);
                 }   
            }
        System.debug('Testing for SML.') ;  
        if ( insertSLMList!= null )
        {
           if ( !Test.isRunningTest() )
            {
               System.debug('About to insert SLM. ' + insertSLMList);
               upsert insertSLMList Applicant_Client_ID__c ;  
               System.debug('AFTER insert of SLM Records');
            }
            else
            {
              try
              {
                upsert insertSLMList Applicant_Client_ID__c ; 
               }
              catch(Exception e)
              {
                System.debug(LoggingLevel.ERROR, '---> caught exception Upserting SLMList: ' + e.getMessage() );
               }
             }
           }
        }
    }

I have a text field, which has values in a table format. When I SOQL to retrieve the data from that field through Dataloader, I got the result as "</td></tr><tr height=""20""><td colspan=""1"" rowspan=""1"" height=""20"" style=""height: 20px;"">. how to solve?
Why my custom checkbox is always checked when I try to save as uncheck in the account object?

This is happening only when I have a active trigger. The trigger which I wrote is simple one to check whether that checkbox is "checked" or not, then copy the postal code from Billing address to shipping address. 

When that particular trigger is "Inactive" and tried to save the record with that checkbox as "unchecked" it is working good.
Not sure why this trigger is always "checked" the checkbox when I save the record.

This is my trigger:
Trigger AccountAddressTrigger on Account (before insert,before update) {
       for (Account a : Trigger.new)
   {
           if(a.Match_Billing_address__C = True)
       {
         if(a.BillingPostalCode != NULL)
               {
       a.ShippingPostalCode= a.BillingPostalCode;
                  } 
           }
   }
   
}
 
whenever new application comes in from students, need to check whether student contact is already there or not, if yes then update the contact record with any new field value and create application related record to contact.
if no contact is present, then create new contact record and create a application related record.

We have application id as a external id, which is tagged to application related record. No external id is mapped to Contact.

Wrote some logic, but it is working for insert operation, but it is failing for update the contact record.
Can anyone suggest some workaround? Thanks.

public with sharing class ContactSLMCreateHelper {
    
    public static void createSLM(List<TY_Imports__c> Imports){     
        List<Admission__c> insertSLMList = new List<Admission__c>();
        Set<String> contactIds = new Set<String>();
        Map<String, Contact> contactsToInsert = new Map<String, Contact>();
        Map<String, Contact> contactsToUpdate = new Map<String, Contact>();
        List<Contact> con=[select Id,FirstName,LastName from Contact ];
        // Contact copied form TY import class
        for(TY_Imports__c TY : Imports) 
        {
            for(integer i=0; i < con.size();i++)
            {
                  if (con[i].FirstName ==TY.First_Name__c  && con[i].LastName==TY.Last_or_Family_Name__c) {
         
                     system.debug('updating the record');
                    Contact c = new Contact();
                       if (TY.Last_or_Family_Name__c!= null) {
                     c.LastName = TY.Last_or_Family_Name__c;
                    }     
                    else { 
                     c.LastName='No Last Name';
                         }  
                c.FirstName= TY.First_Name__c;
                c.GU_ID__c= TY.GUID__c;
                c.Ethnicity__c= TY.Ethnicity__c;
                contactsToupdate.put(TY.Applicant_Client_ID__c , c);
                }
               
         
                else{
                    system.debug('creating new record');
                    contact c = new Contact();
                    if (TY.Last_or_Family_Name__c!= null) {
                     c.LastName = TY.Last_or_Family_Name__c;
                    }     
                    else { 
                     c.LastName='No Last Name';
                         }  
                c.FirstName= TY.First_Name__c;
                c.GU_ID__c= TY.GUID__c;
                c.Ethnicity__c= TY.Ethnicity__c;
                contactsToInsert.put(TY.Applicant_Client_ID__c , c);
                    
                }
            }}
         System.debug('Testing for contact.') ;  
        if ( contactsToupdate.values()!= null )
        {
            System.debug('About to update Contact ' + contactsToupdate.values());
            update contactsToupdate.values(); 
            System.debug('AFTER update of contact Records');
        }
          if(contactsToinsert.values()!= null){
              System.debug('About to insert Contact ' + contactsToInsert.values());
             insert contactsToInsert.values(); 
              System.debug('AFTER insert of contact Records');
            }
        RecordType SLMRecordType;
        List<RecordType> SLMRecordTypes = [ select Id, Name, DeveloperName from RecordType where SObjectType = 'Admission__c' ];
        
        if ( SLMRecordTypes != null && SLMRecordTypes .size() > 0 )
        {
            SLMRecordType = SLMRecordTypes [0];        
        }
        else
        {
            SLMRecordType = new RecordType(id='01240000000UcwV');
        }
        
        for(TY_Imports__c TY : Imports) {
            if (TY.Applicant_Client_ID__c != NULL) {
                Admission__c adm = new Admission__c();
        
                adm.Applicant_Client_ID__c = TY.Applicant_Client_ID__c;
                adm.Age_at_Time_of_Enrollment__c = TY.Age_at_Time_of_Enrollment__c;
                adm.RecordTypeId = SLMRecordType.Id;
                adm.TY_Application_Term__c= TY.Application_Term__c;
                adm.TY_Admitted_Date__c= TY.TY_Admitted_Date__c;
                adm.TY_Enrolled_Date__c= TY.TY_Enrolled_Date__c;
                adm.Decision_Date__c = TY.Decision_Date__c;
                adm.Enrollment_Decision__c = TY.Enrollment_Decision__c;
                adm.Months_of_work_NEW__c= TY.Months_of_work_NEW__c;
                if (contactsToInsert.containsKey(TY.Applicant_Client_ID__c)) {
                adm.ContactLookUp__c= contactsToInsert.get(TY.Applicant_Client_ID__c).id;
                }
            insertSLMList.add(adm);
                 }   
            }
        System.debug('Testing for SML.') ;  
        if ( insertSLMList!= null )
        {
           if ( !Test.isRunningTest() )
            {
               System.debug('About to insert SLM. ' + insertSLMList);
               upsert insertSLMList Applicant_Client_ID__c ;  
               System.debug('AFTER insert of SLM Records');
            }
            else
            {
              try
              {
                upsert insertSLMList Applicant_Client_ID__c ; 
               }
              catch(Exception e)
              {
                System.debug(LoggingLevel.ERROR, '---> caught exception Upserting SLMList: ' + e.getMessage() );
               }
             }
           }
        }
    }
I have the start and end DateTime field in Opportunity, I need to split that into date and time based on customers' country in the record.

Eg: UTC : 2021-04-26T09:00:00.000+0000

Country is UK
Output:
Date : 26-04-2021
Time : 10 AM

If the country is Germany
Output:
Date : 26-04-2021
Time : 11 AM
 
I need to override the list of recordtypes displaying in the selection panel when the user clicks the "New" button.
Ex: I have recordtype A, B, C in Opportunity, whenever the user clicks "New" the selection window need to display only A and B. But he should have access to C recordtype. Because I have another quick action button in the detail page to create records with C recordtype for the user. 
Is that possible to override the selection window to display specific record type?
For example, I have a text " Hello World", I need to use this text in the places in the VF page based on the Output render conditions at least 4-5 times in a page. I don't want to repeat this text hardcoded in the multiple places.

How can we achieve this without any extension/custom controller? Because in future I may need to change the text in Prod directly, rather than pushing the changes through Changeset.

P.S: I have really long text and I have multiple texts like this to be repeated.
I need to display the email id with link based on program name in a para. How can I acheive in VF?
<p class = "doc-preview__copy txindent">
               If you have any questions regarding your next steps, please contact the {!TargetX_SRMb__Application__c.Program_Name__c} 
               admissions team  
                <apex:outputText value="{!IF(app.Program_Name__c == "abc", <a href="mailto:abc@abc.com">abc@abc.com</a>.,a href="mailto:123@abc.com">123@abc.com</a>
                                        ')}" />
   </p>
I am getting syntax error or EL Expression unbalanced error.


 
Hi,
I need to read the email template content alone into the VF page, is that possible?
 
I tried to convert the lead through batch processing, which need to update the existing contact based on the contact id. But the value in the contact record is not overwritten with the Lead value.
Can anyone help on this? Even I set the setOverwriteLeadSource(true); 
for(Lead record: scope) {
            Database.LeadConvert lc = new Database.LeadConvert();
            lc.setLeadId(record.Id);
            lc.setConvertedStatus(convertedStatus);
            
            if(matchAcct.containsKey(record.company))
            {
                lc.setAccountID(matchAcct.get(record.company).id);
            }
            if(matchCont.containsKey(record.Email))
            {
                lc.setContactID(matchCont.get(record.Email).id);
            }
            
            lc.setDoNotCreateOpportunity(true);
            lc.setOverwriteLeadSource(true);
            converts.add(lc);
        }
        
        system.debug('ConvertsLeads:' +converts);
       // Database.LeadConvertResult lcr ;
       List<Database.LeadConvertResult> lcr = Database.convertLead(converts,false);

 
Apex trigger casetriger caused an unexpected exception, contact your administrator: casetriger: execution of BeforeUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.casetriger: line 63, column 1
  1. trigger oppTr on Opportunity (after update,after insert){
  2.         
  3.     Map<Id,Opportunity> OppStage = new Map<Id,Opportunity>();
  4.     List<Account> AccList = new List<Account>();
  5.     
  6.     for(Opportunity opp : trigger.new){        
  7.         if(opp.StageName == 'Closed Lost' && trigger.oldMap.get(opp.Id).StageName == 'Closed Won'){
  8.            OppStage.put(opp.AccountId, opp);
  9.         }
  10.     }
  11.     System.debug('OppStage'+OppStage);
  12.    try {            
  13.    if(OppStage.size()>0){
  14.        System.debug('OppStage'+OppStage.size());
  15.         for(Opportunity opp2 : OppStage.values()){
  16.            System.debug('opp2'+opp2);
  17.            Account acc = new Account();
  18.            acc.Id = opp2.AccountId;
  19.            acc.Status__c = 'Lost';
  20.            AccList.add(acc);
  21.            System.debug('AccList'+acc.Status__c);
  22.         } 
  23.        update AccList;
  24.        System.debug('AccList'+AccList);
  25.     } 
  26.    } catch (System.NullPointerException e){
  27.      String s;
  28.         s.toLowerCase();
  29.    }   
  30.  
  31. }
instead error 
i must update the new values to old record with same name help me



trigger accounttrigger on Account (before insert, before update) {

     Map<String, Id> mapAccount = new Map<String, Id>();
    
    Set<String> setAccName = new Set<String>();
    for(Account acc : trigger.new)
        setAccName.add(acc.Name);
        
    for(Account acc : [ SELECT Id, Name FROM   Account WHERE  Name IN :setAccName ] )
        mapAccount.put(acc.Name, acc.Id);
    
    for(Account acc : trigger.new)
        if(mapAccount.containsKey(acc.Name) && mapAccount.get(acc.Name) != acc.Id)
            acc.addError( 'There is already another Account with the same Name. '  +  
                mapAccount.get(acc.Name) + '\'>' + acc.Name + '</a>', FALSE );
}
Just last week I started getting issues with picklists that have restricted values.  I am creating records in a test and I have copied the value right from the picklist when I recreate it in my test.. however, the test is failing due to, "System.DmlException: Insert failed. First exception on row 1; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Inter-Plan Preparing: [Cede_Status__c]"

I'm hoping there is just something I'm missing here?  

thanks!!

Fred
  • March 22, 2017
  • Like
  • 0
When we create an opportunity we create a certain number of quotes (custom, child record). I would like to be able to send an email to include information from all the quotes created under the opportunity.This is my first visualforce email template. I want to be able to pull I need some help because when I go to save I receive the following error: Unknown property 'core.email.template.EmailTemplateController.Opportunity'
 
<messaging:emailTemplate recipientType="User"
                     relatedToType="Opportunity"
                     subject=" {!Opportunity.Account}, {!Quotes_RFR__c.Current_Carrier__c}, {!Opportunity.Date_Due__c},{!Opportunity.Total_Eligible__c}" >
<messaging:htmlEmailBody >  
    <html>
        <body>
            <STYLE type="text/css">
                TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
                TD  {font-size: 11px; font-face: verdana } 
                TABLE {border: solid #CCCCCC; border-width: 1}
                TR {border: solid #CCCCCC; border-width: 1}
            </STYLE>
            <font face="arial" size="2">
                <table border="0" >
                    <tr > 
                        <th>Quote Number</th><th>Contribution Type</th><th>In Network</th><th>Out of Network</th>
                    </tr>
                    <apex:repeat var="cx" value="{!Quotes_RFR__c}">
                        <tr>
                            <td>{!Quotes_RFR__c.Quote_Name__c} </td>
                            <td>{!Quotes_RFR__c.Contribution_Type__c}</td>
                            <td>{!Quotes_RFR__c.In_NetworkDiag_Prev__c}/ {!NullValue(Quotes_RFR__c.In_Network_Basic__c, "0")}/ {!NullValue(Quotes_RFR__c.In_Network_Major__c, "0")}/ {!NullValue(Quotes_RFR__c.In_Network_Ortho__c, "0")}; {!Quotes_RFR__c.In_Network_Deductible_Ind__c}/ {!Quotes_RFR__c.In_Network_Deductible_Fam__c} Ded; {!Quotes_RFR__c.In_Network_Annual_Max__c} Max; {!NullValue(Quotes_RFR__c.In_Network_Ortho_Max__c, "0")}</td>
                            <td>{!Quotes_RFR__c.Out_Network_Diag_Prev__c}/ {!NullValue(Quotes_RFR__c.Out_Network_Basic__c, "0")}/ {!NullValue(Quotes_RFR__c.Out_Network_Major__c, "0")}/ {!NullValue(Quotes_RFR__c.Out_Network_Ortho__c, "0")}; {!Quotes_RFR__c.Out_Network_Deductible_Ind__c}/ {!Quotes_RFR__c.Out_Network_Deductible_Fam__c} Ded; {!Quotes_RFR__c.Out_Network_Annual_Max__c} Max; {!NullValue(Quotes_RFR__c.Out_Network_Ortho_Max__c, "0")} </td>
                        </tr>
                    </apex:repeat>                 
                </table>
                <p />
            </font>
        </body>
    </html>
</messaging:htmlEmailBody> 
</messaging:emailTemplate >

 
Hello,

I have a requirement where I need to access Campaign Influence records in the Opportunity related list by SOQL query. Basically, I need to access it because I have custom object looking up to CAMPAIGN. And I want to show all opportunities in that custom object related list "Opportunities" upon on adding the Campaign in the custom object.

Thanks,
GR
Hello,

I am attempting to extract information from a salesforce object using the data loader command line functionality.  I currently have a process-conf and .sdl that execute properly.  However, when I attempt to include Format() in the select statement, I am unsure of how to modify the mapping in the .sdl to bring it into the .csv.  I've tried a couple things that were unsuccessful.

This example works fine:
Select Id, CreatedDate
From Account

This example does not:
Select Id, format(CreatedDate)
From Account
Hello,

I've seen this topic come up, but I don't see any answers that seem to be relevant to my case.

I am using the Rails restforce Gem to connect to Salesforce.  I am able to connect, pull, update, create data, but after some period of time my session seems to expire with the message "INVALID_SESSION_ID: Session expired or invalid".  

Here is the code I am using to initialize my client:
 
@client = Restforce.new oauth_token: options[:salesforce_token],
      refresh_token: options[:salesforce_refresh_token],
      instance_url:  options[:salesforce_instance_url],
      client_id:     sales_force_client_id,
      client_secret: sales_force_client_secret,
      authentication_callback: Proc.new { |x| Rails.logger.debug x.to_s }

And when I make a request (again after a period of time) I get the following back:
 
url: "https://cs13.salesforce.com/services/data/v38.0/sobjects/Contact"
  method: :post
  headers: {"User-Agent"=>"Faraday v0.9.2", "Content-Type"=>"application/json", "Authorization"=>"OAuth XXXXXXXXXXX"}
  body: "{\"LastName\":\"Test\",\"FirstName\":\"Test \",\"MailingCountry\":\"United States\",\"MailingPostalCode\":\"29464\",\"MailingCity\":\"Mount Pleasant\",\"MailingState\":\"South Carolina\",\"Phone\":\"1-555-555-5555\",\"Business_Contact__c\":true,\"RecordTypeId\":\"01238000000UVfW\"}"
D, [2017-02-06T14:43:14.791977 #99698] DEBUG -- response:
  status: "401"
  headers: {"date"=>"Mon, 06 Feb 2017 19:43:07 GMT", "x-content-type-options"=>"nosniff", "x-xss-protection"=>"1; mode=block", "content-security-policy"=>"reflected-xss block;report-uri /_/ContentDomainCSPNoAuth?type=xss, referrer origin-when-cross-origin", "set-cookie"=>"BrowserId=I2nltdq0SSqJ7KinYQEyMw;Path=/;Domain=.salesforce.com;Expires=Fri, 07-Apr-2017 19:43:07 GMT", "expires"=>"Thu, 01 Jan 1970 00:00:00 GMT", "www-authenticate"=>"Token", "content-type"=>"application/json;charset=UTF-8", "transfer-encoding"=>"chunked", "connection"=>"close"}
  body: "[{\"message\":\"Session expired or invalid\",\"errorCode\":\"INVALID_SESSION_ID\"}]"

Any pointers would be greatly appreciated!