• jkfin codkfm
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
**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';                             
                     } 
                 }         
             }  
         } 
 
Hi Guys,

I am trying to create a validation rule where if I pick a country a state would be required.  
Can someone please help me out. (both fields are pick lists)
I am trying to pull picklist values in to my component using schema and its methods. I am getting all the values through server controller, but in my component labels are not populating but it is showing picklist structure.

Lightning Component:

<aura:component controller="PickListController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="aname" type="Account" default="{'sObjectType':'Account'}"/>
    <aura:attribute name="picvalue" type="List"/>
   <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> 
        <lightning:input label="Enter Your Name: " value="{!v.aname.Name}"/>
        <lightning:input label="Phone Number: " value="{!v.aname.Phone}"/>
       <lightning:select value="{!v.aname.Rating}" label="Rating">       
            <option value="choose">Choose one...</option> 
            <aura:iteration items="{!v.picvalue}" var="s">
                <option value="{!s.value}"/>             
            </aura:iteration> 
        </lightning:select> 
    <lightning:button label="Submit" onclick="{!c.go}"/>
</aura:component>

Js:

({
    doInit : function(component) {        
        var pickvar = component.get("c.getPickListValuesIntoList");
        pickvar.setCallback(this, function(response) {
            var state = response.getState();
            if(state === 'SUCCESS'){
                var list = response.getReturnValue();
                component.set("v.picvalue", list);
            }
            else if(state === 'ERROR'){
                //var list = response.getReturnValue();
                //component.set("v.picvalue", list);
                alert('ERROR OCCURED.');
            }
        })
        $A.enqueueAction(pickvar);
    },
    go : function(component){
        var cvar = component.get("v.aname");
        var action = component.get("c.insertValues");
        action.setParams({acc: cvar});
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === 'SUCCESS'){
            var list1 = response.getReturnValue();
            //component.set("v.picklistValues", list);
            alert('Record Created Successfully '+list1);
            }
            else if(state === 'INCOMPLETE'){
                alert('Something is missing');   
            }
            else if(state === 'ERROR'){
                alert('Insertion Failed');   
            }
        })
        $A.enqueueAction(action);
    }
})

Server Controller:

public class PickListController {
    @AuraEnabled        
    public static List<String> getPickListValuesIntoList(){
        List<String> pickListValuesList = new List<String>();
        Schema.DescribeFieldResult fieldResult = Account.Rating.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for( Schema.PicklistEntry pickListVal : ple){
            pickListValuesList.add(pickListVal.getLabel());
            System.debug('Values in Rating are: '+pickListValuesList);
        }     
        return pickListValuesList;
    }
    @AuraEnabled        
    public static Id insertValues(Account acc){
        insert acc;   
        return acc.id;
    }
}

User-added image