• Nish321
  • NEWBIE
  • 180 Points
  • Member since 2014

  • Chatter
    Feed
  • 5
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 41
    Questions
  • 42
    Replies

Hello all,

So I created a trigger to Cases in a queue, when size is reached I want to send an email once..only once.

My trigger is firing at limit (3), but is sending the email 3 times. I think I need a second or third set of eyes to see what I am missing.

Thanks for your help.

Robert 

trigger NotificationExceedingQueueLimit3 on Case (before insert,before update) {

boolean EmailSent = False;

    list<group> queuelist= [SELECT id  FROM Group where DeveloperName = 'CPS_Default_Queue'and Type = 'Queue' limit 1];     
    if(queuelist.size()>0){
                
             list<case> caselist = [select id from case where ownerid =:queuelist[0].id];
             for(case cs : trigger.new){
             
                if(caselist.size()==3 && EmailSent == False)
                {
                  EmailSent = True; 
                  List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                  List<String> sendTo = new List<String>();
                  sendTo.add('Hello.Friend@gmail.com' );
                  mail.setHtmlBody('Hello, <br/> Default Queue Limit Exceeded. The count has exceeded 2 cases.<br/><br/> Thanks, <br/>Salesforce Admin');
                  mail.setSubject('Case Limit of 02 Exceeded');
                  mail.setToAddresses(sendTo);
                  mails.add(mail);   
                  Messaging.sendEmail(mails); 
                }
        
             }
    }  
}
 

 

 

I am trying to move records from one custom Object(Course_temp__c) to another custom Object(Course__c) using Apex batch. This is the code I have:
global class MyBatchJob2 implements Database.Batchable<Course_temp__c> {

    global MyBatchJob2(){}

    global List<Course_temp__c> start(Database.BatchableContext BC) {
    	return [Select Id, Name, Contact__c, Course_Fees__c,Date__c From Course_temp__c];
    }

    global void execute(Database.BatchableContext BC, List<Course_temp__c> scope) {
       List<Course__c> lhList = new List<Course__c>();
       for(Course_temp__c obj : scope){
           System.debug('Course_temp records are: ' +obj);
           lhList.add(
               new Course__c(
                  Name = obj.Name,
                   Contact__c = obj.Contact__c,
                   Course_Fees__c = obj.Course_Fees__c,
                   Date__c = obj.Date__c
               )
           );
           System.debug('The list is: '+lhlist);
       }
       insert lhList;
       delete scope;
    }

    global void finish(Database.BatchableContext BC) {
        System.debug('Finished Succesfully');
    }
}
I am invoking the batch class using           Id batchJobId = Database.executeBatch(new MyBatchJob2(), 200);

The code is running without any compilation errors and I also get the 'Finished Succesfully' message in the debug log. However, the records are not moving from Course_temp__c to Course__c. Can someone please tell me what I missing. Any help is hugely appreciated.


 
how to get annual revenue in account  and split to opportunities under that account 
using trigger plzzzzzzzzz help me

User-added image
I used this step

From Setup, enter Outbound Changesets in the Quick Find box, then select Outbound Changesets.
If a splash page appears, click Continue.
In the Change Sets list, click New.
Enter a name for your change set, for example, HelloWorldChangeSet, and optionally a description. Click Save.
In the Change Set Components section, click Add.
Select Apex Class from the component type drop-down list, then select the MyHelloWorld and the HelloWorldTestClass classes from the list and click Add to Change Set.
Click View/Add Dependencies to add the dependent components.
Select the top checkbox to select all components. Click Add To Change Set.
In the Change Set Detail section of the change set page, click Upload.
Select the target organization, in this case production, and click Upload.
After the change set upload completes, deploy it in your production organization.
Log into your production organization.
From Setup, enter Inbound Change Sets in the Quick Find box, then select Inbound Change Sets.
If a splash page appears, click Continue.
In the change sets awaiting deployment list, click your change set's name.
Click Deploy.

I have created a custom button using Javascript on Opportunity. On the opportunity object we already have relationship field which relates back to Opportunity (like Parent-Child).

The javascript button will copy the values of certain field from the Parent opportunity and auto populate in the new child opportunity created. All the values are copied to child opportunity, but except for picklist values which has "&" in the value.. When i use urlencode like below, it is throwing the below error:

00NK0000001jyxH={!URLENCODE(Opportunity.ABC__c)}

Error: Field Opportunity.HBS_ePSF_Branch_Location__c is a picklist field. Picklist fields are only supported in certain functions.
 
This code throws an error -  "This page has an error. You might just need to refresh it" . Anything wrong with the code? 
 
if(this.allowCreditCheck === false){
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: "001R000001RQLHfIAP",
                actionName: 'view'
            }
        });
    }

 
Hi, 
I'm trying to encrypt json data by signing with HMAC. Code doesn't seem to generate the right link.  Please assist !! 
 
public class crypto1 
    {
    
				 public string encryptkeyy = '3kXLV1rnimLRd0of4TPGz7iu2Wdd+/hYdfdf/Dt6nnIk=';  
				 public string authkeyy =     '2BKulGe3CTWOxSHkwR6546XqkM62dNpFAeuuWhfevc4A=';
				 public string domain = 'XYZ.com';
				
				 
				 public void crpytofunction(){
				 
				 string order   = '{ "email":"john@doe.com","name":"John Doe","ref":"1234"}';
				 
				
				
				 
				
				
				Blob encKey = EncodingUtil.base64Decode(encryptkeyy );
			  
				
				
				 Blob authKey = EncodingUtil.base64Decode(authkeyy);
				
				
				Blob data = Blob.valueOf(order);
				
			   // string s =  String.valueOf(Crypto.getRandomInteger());

				
				//Initialization vector
				  Blob encryptedBlob = Crypto.encryptWithManagedIV('AES256',authKey,data);
				  
			  
				  String encodedCipherText = EncodingUtil.base64Encode(encryptedBlob );  // all good until here .. 
				   
				   string payload = EncodingUtil.urlEncode(encodedCipherText,'UTF-8');
				   
				   Blob data1 = crypto.generateMac('HmacSHA256', encryptedBlob, authKey );  // problem with this part. 
				   
				   String anotherone = EncodingUtil.base64Encode(data1);
			
			  
					string link =  'https://www.trustpilot.com/evaluate-bgl/xyz.com?'+anotherone

     
    } 
    
   
      
    
    
    }

 
Hi,

I have an existing functionality - whenever an attachment is uploaded on child record, it will get automatically inserted on Parent record as well. This works fine.  Now the parent record's attachment has to be deleted whenever a child record's attachment is deleted. Any idea how to accomplish this?

Thanks,
Nish
  • September 30, 2017
  • Like
  • 0
Not able to figure out what's wrong with this trigger.  
 
trigger DuplicateEmail on Contact (before insert, before update) {

map<string, contact> conmap =  new map<string, contact> ();

   for(contact con : trigger.new)
   
      {
        if(con.email!=null){
        
        conmap.put(con.email, con);
        
        }
      
     }
     
     
 map<string, contact> emailmap = new map<string, contact> ([select email, id from contact where email IN: conmap.keyset() limit 1]);    
 

 
      for(contact c : trigger.new)
      
      {
      
      
      
     if(emailmap.get(c.email) !=null)
      
      {
        c.email.adderror('this is duplicate email');
      }
    
   
   }
     
     
     
}

 
I have a scenario where i'm auto populating the values using javascript button (which further invokes an apex class). Now the real problem is when these fields are updated, it is invoking a trigger due to update operation.  Is there a way to prevent this?  In another words, Is there a way to bypass the trigger if the button is clicked?
Hi,

I'm new to salesforce. Can someone help me out with the test class for the below trigger:
trigger CheckDuplicateIrrs on IRR_s__c (before insert, before update) {
if ( CommonMessages.IRRTriggerFirstRun ) {
        CommonMessages.IRRTriggerFirstRun = false;
    List < String > samplenames = new List < String >();
    for (IRR_s__c s : trigger.new) {
        if ( String.isNotBlank(s.name) ) {
            if ( trigger.isInsert ) {
                samplenames.add('IRR' + '-' + '07' + '-' + s.IRR_Year__c.RIGHT(2) + '-' + String.valueOf(s.Sequential_Number__c).leftPad(4, '0')); 
            } else if ( trigger.isUpdate ) {
                if ( s.Sequential_Number__c != trigger.oldMap.get(s.Id).Sequential_Number__c || s.Name != trigger.oldMap.get(s.Id).Name ) {
                    samplenames.add('IRR' + '-' + '07' + '-' + s.IRR_Year__c.RIGHT(2) + '-' + String.valueOf(s.Sequential_Number__c).leftPad(4, '0')); 
                }
            }
        }
    }    
    
    if ( samplenames.size() > 0 ) {
        List < IRR_s__c > dupsamples =  [ SELECT Id, Name, Sequential_Number__c FROM IRR_s__c WHERE Name IN: samplenames ];
        if ( dupsamples.size() > 0 ) {
            Map < String, IRR_s__c > mapNameIRR = new Map < String, IRR_s__c >();
            for ( IRR_s__c IRR : dupsamples ) {
                mapNameIRR.put(IRR.Name, IRR);
            }
            
            for (IRR_s__c s : trigger.new) {
                if ( mapNameIRR.containsKey('IRR' + '-' + '07' + '-' + s.IRR_Year__c.RIGHT(2) + '-' + String.valueOf(s.Sequential_Number__c).leftPad(4, '0')) ) {
                    s.addError('This IRR already exists with same Name');
                }
            }
        }
    }  
   }

 
Hi,

How can i deploy the profiles alone from sandbox to the production?  

Thanks,
Ramshah
Could some please help me out regarding this?  It's throwing an errow when adding the bunch of records at a time.
 Below is my code:
public with sharing class AddMultipleRelatedProducts {
    
    public Project_Product__c CurrentPT {get;set;}
    
    public List<TaskTemplate> listTaskTemplate {get;set;}
     
    public string SearchKeyword {get;set;}
     
    public CustomIterable obj;
    
    public SET<ID> setSelectedProductId {get;set;}
    
    public List<Product_Code__c> listProductCode {get;set;}
    public List<Product_Code__c> listSelectedProductCode {get;set;}
    public boolean ShowProductCode {get;set;}
    Set<Id> productIds = new Set<Id>();
    Set<Id> SproductCodeIds = new Set<Id>();
    Set<Id> SelectedProductCodeIds = new Set<Id>();
    public List<Product__c> Products { get; set; }
      
    public AddMultipleRelatedProducts(){
        listSelectedProductCode = new List<Product_Code__c>();
        CurrentPT = new Project_Product__c();
        listTaskTemplate = new List<TaskTemplate>();
        setSelectedProductId = new SET<ID>();
        listProductCode = new List<Product_Code__c>();
        ShowProductCode = false;
        
        if(System.currentPageReference().getParameters().get('id') != null ){
            for(Project_Product__c pt : [Select Id From Project_Product__c Where Id =: System.currentPageReference().getParameters().get('id')]){
                CurrentPT = pt;
            }
        }   
         
        SelectedProductCodeIds = new Set<Id>();
        for(Products__c pj : [select Product_Code__c from Products__c where Project__c = :CurrentPT.Id order by Product_Code__c asc ])
        {
            SelectedProductCodeIds.add(pj.Product_Code__c);
        }
        
        productIds = new Set<Id>();
        for(Product_Code__c pc : [select Id, Product_Name__c from Product_Code__c  where Id in :SelectedProductCodeIds])
        {
            productIds.add(pc.Product_Name__c);
        }
        
        Products = [select Id, Name,  Division__c, Franchise__c,  Product_Code__c, Project__c from Product__c where Id in :ProductIds ]; // added Product_Code__c
        
        DoSearch();
    }
    
    public void DoSearch(){
        listTaskTemplate = new List<TaskTemplate>();
        
        string strQ = ' Select Id, Name ,Franchise__c,Division__c From Product__c Where Total_Product_Code__c > 0 ';

        string strKey = SearchKeyword + '%';
        
        if(SearchKeyword != null && SearchKeyword != ''){
            strKey = strKey.replace('*','');
            
            strQ = strQ + ' AND (Product_Code__c LIKE \'' + strKey + '\' OR Name Like \'' + strKey + '\'  OR Franchise__c Like \'' + strKey + '\' OR Division__c Like \'' + strKey + '\' ) ';
        }
        
        strQ = strQ + '  Order By Name ASC, Name ASC Limit 2000';
        
        obj = new CustomIterable(strQ); 
        obj.setPageSize = 100  ;
        next();
         
    }
    
    
    public pageReference DoCancel(){
        return new PageReference('/' + CurrentPT.Id);
    }
    
    public pageReference DoSelect() {
        pageReference pr = null;
        listSelectedProductCode = new List<Product_Code__c>();
        try{
            SET<ID> setTTId = new SET<ID>();
             
            for(TaskTemplate tt : obj.accInnerList){
                if(tt.IsSelected == true ){
                    setTTId.add(tt.TaskTemp.Id);
                }
            }
            
            if(setTTId.size() <= 0 ){
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please select at least one Product'));  
                return null;
            }
            
            List<Products__c> listRT = new List<Products__c>();
            
            for(TaskTemplate tt : obj.accInnerList){
                if(tt.IsSelected == true ){
                    setSelectedProductId.add(tt.TaskTemp.Id); 
                }
            }
            
            listProductCode = [Select Id, Name, Description__c, Product_Name__c,Product_Name__r.Name,Is_Selected__c FROM Product_Code__c WHERE Product_Name__c IN:setSelectedProductId AND Id NOT IN: SelectedProductCodeIds Order By Product_Name__r.Name ASC, Name ASC limit 2000 ];
            listSelectedProductCode = [ SELECT Id, Name, Description__c, Product_Name__r.Name, Product_Name__r.Franchise__c, Product_Name__r.Division__c, Product_Name__c FROM Product_Code__c WHERE Id IN: SelectedProductCodeIds order by Name ASC  ];
           // listSelectedProductCode = [ SELECT Id, Name, Description__c, Product_Name__r.Name, Product_Name__r.Franchise__c, Product_Name__r.Division__c, Product_Name__c FROM Product_Code__c WHERE Product_Name__c IN: productIds order by Name ASC  ];
            ShowProductCode = true; 
            // productIds
        }
        catch(Exception ex){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,ex.getMessage()));  
        }
        return pr;
        
    }
    
    
    public pageReference DoSave(){
        pageReference pr = null;
        try{
            SET<ID> setTTId = new SET<ID>();
             
            for(Product_Code__c tt : listProductCode){
                if(tt.Is_Selected__c == true ){
                    setTTId.add(tt.Id);
                }
            }
            
            if(setTTId.size() <= 0 ){
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please select at least one Product Code'));  
                return null;
            }
            
            List<Products__c> listRT = new List<Products__c>();
            
            for(Product_Code__c tt : listProductCode){
                if(tt.Is_Selected__c == true ){
                    Products__c rt = new Products__c();
                    
                    rt.Project__c = CurrentPT.Id;
                    rt.Product__c =  tt.Product_Name__c;                    
                    rt.Product_Code__c = tt.Id;
                    listRT.add(rt);
                }
            }
            
            if(listRT.size() > 0){
                upsert listRT;
            }

            pr = new PageReference('/' + CurrentPT.Id);
        }
        catch(Exception ex){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,ex.getMessage()));  
        }
        return pr;
        
    }
    
    
    public Boolean hasNext {
        get {
            return obj.hasNext();
        }
        set;
    }
    
    public Boolean hasPrevious {
        get {
            return obj.hasPrevious();
        }
        set;
    }
    
    public void next() {
        listTaskTemplate = obj.next();
    }
    
    public void previous() {
        listTaskTemplate = obj.previous();
    }
    
    
}

 
Any idea how to sort version numbers in descending order.

Currently, my code is :  versionList = [Select Id,Name from Version__c where Product__c=:prd and Active__c=true  order by Name desc];    

Still the version numbers are unordered. Eg: 8.1.0, 8.2.1, 8.10.1. 
Hi,

I'm just wondering if we have the ability to change the 'Posted by'  field in the Ideas. Currently, the Posted by field displays only the alias name but I would like to display the full name who posts the idea rather than the alias name.  

User-added image

Thanks,
Ramshah

Any idea why this occurs?

User-added image

Could someone help me out with this? 

integer dt1 = day( datevalue(cc1.ClosedDate) ) - today();
Can anyone help me out with this trigger?  I would like to create a new case comment whenever a case is inserted or updated. Below is the trigger i've written:

trigger UpdateanotherObj on Case (after insert, after update) {

//whenever a case is created a student should also be created 
set <ID> Caseids =  new set<ID> ();
 list<casecomment> casecommentlist = new list <casecomment> ();
 // casecomment[] comments = new casecomment[0];
 // database.dmloptions option = new database.dmloptions();

for (case c : trigger.new)

{

caseids.add(c.id);

}

 // list<casecomment>  cc =    [select ID, ParentID from CaseComment where ParentID IN : caseids] ;
  
for(case c : trigger.new  )
{

casecomment cc = new casecomment();
 cc.parentid = c.ID;
cc.commentbody = 'case comment this is';
cc.ispublished = true;
casecommentlist.add(cc); 
}
  insert casecommentlist;

}
How to send an email notification to the article follower whenever an article is updated?   
 
How to Send an email update to the article followers when an article is updated?
On page layout,  Can we hide the field name and dispay field value alone?
 
I would have to autopopulate a field in Case object from Account object.    The field value should be colored (Eg: Green) or highlighted.  How can I accomplish this using a formula ?
Can i clone all the objects of App A into App B in the same instance?  Also, i would like to add some suffix to make sure API names are different. Is there a shortcut? Thanks

How to edit the columns (list view') of 'Article Management' tab?  I would like to add a column to the view but I don't find the provision to add it anywhere?  Any help would be appreciated.

Thanks

User-added image

I created a button on detail page. I have access to that button (since i'm an admin). However, when I logged in as a different user whose profile is ABC, It throws an alert 'Insufficient access'.   FYI,  it's a java script button which calls an apex class.

Could you please help me how to figure it out?  Thanks
How do I restrict the user to add multiple related list items? As per the requirement, User should not be able to add more than one related list item. Any suggestions on this would be appreciated.

Thanks,
Ramshah

Hello all,

So I created a trigger to Cases in a queue, when size is reached I want to send an email once..only once.

My trigger is firing at limit (3), but is sending the email 3 times. I think I need a second or third set of eyes to see what I am missing.

Thanks for your help.

Robert 

trigger NotificationExceedingQueueLimit3 on Case (before insert,before update) {

boolean EmailSent = False;

    list<group> queuelist= [SELECT id  FROM Group where DeveloperName = 'CPS_Default_Queue'and Type = 'Queue' limit 1];     
    if(queuelist.size()>0){
                
             list<case> caselist = [select id from case where ownerid =:queuelist[0].id];
             for(case cs : trigger.new){
             
                if(caselist.size()==3 && EmailSent == False)
                {
                  EmailSent = True; 
                  List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                  List<String> sendTo = new List<String>();
                  sendTo.add('Hello.Friend@gmail.com' );
                  mail.setHtmlBody('Hello, <br/> Default Queue Limit Exceeded. The count has exceeded 2 cases.<br/><br/> Thanks, <br/>Salesforce Admin');
                  mail.setSubject('Case Limit of 02 Exceeded');
                  mail.setToAddresses(sendTo);
                  mails.add(mail);   
                  Messaging.sendEmail(mails); 
                }
        
             }
    }  
}
 

 

 

Hi,
Please can anyone help me  with how to merge these two codes into one?
I wrote the following  codes separately  for same the custom object, and I dont know how to consolidate them into one code
. Any help will be appreciated !

1st Code: 
trigger SetContactOnAssetRecord on Assets_Check_in_Checkout__c (before update,before insert) {
    set<string>Netid = new Set<string>();
    for (Assets_Check_in_Checkout__c a  : Trigger.new){
       Netid.add(a.GU_Net_ID__c) ;
        
    }
    List<Contact> ContactList = [ select id, GU_Net_ID__c from Contact where GU_Net_ID__c IN :Netid ];
    Map<string,Contact> netidToContactMap= new Map <string,Contact>();
    
    for (Contact c : ContactList){
        
      netidToContactMap.put(c.GU_Net_ID__c,c);  
        
    }
    for(Assets_Check_in_Checkout__c chk : Trigger.new ){
        if(chk.GU_Net_ID__c != null && netidToContactMap.containsKey(chk.GU_Net_ID__c) ){
            system.debug('Contact id:' + netidToContactMap.get(chk.GU_Net_ID__c).id);
            chk.Loaner__c = netidToContactMap.get(chk.GU_Net_ID__c).id;
        }
        else
        {
           chk.addError('Netid not exist in Salesforce');
 
        }
    }
    
}


2nd Code:

trigger UpdateStatus on Assets_Check_in_Checkout__c (after insert, after update) {
 // Create a list of assetids
    List<Id> assetIds = New List<ID>();
    set<id> assetName = new set<id>();
    Map<id,id> Assetid = new Map<id,id>();
    List<Asset> LAsset = new List<Asset>();
    
    if(Trigger.isInsert){
        for(Assets_Check_in_Checkout__c AssID : Trigger.new){
        if(!string.isBlank(assid.Asset_Name__c))
        {
            Assetid.put(assID.id, assid.Asset_Name__c);
        }
    }
    }
    
    if(Trigger.isUpdate)
    {
    for(Assets_Check_in_Checkout__c AssID : Trigger.new){
        
        if(!string.isblank(assid.Asset_Name__c) && Trigger.oldMap.get(AssID.id).Status__c != Trigger.newMap.get(AssID.id).Status__c)
        {
            Assetid.put(assID.id, assid.Asset_Name__c);
            assetName.add(assid.Asset_Name__c);
        }
    }
    }
    
    for(Asset a: [select id, status,(select name, status__c from Assets_Check_in_Checkout__r where id IN:Assetid.keySet()) from Asset where id IN: AssetId.values()]){
        
        
        for(Assets_Check_in_Checkout__c ACC : a.Assets_Check_in_Checkout__r)
        {
            Asset a1 = new Asset();
            if(acc.status__C == 'Check-in')
            {
                a1.Status = 'Available';
                a1.id = a.id;
                LAsset.add(a1);
            }
            else if(acc.status__c == 'Checkout')
            {
                a1.Status = 'Not Available';
                a1.id = a.id;
                LAsset.add(a1);
            }
        }
        
       
    }
    
    Update LAsset;
}
    
I am trying to move records from one custom Object(Course_temp__c) to another custom Object(Course__c) using Apex batch. This is the code I have:
global class MyBatchJob2 implements Database.Batchable<Course_temp__c> {

    global MyBatchJob2(){}

    global List<Course_temp__c> start(Database.BatchableContext BC) {
    	return [Select Id, Name, Contact__c, Course_Fees__c,Date__c From Course_temp__c];
    }

    global void execute(Database.BatchableContext BC, List<Course_temp__c> scope) {
       List<Course__c> lhList = new List<Course__c>();
       for(Course_temp__c obj : scope){
           System.debug('Course_temp records are: ' +obj);
           lhList.add(
               new Course__c(
                  Name = obj.Name,
                   Contact__c = obj.Contact__c,
                   Course_Fees__c = obj.Course_Fees__c,
                   Date__c = obj.Date__c
               )
           );
           System.debug('The list is: '+lhlist);
       }
       insert lhList;
       delete scope;
    }

    global void finish(Database.BatchableContext BC) {
        System.debug('Finished Succesfully');
    }
}
I am invoking the batch class using           Id batchJobId = Database.executeBatch(new MyBatchJob2(), 200);

The code is running without any compilation errors and I also get the 'Finished Succesfully' message in the debug log. However, the records are not moving from Course_temp__c to Course__c. Can someone please tell me what I missing. Any help is hugely appreciated.


 
how to get annual revenue in account  and split to opportunities under that account 
using trigger plzzzzzzzzz help me
Not able to figure out what's wrong with this trigger.  
 
trigger DuplicateEmail on Contact (before insert, before update) {

map<string, contact> conmap =  new map<string, contact> ();

   for(contact con : trigger.new)
   
      {
        if(con.email!=null){
        
        conmap.put(con.email, con);
        
        }
      
     }
     
     
 map<string, contact> emailmap = new map<string, contact> ([select email, id from contact where email IN: conmap.keyset() limit 1]);    
 

 
      for(contact c : trigger.new)
      
      {
      
      
      
     if(emailmap.get(c.email) !=null)
      
      {
        c.email.adderror('this is duplicate email');
      }
    
   
   }
     
     
     
}

 

User-added image
I used this step

From Setup, enter Outbound Changesets in the Quick Find box, then select Outbound Changesets.
If a splash page appears, click Continue.
In the Change Sets list, click New.
Enter a name for your change set, for example, HelloWorldChangeSet, and optionally a description. Click Save.
In the Change Set Components section, click Add.
Select Apex Class from the component type drop-down list, then select the MyHelloWorld and the HelloWorldTestClass classes from the list and click Add to Change Set.
Click View/Add Dependencies to add the dependent components.
Select the top checkbox to select all components. Click Add To Change Set.
In the Change Set Detail section of the change set page, click Upload.
Select the target organization, in this case production, and click Upload.
After the change set upload completes, deploy it in your production organization.
Log into your production organization.
From Setup, enter Inbound Change Sets in the Quick Find box, then select Inbound Change Sets.
If a splash page appears, click Continue.
In the change sets awaiting deployment list, click your change set's name.
Click Deploy.

I cannot figure out what Im doing wrong. I need it to have Priority of Low if no Direct Dial and/or Mobile on Contact and Medium if there is Direct Dial AND/OR Mobile. Medium works but not Low.

Any ideas? Help is very much appreciated.

trigger createTask on Contact (after insert, after update) {
    List<Task> listOfTaskToBeInserted = new List<Task>();
    Task newtask;
    for(Contact con : trigger.new){
        if((trigger.isInsert && (con.Direct_Dial__c == '' || con.MobilePhone == '')) || (trigger.isUpdate && trigger.oldMap.get(con.id).Exec_Type__c != con.Exec_Type__c && (con.Exec_Type__c == 'Key Exec' || con.Exec_Type__c == 'Approved Exec'))){
            newtask = new Task();
            newtask.WhatId = con.AccountId;
            newtask.Subject = 'Target';
            newtask.whoId = con.id;
            newtask.ActivityDate = system.today();
            newTask.Status = 'Open';
            newTask.Attendee__c = con.Task_Attendee__c;
            if(con.Direct_Dial__c == ''){
               newTask.Priority = 'Low';
            }
            else{
                newTask.Priority = 'Medium';
            }
           listOfTaskToBeInserted.add(newTask);
        }
    }
    if(listOfTaskToBeInserted.size() > 0){
        insert listOfTaskToBeInserted;
    }
}
Hi,

I have a button on case which calls a vf page and this vf will available only when some error occurs. Otherewise it directly create a child case using a controller. from action part of vf page.
But I want it should go to standard new page of a case from controller and parent case field should be populated with the casenumber from which I am trying to create a child case.

 pageRef = new PageReference ('/500/e?CFparent='+caseNumber+'&RecordType=01280000000HnUD');

I am using above code to for this. But I don't get desired result and it is being overidden by new button of case.
Any help on this.

Regards,
Aditya
Hi,

I'm just wondering if we have the ability to change the 'Posted by'  field in the Ideas. Currently, the Posted by field displays only the alias name but I would like to display the full name who posts the idea rather than the alias name.  

User-added image

Thanks,
Ramshah
On page layout,  Can we hide the field name and dispay field value alone?
 
Hello,

I created a custom field and set the help text with the line breaks and when it is hovered in the detail page it displays as 
First Line
Second Line
When I checked the html page generated by Salesforce the code looks like below.
sfdcPage.setHelp('xxxx', 'FirstLine\r\u003Cbr\u003ESecondLine');
which i assume is complicated version of 
sfdcPage.setHelp('xxxx', 'FirstLine\r\nSecondLine');
Now when I added a translated text in Setup -> Translation Workbench -> Translate for another language and given the value as 
First Line_FR\r\nSecond Line_FR
but in the UI, it displays everything in a single line and there is no line break but instead it displays all the characters entered above. When looked at the html page generated by Salesforce this is what I see
sfdcPage.setHelp('xxxx', 'First line_FR \\r\\n Second line_FR');
SF automatically inserts another escape sequence character '\' so that it displays what we enter in the translated text. I tried replacing '\r\n' with the actual value which SF used '\r\u003Cbr\u003E' in the translation workbench but still no luck. Is there any other way to display the line break?
I would have to autopopulate a field in Case object from Account object.    The field value should be colored (Eg: Green) or highlighted.  How can I accomplish this using a formula ?
I created a button on detail page. I have access to that button (since i'm an admin). However, when I logged in as a different user whose profile is ABC, It throws an alert 'Insufficient access'.   FYI,  it's a java script button which calls an apex class.

Could you please help me how to figure it out?  Thanks
Hi,   It is throwing an error  "Error: Compile Error: Variable does not exist: com.ParentId at line 9 column 7".

Could someone please help me what's wrong here?

trigger CaseCommentsUpdate on Case (after insert, after update) {

List<CaseComment> NewComment = new List<CaseComment>();
    
    for(Case ca: Trigger.new){
    if(ca.Next_Contact_Date__c <= Today() && ca.status = 'Client Action Required' )
        
        CaseComment com = new CaseComment();
      com.ParentId = ca.id;
        com.CommentBody= ca.description;
        NewComment.add(com) ;                            

}}
When the system automatically does something, why does the history show it was a user in the system?  If something is automatically done by the system, can we have the User read something like “CRM” or “System.”

Please guide !

Thanks in advance
 
 
Is there a way to change audit fields' values  like 'Created by' value ? 
A casecomment should be created based upon the status on the Case.  I've tried to do with workflow - field update but I don't see any fields related to the CaseComment.  Can this be done through workflow/trigger?

Thanks
I have two custom Object , Salesorder and SalesYear.SalesYear has two records - 2015 and 2016.SalesOrder Has a lookup to Salesyear.What i am trying to achieve is when i click on new salesorder , it should auto populate a value for salesyear i.r 2016
For this i have written a trigger, and it doesnot works for some reason which i am not aware of.
Can some one guide me in achieving this?
 
trigger SalesOrderTrigger on gii__SalesOrder__c (before insert, before update) {



    Sales_year__c objSales_year = new Sales_year__c();
    objSales_year = [select id from Sales_year__c where name = '2016'];
    for(gii__SalesOrder__c objOrder : trigger.new){
        objOrder.Sales_Year__c= objSales_year.id ;
    }
}