• Sumit Saini 1
  • NEWBIE
  • 5 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
Hi, 
can i get all the values of a picklist field in a list some how?

I have picklist type custom field in the product. having some options.
In my apex class i want to use these options. can I get them some how throught code? 
Hi Everyone

I have a simple before update trigger below. I am trying to catch any error and log to a custom table. The below will cause Duplicate error in UI but nothing is inserted into custome object USD_Error_Log__c.. Its like trigger does not fall into either DMLException or Exception catch blocks. Any and all help is appreciated.

Thanks

Jon

trigger USD_Contact on Contact(before update){

Set<USD_Error_Log__c> student = new Set<USD_Error_Log__c>(); 

for (Contact c: Trigger.new) {
    // delete [select id from USD_Error_Log__c];    
    
try{
  
     c.TargetX_SRMb__BannerID__c = '008372883';   // this will cause Duplicate value on record error      
     
} catch (DMLException e) {

  string error = e.getMessage();
  student.add(new USD_Error_Log__c(Banner_ID__c = c.TargetX_SRMb__BannerID__c,Error_Message__c = error ));
  
  if(!student.isEmpty()){   
   List<USD_Error_Log__c> toInsert = new List<USD_Error_Log__c>();
   try{
      toInsert.addAll(student);
      insert toInsert;     
   }catch(Exception se){
   }                             
  } 

} catch(Exception e) {
    
  string error = e.getMessage();
  student.add(new USD_Error_Log__c(Banner_ID__c = c.TargetX_SRMb__BannerID__c,Error_Message__c = error ));
  
  if(!student.isEmpty()){   
   List<USD_Error_Log__c> toInsert = new List<USD_Error_Log__c>();
   try{
      toInsert.addAll(student);
      insert toInsert;     
   }catch(Exception se){
   }                             
  } 
  
    
}

}//end loop



}
I have two objects Parent(Account) and Child(Contact). I want to update all associated child records 'Last Name' with comma separated formate in parent filed (custome field).

For suppose i have five child records for associate parent record, now i want to update this five child records last names into that parent filed with comma separated.

I know we can do this using VF and Apex. Can you please clarify is it possible through Triggers? And if u can please share sample code.

Thanks in advance!!!!
  • November 25, 2014
  • Like
  • 0
Hai friends,
i want to display all objects with its keyprefix values for this i done like this

in controller class:
public class GettingObjectsAndKeyPrifix {
    public List<Schema.SObjectType> gd {get;set;}
    public List<String> objectMap {get;set;}

     Public GettingObjectsAndKeyPrifix(){
        gd= Schema.getGlobalDescribe().Values();
        objectMap = new List<String>();
        for(Schema.SObjectType f : gd)
        {
            objectMap.add(f.getDescribe().getKeyPrefix());
        }
        System.debug('--------- --'+gd);
        System.debug('+++++++++ --'+objectMap.size() );
    }
}

in visual force page:
<apex:page controller="GettingObjectsAndKeyPrifix">
    <!--http://srinivas4sfdc.blogspot.in/2013/12/list-of-salesforce-object-key-prefixes.html-->
   <apex:pageBlock >
   <apex:pageBlockSection >
        <apex:pageBlockTable value="{!objectMap}" var="o">
        <apex:column value="{!o}"></apex:column>
        </apex:pageBlockTable>  
      <apex:pageBlockTable value="{!gd}" var="g">
    <apex:column value="{!g}"></apex:column>
    </apex:pageBlockTable>
  
    </apex:pageBlockSection>
   
     </apex:pageBlock>
   
</apex:page>

here output is comming ,but i want output like

account--001
Note-002
like this how can i please help.

i want ouput like this in url
http://srinivas4sfdc.blogspot.in/2013/12/list-of-salesforce-object-key-prefixes.html
How can I get the current Salesforce User ID in an Apex class?

Any help is appreciated!

Chris