• Jithesh Vasudevan
  • NEWBIE
  • 125 Points
  • Member since 2016
  • Senior Engineer
  • Suyati Technologies

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 53
    Replies
Hi All,

I am creating a filter with checkboxes, I want when case comment checkbox is true then all comment associated with case are shown and when we check checkbox Email, Then only comments which are added by mail should be shown means-
  • If Email is check for email-to-case then only comment are shown which startsWith To:
  • and If Case Comment is checked then except To: comments should be shown.
I don't know startsWith is used in SOQL or not but i Used like operater but it is showing error please help me to find the correct query

My sample code are -
if(filterLabel.isEmpty() && commentFilter==true){
    System.debug('Inside custom setting Enable If query');
    String srchValue = 'To:';
    string tempInput = '%' + srchValue + '%';
    commentQuery = commentQuery + ' And CommentBody NOT LIKE \'%' + srchValue + '%\'';
    System.debug('Inside if of custom setting check'+commentQuery);
}
else if(!filterLabel.isEmpty() && commentFilter==true && !filterLabel.contains('Email')){
    String srchValue = 'To:';
    string tempInput = '%' + srchValue + '%';
    commentQuery = commentQuery + ' And CommentBody LIKE \'%' + srchValue + '%\'';
    System.debug('Inside first else of custom setting check'+commentQuery);
}
else if(!filterLabel.isEmpty() && !commentFilter==true && !filterLabel.contains('Email')){
    commentQuery = commentQuery +' And Createdby.Id IN: Ids';
    System.debug('Inside second else of custom setting check'+commentQuery);
}
else if(!filterLabel.isEmpty() && !commentFilter==true && FilterStringValue=='Email' && filterLabel.contains('Email')){
    String srchValue = 'To:';
    string tempInput = '%' + srchValue + '%';
    commentQuery = commentQuery + ' And CommentBody LIKE \'%' + srchValue + '%\'';
    System.debug('Inside third else of custom setting check'+ commentQuery);
}
else if(!filterLabel.isEmpty() && commentFilter==true && FilterStringValue=='Email' && filterLabel.contains('Email')){
    commentQuery = commentQuery;
    System.debug('Inside fourth else of custom setting check'+ commentQuery);
}
else if(!filterLabel.isEmpty() && commentFilter==true && filterLabel.contains('Email')){
    commentQuery = commentQuery;
    System.debug('Inside fifth else of custom setting check'+commentQuery);
}

I also used below query - 

String
startValue = 'To:';
   commentQuery = commentQuery + ' And CommentBody NOT LIKE '+ startValue +'%\'';

Regards,
Sangeet
Hi all,

I want to write a validation rule where picklist value country is US the phone number should display with country code +1 and Australia +61 and India  is +91 
 I have tried this 

ISPICKVAL( Country__c , "UK")  

AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+44]{3}[1-9]{1}[0-9]{9}"))

 
ISPICKVAL( Country__c , "USA")  
 AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+1]{2}[1-9]{1}[0-9]{9}"))

ISPICKVAL( Country__c , "India")  
 
AND( NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+91]{3}[1-9]{1}[0-9]{9}"))

ISPICKVAL( Country__c , "Australia")  
 AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+61]{3}[1-9]{1}[0-9]{9}"))

)

Thank you in advance 
sheeba
Hi Everyone,
I have an apex trigger that tracks field updates on the custom object Menu__c. When an field in the object Menu__c field set is changed, a new record is created under the custom object 'Menu Price Changes'. 

So far, I only track the field name that is changed and the old and new value. I also want to add the record name to be added to the new Menu Price Changes record, specifically the location name or the Menu Name. 

What would be the best way to do this? If anything it would be great to have a lookup value field for the Menu Name under the Menu Pice Changes object and have it automatically filled in when a field is changed on the Menu Object. 

Any help on this would be amazing!!! I think I am missing something small in my code. 

User-added imageUser-added image
 
trigger AccountHistoryTracker on Menu__c (after update) {

    final List<Schema.FieldSetMember> trackedFields = 
        SObjectType.Menu__c.FieldSets.MenuHistoryFieldSet.getFields();

    if (trackedFields.isEmpty()) return;

    final List<Menu_Price_Tracker__c> fieldChanges = 
        new List<Menu_Price_Tracker__c>();

    if(!trigger.isUpdate)
        return;

    for (Menu__c newAccount : trigger.new) {

        final Menu__c oldAccount = trigger.oldmap.get(newAccount.Id);

        for (Schema.FieldSetMember fsm : trackedFields) {

            String fieldName  = fsm.getFieldPath();
            String fieldLabel = fsm.getLabel();

            if (newAccount.get(fieldName) == oldAccount.get(fieldName))
                continue;

            String oldValue = String.valueOf(oldAccount.get(fieldName));
            String newValue = String.valueOf(newAccount.get(fieldName));

            if (oldValue != null && oldValue.length()>255) 
                oldValue = oldValue.substring(0,255);

            if (newValue != null && newValue.length()>255) 
                newValue = newValue.substring(0,255); 

            final Menu_Price_Tracker__c accountHistory = 
                new Menu_Price_Tracker__c();

            accountHistory.name         = fieldLabel;
            accountHistory.apiName__c   = fieldName;
            accountHistory.OldValue__c  = oldValue;
            accountHistory.NewValue__c  = newValue;

            fieldChanges.add(accountHistory);
        }
    }

    if (!fieldChanges.isEmpty()) {
        insert fieldChanges;
    }
}

 
When we use URL redirect in Site.com, do we really have to 'Publish Changes' after creating a URL redirect is created?
I have created one and tried to test the url I used and it did not work. Also, I have not published any changes yet though.
Just wondering if we have to publish it first before we test it.
Checking if there are any articles on schemaCache.objectDescribe().
Ex: SchemaCache.objectDescribe(fieldObj.objectName);
  Profile p= [Select Id from profile where Name='System Administrator'];
        User u=new User(firstname = 'ABC', 
                        lastName = 'XYZ', 
                        email = 's-abe=kureha.co.jp@example.com', 
                        Username = 's-ab@kureha.co.jp.sd', 
                        EmailEncodingKey = 'ISO-8859-1', 
                        Alias = 'ShAbe',
                        IsActive=true,
                        TimeZoneSidKey = 'America/Los_Angeles', 
                        LocaleSidKey = 'en_US', 
                        LanguageLocaleKey = 'en_US', 
                        ProfileId = p.Id);
        insert u;   
        Case c = new Case(Status='New',OwnerId=u.Id);     
        insert c; 
Hi All,

I am creating a filter with checkboxes, I want when case comment checkbox is true then all comment associated with case are shown and when we check checkbox Email, Then only comments which are added by mail should be shown means-
  • If Email is check for email-to-case then only comment are shown which startsWith To:
  • and If Case Comment is checked then except To: comments should be shown.
I don't know startsWith is used in SOQL or not but i Used like operater but it is showing error please help me to find the correct query

My sample code are -
if(filterLabel.isEmpty() && commentFilter==true){
    System.debug('Inside custom setting Enable If query');
    String srchValue = 'To:';
    string tempInput = '%' + srchValue + '%';
    commentQuery = commentQuery + ' And CommentBody NOT LIKE \'%' + srchValue + '%\'';
    System.debug('Inside if of custom setting check'+commentQuery);
}
else if(!filterLabel.isEmpty() && commentFilter==true && !filterLabel.contains('Email')){
    String srchValue = 'To:';
    string tempInput = '%' + srchValue + '%';
    commentQuery = commentQuery + ' And CommentBody LIKE \'%' + srchValue + '%\'';
    System.debug('Inside first else of custom setting check'+commentQuery);
}
else if(!filterLabel.isEmpty() && !commentFilter==true && !filterLabel.contains('Email')){
    commentQuery = commentQuery +' And Createdby.Id IN: Ids';
    System.debug('Inside second else of custom setting check'+commentQuery);
}
else if(!filterLabel.isEmpty() && !commentFilter==true && FilterStringValue=='Email' && filterLabel.contains('Email')){
    String srchValue = 'To:';
    string tempInput = '%' + srchValue + '%';
    commentQuery = commentQuery + ' And CommentBody LIKE \'%' + srchValue + '%\'';
    System.debug('Inside third else of custom setting check'+ commentQuery);
}
else if(!filterLabel.isEmpty() && commentFilter==true && FilterStringValue=='Email' && filterLabel.contains('Email')){
    commentQuery = commentQuery;
    System.debug('Inside fourth else of custom setting check'+ commentQuery);
}
else if(!filterLabel.isEmpty() && commentFilter==true && filterLabel.contains('Email')){
    commentQuery = commentQuery;
    System.debug('Inside fifth else of custom setting check'+commentQuery);
}

I also used below query - 

String
startValue = 'To:';
   commentQuery = commentQuery + ' And CommentBody NOT LIKE '+ startValue +'%\'';

Regards,
Sangeet
Hi all,

I want to write a validation rule where picklist value country is US the phone number should display with country code +1 and Australia +61 and India  is +91 
 I have tried this 

ISPICKVAL( Country__c , "UK")  

AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+44]{3}[1-9]{1}[0-9]{9}"))

 
ISPICKVAL( Country__c , "USA")  
 AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+1]{2}[1-9]{1}[0-9]{9}"))

ISPICKVAL( Country__c , "India")  
 
AND( NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+91]{3}[1-9]{1}[0-9]{9}"))

ISPICKVAL( Country__c , "Australia")  
 AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+61]{3}[1-9]{1}[0-9]{9}"))

)

Thank you in advance 
sheeba
Hello, 

We have a class and trigger in place which is now producing the error listed below. It is referencing an Apex Class and an Apex Trigger of where the issue is stemming from. 

Can someone help me figure out how I can correct this? 

Thank you!
 
Apex script unhandled trigger exception by user/organization: 005A0000005XYZb/00DA0000033432M

triggerUpdAssignedLead: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 101

Class.LeadTrigger.<init>: line 47, column 1
Trigger.triggerLead: line 3, column 1

Line 47  of the Class.LeadTrigger can be found in this class code below:  
for(User u : [Select Id, UserType, Contact.AccountId, Contact.Account.Member__c, Exclude_from_Zip_Placement__c From User Where isActive = true]){
 
public without sharing class LeadTrigger {
    //private static boolean alreadyExecuted = false;
    Private Set<String> OpenLeadStatus = new Set<String>{'Awaiting Decision','Initiating Contact','New', 'Quoting', 'Re-Engaged', 'Job Take'};
    Private String QuotingStatus = 'Quoting';
    Private String QuotingCampaignNumber = '34099';
    Private static String MODELER_LEAD = 'Modeler Lead';
    Private static String HOW_LEAD = 'Show Lead';
    Private static String STATUE = 'Statue';
    public static String ClosedStatus = 'Closed By EF';
    public static String ProjectDelayedStatus = 'Project Ending';
    //public static boolean isTest {get; set;}
    //public static boolean isTestUpdateLead {get; set;}
    public static boolean isUpdateLeadStatus {get; set;}
    public static boolean isUpdateHistoryLog {get; set;}
    
    //New class variable creatd for optimization - 10/2016
    //Prevent SOQL Query governor limit exception
    private Map<String,Id> recTypes = new Map<String,Id>();
    private final string queueInsideSalesId;
    private final string dummyCampaignId = null;
    private Map<Id, User> activeUsers = new Map<Id, User>();
    private Set<Id> excludedZipAssignUsers = new Set<Id>();
    
    //Creating class constructor to initialize class objects - 11/2017
    //Prevent SOQL Query governor limit exception
    public LeadTrigger(){
        //Retrieving RecordType information
        for(Schema.RecordTypeInfo rt : Lead.SObjectType.getDescribe().getRecordTypeInfos()){
            String rtName = rt.getName();
            if((rtName == MODELER_LEAD)||(rtName == SHOW_LEAD)){ 
                recTypes.put(rtName, rt.getRecordTypeId());
            }
        }
        
        //Retrieving values for the Lead Assignment - AssignLeads() method
        //Retrieving the default owner (Inside Sales Queue)
        for(QueueSobject queue : [Select QueueId From QueueSobject Where SobjectType = 'Assigned_Lead__c' and Queue.Name = 'Inside Sales']){
            queueInsideSalesId = queue.QueueId;
        }
        
        //Retrieving Dummy Campaign ID for Assigning New Leads to a Campaign
        for(Campaign c : [Select Id, Campaign_Number__c From Campaign Where Name Like '%Dummy%' Limit 1]){
            dummyCampaignId = c.Id;
        }
        
        // Retrieving Active Users List for Lead Assignment
        for(User u : [Select Id, UserType, Contact.AccountId, Contact.Account.Member__c, Exclude_from_Zip_Placement__c From User Where isActive = true]){
            //Retrieving Users excluded by Zip Assignment
            if(u.Exclude_from_Zip_Placement__c ==  true){
                excludedZipPlaceUsers.add(u.Id);
            }else{
                activeUsers.put(u.Id, u);
            }
        }
    }


This is the ApexTrigger code named referenced in the apex error code: 
Trigger.triggerLead: line 3, column 1
 
trigger triggerLead on Lead (after insert, before insert, before update, after update) {

    LeadTrigger lt = new LeadTrigger();
    if (Trigger.isInsert)
        lt.LeadInsertion(Trigger.New, Trigger.isBefore, Trigger.isAfter);
    else if (Trigger.isBefore)
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
    
    if (Trigger.isAfter) {
      lt.ReassignALOnClosedLeads(Trigger.New, Trigger.old, null);
      lt.AddToCampaign(Trigger.New, Trigger.oldMap);
      lt.ProcessQuotingLeads(Trigger.New, Trigger.old);
    } else 
      lt.PopulateAmbassador(Trigger.New, Trigger.old);   
      
    
    // 10/22/2015 Ambassador enhancement Tia Xuan 
    if (Trigger.isBefore && Trigger.isUpdate){
      lt.CreateLastVisitTask(Trigger.new);
      lt.CopyHistoryLog(Trigger.new, Trigger.oldMap);   
    }
}





 
Hi every one,

actually i wrote visual force page 
<apex:page standardController="account" contentType="Application/vnd.ms-excel">
    <apex:form>
    <apex:pageblock title="account">
        <apex:pageBlockTable value="{!account.contacts}" var="contacts">
            <apex:column value="{!contact.name}"/>
            <apex:column value="{!contact.phone}"/>
      </apex:pageBlockTable>
        </apex:pageblock>
   </apex:form>
</apex:page>

actually my intention is i want to know how to use contentType in vf page and how it display .
i wrote above program previed this program i am ot geeting error
but it s not showing any out put.

please let me know if any one knows about it 

Thank you
surender reddy

 
Hi,

I am planning to start Sales force developer training. Could you please guide be If there any structured documentation available in this forum to start.
If so could you please provide me the link
Hello Guys, We have around 10 case record types. We have one specific record type for our service cases. We want the cases to be assigned an auto case number whenever a new case is created. Auto case number shouldn't be assigned when cases are created in other record types. For ex: If there are 8 cases under this record type, I want the 9th case to to have SR-009 as the custom case number isntead of SR-020, assuming other recordtype cases are created. How do I acheive it?
Hi Everyone,
I have an apex trigger that tracks field updates on the custom object Menu__c. When an field in the object Menu__c field set is changed, a new record is created under the custom object 'Menu Price Changes'. 

So far, I only track the field name that is changed and the old and new value. I also want to add the record name to be added to the new Menu Price Changes record, specifically the location name or the Menu Name. 

What would be the best way to do this? If anything it would be great to have a lookup value field for the Menu Name under the Menu Pice Changes object and have it automatically filled in when a field is changed on the Menu Object. 

Any help on this would be amazing!!! I think I am missing something small in my code. 

User-added imageUser-added image
 
trigger AccountHistoryTracker on Menu__c (after update) {

    final List<Schema.FieldSetMember> trackedFields = 
        SObjectType.Menu__c.FieldSets.MenuHistoryFieldSet.getFields();

    if (trackedFields.isEmpty()) return;

    final List<Menu_Price_Tracker__c> fieldChanges = 
        new List<Menu_Price_Tracker__c>();

    if(!trigger.isUpdate)
        return;

    for (Menu__c newAccount : trigger.new) {

        final Menu__c oldAccount = trigger.oldmap.get(newAccount.Id);

        for (Schema.FieldSetMember fsm : trackedFields) {

            String fieldName  = fsm.getFieldPath();
            String fieldLabel = fsm.getLabel();

            if (newAccount.get(fieldName) == oldAccount.get(fieldName))
                continue;

            String oldValue = String.valueOf(oldAccount.get(fieldName));
            String newValue = String.valueOf(newAccount.get(fieldName));

            if (oldValue != null && oldValue.length()>255) 
                oldValue = oldValue.substring(0,255);

            if (newValue != null && newValue.length()>255) 
                newValue = newValue.substring(0,255); 

            final Menu_Price_Tracker__c accountHistory = 
                new Menu_Price_Tracker__c();

            accountHistory.name         = fieldLabel;
            accountHistory.apiName__c   = fieldName;
            accountHistory.OldValue__c  = oldValue;
            accountHistory.NewValue__c  = newValue;

            fieldChanges.add(accountHistory);
        }
    }

    if (!fieldChanges.isEmpty()) {
        insert fieldChanges;
    }
}

 
public class ELOUpload_Class {
   
    public static void ELOUpload_Method1 (List<ContentDocument> lstContentDoc) {
      
       //Create a set of all the incoming IDs
        Set<Id> contDocId = new Set<Id> (); 
            
        for (ContentDocument contDoc : lstContentDoc ) {
            
           contDocId.add(contDoc.Id);
          
        }
        system.debug('contDocId = ' + contDocId );  
        
        List <ContentDocumentLink> contDoclink = [SELECT Id, ContentDocumentId FROM ContentDocumentLink WHERE ContentDocumentId = '0692O0000003CSTQA2']; 
        
        system.debug('contDoclink   = ' + contDoclink );      

    }
}
Hi Guys - I am working with ContentFiles and am trying to get a list to populate with some values from the ContentDocumentLink object. The code above (with hardcoded value) works fine and returns the values. However when trying to do it referencing the set variable (contDocId) in the code below I get no values returned. The contDocId is being pulled correctly too (which is the hardcoded value).
public class ELOUpload_Class {
   
    public static void ELOUpload_Method1 (List<ContentDocument> lstContentDoc) {
      
       //Create a set of all the incoming IDs
        Set<Id> contDocId = new Set<Id> (); 
            
        for (ContentDocument contDoc : lstContentDoc ) {
            
           contDocId.add(contDoc.Id);
          
        }
        system.debug('contDocId = ' + contDocId );  
        
        List <ContentDocumentLink> contDoclink = [SELECT Id, ContentDocumentId FROM ContentDocumentLink WHERE ContentDocumentId IN :contDocId]; 
        
        system.debug('contDoclink   = ' + contDoclink );      

    }
}

Also here is the trigger so you can see all the code involved.
trigger ELOUpload_Trigger on ContentDocument (after insert) {
     ELOUpload_Class.ELOUpload_Method1 (Trigger.new);               
  }

Thank you!
Hi Team,
I am getting below error message while creating a custom object,
"Custom Object Limits Exceeded with a fresh salesforce account"

I have just registered for a fresh developer account in SFDC and not done any activity before this. 
Please advise.
I would like to have a VF page and controller that could ask user to click on any 3 of this information inside an array:

a = [["I have a thing"], ["I have thing", "I got something"]]

I know I can use repeat to
<apex:variable value="{!0}" var="v" />
<apex:repeat value="a" var="t">
<apex:commandLink action="{!showPopUp}">{!v}</apex:commandLink>
</apex:repeat>
<apex:variable value="{!v + 1}" var ="v" />



then it will print(in link form so that user can press) it according to :

*I have a thing*
*I have thing*
*I got something*

What I want is to have the VF page show information that map to the clicked one. Example, 

INSIDE "I have a thing", there is information such as gender=male, location=World and comments="something too good".
INSIDE "I got something", there is information such as gender =Female, location=Nowhere and comments="Not so good"

So when user pressed on "I have a thing". information such as  gender=male, location=World and comments="something too good" instead of other value. My main problem is I do not know how can I map this information to be printed on VF page. How can can I tell the VF page which one of these links is chosen and how to map the chosen one to the related information provided?

Please assist me in this or you can just tell me the algorithm and I will do it myself. please
When we use URL redirect in Site.com, do we really have to 'Publish Changes' after creating a URL redirect is created?
I have created one and tried to test the url I used and it did not work. Also, I have not published any changes yet though.
Just wondering if we have to publish it first before we test it.
Salesforce announced that now we can get developer name for record type more easily: https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_apex_developer_name.htm

What is the difference between old and new approach getting Developer Name for Record Types announced in Summer 18 release?
Can someone show examples to see the difference?
Thanks!
I have a class if ,else if condition , and the test class is not getting covered for ELSE IF condition. please help me.


CLASS:

String cNumber=contact.tocContact_ID__c;
                                List<tocSubscriber__c> ListtocSubscriber=[Select Id,Account_Number__c,Billing_Contact_Payer__c,Billing_Contact_Viewer__c from tocSubscriber__c where Billing_Contact_Payer__c=:cNumber OR Billing_Contact_Viewer__c LIKE :('%'+cNumber+'%')];
                                for(tocSubscriber__c billAddress :ListtocSubscriber)
                                {
                                   if(billAddress.Billing_Contact_Payer__c==cNumber)
                                   {
                                     listBillingAddress.add(new BillingAddress(billAddress.Account_Number__c,Label.MyTR_Billing_Contact_Payer_c));
                                   }
                                   else if(billAddress.Billing_Contact_Viewer__c.contains(cNumber))
                                   {
                                     listBillingAddress.add(new BillingAddress(billAddress.Account_Number__c,Label.MyTR_Billing_Contact_Viewer_c));
                                   }
                                }


TEST CLASS:
Contact C1 = TestDataUtility.getContactDetails (at.id);
            C1.tocContact_ID__c='C-TR678798';
            insert c1;  
            
                    
            tocSubscriber__c subsc1 = MyTRGenericTestDataUtility.getToSubcriber(at.Id);
            subsc1.Billing_Contact_Payer__c =C1.tocContact_ID__c;
            subsc1.Billing_Contact_Viewer__c = C1.tocContact_ID__c;
            insert subsc1;
 
How to put URL dynamically in HTML email template, i want to populate url dynamically otherwise on every instance i have to chance the URL.

Some one please suggest me what we have to do here.