• rajesh kamath 16
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hello Geeks,

I had a query and would be much appreciated for any kinda help.

Firstly, when I create a quote record, is it a standard behaviour that QLI's get created automatically?

Secondly, When I create a quote manually, QLI's gets created automatically, this is correct behaviour as per our functionality...

But when I insert the bulk quote records through dataloader, the quote gets created but its respective QLI's are not geting created...

Please let me know why this issue is happening and any answers on solving it. Prior thanks...
Hello Geeks,

I am stuck and need a help. I have a requirement as follows, Consider a user sends an email with the body and an email subject line as "Subject: Hello 00001043" where 00001043 can be any case number. Now as per my requirement I need two things to be handled.
1. Firstly I need to parse the subject line of the email which user has sent and get the case number from the subject line and match the case number from the subject line with the case number of all the case records in the database. 
    a) If there are any matching case records with the case number from the subject line, then I simply need to attach the email in the email related list of the matched case record.

    b) If no case records are presents with the case number as per the subject line, then only I need to create a new case record with that email sent to be attached to this newly created case record.
    
I have used Email-to-case functionality, where whenever user sends any mail, a new case record gets created automatically irrespecttive of the case number mentioned in the subject line. Say the case with the case number in the subject line if already present in database still it creates new case record and attaches the email to new record. But I want the email to get attached to the old matched record instead of new case to be created.

To handle it I am using InboundEmailHandler code which I am triggering out using Email Service: Execute on Inbound by selecting that apex class but not getting a way out to proceed further. Can anyone help me out in the logic. I am attaching my entire code. Any help would be highly appreciated.

Thanks.

Code:

Global class EmailToCase implements Messaging.InboundEmailHandler
{
    Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope env ) 
    {
        //Create an inboundEmailResult object for returning the result of the email service.
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
                 
        //Convert the subject line to ignore the case so the program can match on lower case or upper case.
        String mySubject = email.subject.equalsIgnoreCase();
        
        //String to hold the numbers from the subjectLine
        String caseIdInSubjectLine = '';

        //Check if the numbers are present in the subjectLine
        for(String str : mySubject.split('(?!^)'))
        {
            //Fetch only the numbers from the subjectLine for comparision 
            if(str.isNumeric())
            {
                //Hold the numbers from the subjectLine into a String variable
                caseIdInSubjectLine += str;
            }
        }
        
        //Check if the subject line has a case number
        if(caseIdInSubjectLine != null || caseIdInSubjectLine!= '')
        {
            //List to insert case records to database
            List<Case> lstCaseRecordsToInsert = new List<Case>();
            
            //Fetch all the cases whose case number from the subject line matches with the case records from the database
            List<Case> matchingCases = [Select Id, CaseNumber, Subject, Description From Case Where CaseNumber = :caseIdInSubjectLine];
            
            //Check if there are matched case records
            if(!matchingCases.isEmpty())
            {
                //Simply handled if more than 1 case records with case number are being matched
                if(matchingCases.size() == 1)
                {
                    //Iterate over the matched case records
                    for(Case objMatchedCase : matchingCases)
                    {
                        //Here i want my email to be attached to the matched case
                    }        
                }
                else
                {
                    system.debug(Logginglevel.ERROR, 'EmailToCase.  Create a new case because we found '+matchingCases.size() + ' cases with the subject: "' + mainSubject + '"');
                }
            }
            else
            {
                //Create a new case record 
                Case objCaseToInsert = new Case();
                objCaseToInsert.SuppliedEmail = email.fromAddress;
                objCaseToInsert.SuppliedName = email.fromName;
                objCaseToInsert.Status = 'New';
                objCaseToInsert.Priority = 'Low';                
                objCaseToInsert.Origin = 'Email';
                
                //Subject from the email
                String extractedSubject = email.subject;        
                objCaseToInsert.Subject = extractedSubject;
                objCaseToInsert.Description = email.plainTextBody;
                
                //Add the case records to a list
                lstCaseRecordsToInsert.add(objCaseToInsert);
            }
            
            //If the list contains some values
            if(!lstCaseRecordsToInsert.isEmpty())
            {
                insert lstCaseRecordsToInsert;
            }
        }
        else
        {
            //No case number in the subject line, so do nothing
        }    
    }        
}
On creation of a Partner Community User from contact we are creating a account share record for contact's related account.
Also, case share record gets created automatically due to the created account share.
While updating contact's related account with another account, the account share which we have created gets deleted. Why?
We need to delete the case share record as well. But the case share record is not getting deleted. Please let us know the possible solutions.


It will be helpful if someoen can help
Hello Geeks,

I had a query and would be much appreciated for any kinda help.

Firstly, when I create a quote record, is it a standard behaviour that QLI's get created automatically?

Secondly, When I create a quote manually, QLI's gets created automatically, this is correct behaviour as per our functionality...

But when I insert the bulk quote records through dataloader, the quote gets created but its respective QLI's are not geting created...

Please let me know why this issue is happening and any answers on solving it. Prior thanks...
Hello Geeks,

I am stuck and need a help. I have a requirement as follows, Consider a user sends an email with the body and an email subject line as "Subject: Hello 00001043" where 00001043 can be any case number. Now as per my requirement I need two things to be handled.
1. Firstly I need to parse the subject line of the email which user has sent and get the case number from the subject line and match the case number from the subject line with the case number of all the case records in the database. 
    a) If there are any matching case records with the case number from the subject line, then I simply need to attach the email in the email related list of the matched case record.

    b) If no case records are presents with the case number as per the subject line, then only I need to create a new case record with that email sent to be attached to this newly created case record.
    
I have used Email-to-case functionality, where whenever user sends any mail, a new case record gets created automatically irrespecttive of the case number mentioned in the subject line. Say the case with the case number in the subject line if already present in database still it creates new case record and attaches the email to new record. But I want the email to get attached to the old matched record instead of new case to be created.

To handle it I am using InboundEmailHandler code which I am triggering out using Email Service: Execute on Inbound by selecting that apex class but not getting a way out to proceed further. Can anyone help me out in the logic. I am attaching my entire code. Any help would be highly appreciated.

Thanks.

Code:

Global class EmailToCase implements Messaging.InboundEmailHandler
{
    Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope env ) 
    {
        //Create an inboundEmailResult object for returning the result of the email service.
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
                 
        //Convert the subject line to ignore the case so the program can match on lower case or upper case.
        String mySubject = email.subject.equalsIgnoreCase();
        
        //String to hold the numbers from the subjectLine
        String caseIdInSubjectLine = '';

        //Check if the numbers are present in the subjectLine
        for(String str : mySubject.split('(?!^)'))
        {
            //Fetch only the numbers from the subjectLine for comparision 
            if(str.isNumeric())
            {
                //Hold the numbers from the subjectLine into a String variable
                caseIdInSubjectLine += str;
            }
        }
        
        //Check if the subject line has a case number
        if(caseIdInSubjectLine != null || caseIdInSubjectLine!= '')
        {
            //List to insert case records to database
            List<Case> lstCaseRecordsToInsert = new List<Case>();
            
            //Fetch all the cases whose case number from the subject line matches with the case records from the database
            List<Case> matchingCases = [Select Id, CaseNumber, Subject, Description From Case Where CaseNumber = :caseIdInSubjectLine];
            
            //Check if there are matched case records
            if(!matchingCases.isEmpty())
            {
                //Simply handled if more than 1 case records with case number are being matched
                if(matchingCases.size() == 1)
                {
                    //Iterate over the matched case records
                    for(Case objMatchedCase : matchingCases)
                    {
                        //Here i want my email to be attached to the matched case
                    }        
                }
                else
                {
                    system.debug(Logginglevel.ERROR, 'EmailToCase.  Create a new case because we found '+matchingCases.size() + ' cases with the subject: "' + mainSubject + '"');
                }
            }
            else
            {
                //Create a new case record 
                Case objCaseToInsert = new Case();
                objCaseToInsert.SuppliedEmail = email.fromAddress;
                objCaseToInsert.SuppliedName = email.fromName;
                objCaseToInsert.Status = 'New';
                objCaseToInsert.Priority = 'Low';                
                objCaseToInsert.Origin = 'Email';
                
                //Subject from the email
                String extractedSubject = email.subject;        
                objCaseToInsert.Subject = extractedSubject;
                objCaseToInsert.Description = email.plainTextBody;
                
                //Add the case records to a list
                lstCaseRecordsToInsert.add(objCaseToInsert);
            }
            
            //If the list contains some values
            if(!lstCaseRecordsToInsert.isEmpty())
            {
                insert lstCaseRecordsToInsert;
            }
        }
        else
        {
            //No case number in the subject line, so do nothing
        }    
    }        
}