• Karan Shah
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
I have a process builder which should send a Survey as an Email to the Contact associated with a Case. This is working in my developer instance but not in the customer sandbox. In the sandbox, even if I try to 'Send Email' from Survey Builder, the email is not received and Survey Invitation is not created.
Hello Experts,

I need help with this code to show only the words in the parent case description in the child case. At the moment the child case description lists all the keywords.
trigger CheckSecretInfo on Case (after insert, before update) {

	String childCaseSubject = 'Warning: Parent case may contain secret info';

	// Step 1: Create a collection containing each of our secret keywords
	Set<String> secretKeywords = new Set<String>();
	secretKeywords.add('Credit Card');
	secretKeywords.add('Social Security');
	secretKeywords.add('SSN');
	secretKeywords.add('Passport');
	secretKeywords.add('Bodyweight');


List<Case> casesWithSecretInfo = new List<Case>();
Set<String> KeyWords = new Set<String>();
for (Case myCase : Trigger.new){
if(myCase.Subject != childCaseSubject){

// Step 2 Loop through secretkeywords and add all offending words to a Set

for(String KeyWord: secretKeywords){
if(myCase.Description != null && myCase.Description.containsIgnoreCase(KeyWord)){
	secretKeywords.add(KeyWord);
    break;
    system.debug('Keywords are: ' + keyword);
}
}

system.debug('cases to create' + casesWithSecretInfo.size());
	//Loop through secretkeywords and if there is any secret keywords add case to be created

List<Case> casesToCreate = new List<Case>();
for(Case caseWithSecretInfo : casesWithSecretInfo){
    Case childCase = new Case();
    childCase.Subject = 'Warning: Parent case may contain secret info';
    childCase.ParentId = caseWithSecretInfo.Id;
    childCase.IsEscalated = true;
    childCase.Priority = 'High';
    childCase.Description = 'The following secret keywords were found: ' + KeyWords;
    casesToCreate.add(childCase);
}
    insert casesToCreate;
}
}

}
Thanks 
 

I apologize for a duplicate entry here. I made this entry earlier but my code has changed and I was unable to edit the previous entry.

 

I have a list ('names') which is being created by a VF page which contains the Names of other records. I am attempting to create a new child record (object : Product_Affected_Entry__c) for each of the entries in that list. That is working properly.

However, I am also attempting to query each record which those entries represents and place the recordID into the Vendor_Product__c field of the child record I am creating - and that field is only being populated in the first child record created.

I believe the problem may be in this portion of the trigger :
 

// get the ids for all vendor products and store in a map keyed by name
           Map<String, Id> subAccIdsByName=new Map<String, Id>();
System.debug('FIRSTsubAccIdsByName='+subaccNames);   
           for (Vendor_Product__c subAcc : [select id, Name from Vendor_Product__c where Name in :subAccNames]) 
                   {
                      subAccIdsByName.put(subAcc.Name, subAcc.id);
System.debug('subAcc Name and ID=' + subAcc.Name +'Id=' + subAcc.id);
                   }

System.debug('SECONDsubAccIdsByName=' + subAccIdsByName);
The FIRSTsubAccIdsName debug is producing :
 
FIRSTsubAccIdsByName={}

But the SECONDsubAccIdsName debug is only producing :
 
SECONDsubAccIdsByName={Red=a7v5600000000O3AAI}
And later this portion of the trigger :
 
String temp = newContract.Products_Affected3__c;
                 temp = temp.replace(']','');
                 temp = temp.replace('[','');
                 String[] all = temp.split(',');

                 for(String productsonpolicy: all)

                 {

                    productsonpolicy = productsonpolicy.normalizeSpace();
System.debug('productsonpolicy'+productsonpolicy);
                    //for(String productsonpolicy: newContract.Products_Affected3__c.split(',')){

                    Product_Affected_Entry__c ssoc = new Product_Affected_Entry__c(

                            //Name = productsonpolicy,
                            Policy__c = newContract.Id,
                            Vendor__c = newContract.Vendor__c,
                            Vendor_Product__c = subAccIdsByName.get(productsonpolicy), // GET THE SUB ACCOUNT ID BASED ON NAME
                            Policy_and_Product__c = newContract.Name + '~' + subAccIdsByName.get(productsonpolicy)); 
                            //Contract_Start_Date__c = newContract.Contract_Start_Date__c,
                           // Contract_End_Date__c = newContract.Contract_End_Date__c,
                           // Logo_Usage_Allowed__c = 'Yes');

                    subs.add(ssoc);
                 }
              } 
           }

           upsert subs ;

The 'productsonpolicy' debug is passing through multiple times and properly producing a properly stripped single value each time.

Here is the full trigger :
 
trigger AutoCreateSubsServOnContrOv on Policy_Profile__c (After insert, after update) 
        {
           List<Product_Affected_Entry__c> subs = new List<Product_Affected_Entry__c>();

           // get the full list of sub account names for all records being processed by the trigger

           List<String> subAccNames=new List<String>();

           for (Policy_Profile__c newCont : Trigger.New) 
           {
              if (newCont.Products_Affected3__c != '[]') 
              {
                 // split out the multi-select picklist using a comma delimiter
System.debug('Products_Affected3__c ' + newCont.Products_Affected3__c);

                 String temp = newCont.Products_Affected3__c;
                 temp = temp.replace(']','');
                 temp = temp.replace('[','');
                 String[] all = temp.split(',');
                 subAccNames.addAll(all);
                 for (String acctName : all) 
System.debug('acctname ' + acctName);
              }
           }

           // get the ids for all vendor products and store in a map keyed by name
           Map<String, Id> subAccIdsByName=new Map<String, Id>();
System.debug('FIRSTsubAccIdsByName='+subaccNames);   
           for (Vendor_Product__c subAcc : [select id, Name from Vendor_Product__c where Name in :subAccNames]) 
                   {
                      subAccIdsByName.put(subAcc.Name, subAcc.id);
System.debug('subAcc Name and ID=' + subAcc.Name +'Id=' + subAcc.id);
                   }

System.debug('SECONDsubAccIdsByName=' + subAccIdsByName);

           //For each position processed by the trigger, add a new  

           //Product_Affected_Entry__c record for the specified Products_Affected3__c.  

           //Note that Trigger.New is a list of all the new positions  

           //that are being created.  

           for (Policy_Profile__c newContract : Trigger.New) 
           {
              if (newContract.Products_Affected3__c != '[]') 
              {
                 // split out the multi-select picklist using a comma delimiter
System.debug('Products_Affected3__c ' + newContract.Products_Affected3__c);

                 String temp = newContract.Products_Affected3__c;
                 temp = temp.replace(']','');
                 temp = temp.replace('[','');
                 String[] all = temp.split(',');

                 for(String subsoncontract: all)
                 {

                    subsoncontract = subsoncontract.normalizeSpace();
System.debug('subsoncontract'+subsoncontract);
                    //for(String subsoncontract: newContract.Products_Affected3__c.split(',')){

                    Product_Affected_Entry__c ssoc = new Product_Affected_Entry__c(

                            //Name = subsoncontract,
                            Policy__c = newContract.Id,
                            Vendor__c = newContract.Vendor__c,
                            Vendor_Product__c = subAccIdsByName.get(subsoncontract), // GET THE SUB ACCOUNT ID BASED ON NAME
                            Policy_and_Product__c = newContract.Name + '~' + subAccIdsByName.get(subsoncontract)); 
                            //Contract_Start_Date__c = newContract.Contract_Start_Date__c,
                           // Contract_End_Date__c = newContract.Contract_End_Date__c,
                           // Logo_Usage_Allowed__c = 'Yes');

                    subs.add(ssoc);
                 }
              } 
           }

           upsert subs ;

        }

I'm really at a loss here. Can anybody give any insight to this ? I really appreciate it.

Thank you.
 



 

  • August 14, 2015
  • Like
  • 0