You need to sign in to do that
Don't have an account?
Helen Vico
Trigger to Change the Case Picklist Fields according to Corresponding Value Changes in the Subject Line Email
**Aim:** When the values change in the Case Email Subject Line, automatic changes are to be made to the corresponding values in the picklist values of case fields
The Subject line can contain up to 6 values (1 comment and 5 values). Values marked in Bold are always there. These values in the subject line are all options in the picklist of fields below.
Example of Subject Line: RE: <to be closed>,UK,London,Application,Salesforce,P3
**Acceptance Criteria**
The Status Field should be changed to ‘Closed’ if criteria:
1. subject line contains TEXT ‘To Be Closed’ or <To Be Closed>
2. The case field is: Service(Category) – ‘Application Support’, ‘User Support Service’
Then the other if the values below in the subject line also change then the corresponding case fields change too.
**Further Acceptance Criteria**
The subject line may contain ONE or MORE of the following Fields Text/Subject.
• Country = Always Choice of 18 countries
• Office = Optional Choice of 6 offices
• Service category – Always ONLY Application OR User Support
• Sub service category: Optional Choice of 11
• Priority = ‘P1’, ‘P2’, ‘P3’, P4
This is the trigger previously set up but it does not do the job:
My questions are?
1. Will the splitSubject[]; method populate the case field??
2. Does the following trigger ensure that the subject line values have to be in a certain order to autopopulate correctly?
3. Any comments how to improve the code?
Thanks
AutoCloseCasesFromEmail on Case (before insert) {
// <tobeclosed>,ireland,maynooth,salesforce,P3
for(Case caseToBeClosed: Trigger.new){
system.debug('caseToBeClosed.ContactEmail'+caseToBeClosed.SuppliedEmail);
system.debug('caseToBeClosed.Subject'+caseToBeClosed.Subject);
if(caseToBeClosed.Subject != null){ //IS EMPTY
if(caseToBeClosed.Subject.containsIgnoreCase('<to be closed>')
**Should we add in
if(caseToBeClosed.Service__ = ‘Application’ || ‘User Support’))
{**
String caseSubject = caseToBeClosed.Subject;
List<String> splitSubject = caseSubject.split(',');
if(splitSubject.size()>1){
caseToBeClosed.Country__c = splitSubject[1];
}
if(splitSubject.size()>2){
caseToBeClosed.Office__c = splitSubject[2];
}
caseToBeClosed.Category__c= 'Application Support';
/**/Should this last not be
//if(splitSubject.size()>3){caseToBeClosed.Service__c = splitSubject[3];
// and then change the below option of splitSubject.Size() to >4{ and >5 to reflect their place in the line and take out the last bit caseToBeClosed.Category__c= 'Application Support'; **
if(splitSubject.size()>3){
caseToBeClosed.Sub_Category__c = splitSubject[3];
}
if(splitSubject.size()>4){
caseToBeClosed.Priority = splitSubject[4];
}
caseToBeClosed.Status = 'Closed';
}
}
}
}
The Subject line can contain up to 6 values (1 comment and 5 values). Values marked in Bold are always there. These values in the subject line are all options in the picklist of fields below.
Example of Subject Line: RE: <to be closed>,UK,London,Application,Salesforce,P3
**Acceptance Criteria**
The Status Field should be changed to ‘Closed’ if criteria:
1. subject line contains TEXT ‘To Be Closed’ or <To Be Closed>
2. The case field is: Service(Category) – ‘Application Support’, ‘User Support Service’
Then the other if the values below in the subject line also change then the corresponding case fields change too.
**Further Acceptance Criteria**
The subject line may contain ONE or MORE of the following Fields Text/Subject.
• Country = Always Choice of 18 countries
• Office = Optional Choice of 6 offices
• Service category – Always ONLY Application OR User Support
• Sub service category: Optional Choice of 11
• Priority = ‘P1’, ‘P2’, ‘P3’, P4
This is the trigger previously set up but it does not do the job:
My questions are?
1. Will the splitSubject[]; method populate the case field??
2. Does the following trigger ensure that the subject line values have to be in a certain order to autopopulate correctly?
3. Any comments how to improve the code?
Thanks
AutoCloseCasesFromEmail on Case (before insert) {
// <tobeclosed>,ireland,maynooth,salesforce,P3
for(Case caseToBeClosed: Trigger.new){
system.debug('caseToBeClosed.ContactEmail'+caseToBeClosed.SuppliedEmail);
system.debug('caseToBeClosed.Subject'+caseToBeClosed.Subject);
if(caseToBeClosed.Subject != null){ //IS EMPTY
if(caseToBeClosed.Subject.containsIgnoreCase('<to be closed>')
**Should we add in
if(caseToBeClosed.Service__ = ‘Application’ || ‘User Support’))
{**
String caseSubject = caseToBeClosed.Subject;
List<String> splitSubject = caseSubject.split(',');
if(splitSubject.size()>1){
caseToBeClosed.Country__c = splitSubject[1];
}
if(splitSubject.size()>2){
caseToBeClosed.Office__c = splitSubject[2];
}
caseToBeClosed.Category__c= 'Application Support';
/**/Should this last not be
//if(splitSubject.size()>3){caseToBeClosed.Service__c = splitSubject[3];
// and then change the below option of splitSubject.Size() to >4{ and >5 to reflect their place in the line and take out the last bit caseToBeClosed.Category__c= 'Application Support'; **
if(splitSubject.size()>3){
caseToBeClosed.Sub_Category__c = splitSubject[3];
}
if(splitSubject.size()>4){
caseToBeClosed.Priority = splitSubject[4];
}
caseToBeClosed.Status = 'Closed';
}
}
}
}
jkfin codkfm
Goa Sky Lottery Result (https://www.jkfinco.com/goa-sky-lottery-result-check-gova-sky-lottery-result-today/) Check Gova Sky Lottery Result Today