• fiona gentry
  • SMARTIE
  • 710 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 112
    Questions
  • 47
    Replies
Here there is a Trigger which calls Trigger handler and in turn Trigger handler calls the apex class,this  apex class is to create tasks on Case record 
and the goal here is to prevent a Task from being created for 2 scenarios
  • First  Task with the Action__c field being ‘airtel account contact Research’ and once user creates a Task with Action__c as "‘airtel account contact Research’"
  • then they should only  able to create second  Task with Action__c as '1st airtel contact'',

Now after these 2 tasks creation is done then user can create any task with any picklist value in Action__c field

Here is Trigger which calls TaskTriggerHandler
TaskTrigger
trigger TaskTrigger on Task (before insert) {
    if(Trigger.isBefore&&Trigger.isInsert){
        TaskTriggerHandler.beforeInsert(Trigger.New);
    }    
}

Here is TaskTriggerHandler 
public class TaskTriggerHandler {
    
    public static void beforeInsert(List<Task> tasks){
        final string ERTTRECORDTYPENAME = 'ERTT_Task_Record_Type'; // Filter String to get the ERTT Task REcordType Id
        Id recordTypeId_ERT = [select id, DeveloperName from RecordType where sobjecttype = 'Task' AND developername =: ERTRECORDTYPENAME].Id;
        
        List<Task> ERTTasks = new List<Task>();
        Set<Id> caseIdset = new Set<Id>();
        
        for(Task taskProcess : tasks){
            
           
            // Functionality Added to Validate only the ERTT_Task_Record_Type Record type. 
            if(taskProcess.RecordTypeId == recordTypeId_ERT && taskProcess.Action__c != 'airtel account contact Research' )
            {
                ERTTasks.add(taskProcess);
                if(taskProcess.WhatId != null)
                {
                   caseIdset.add(taskProcess.WhatId);
                }
            }
        }
     
        // Making sure there is data in the ERTT Tasks and What Id of the Tasks 
        if(!ERTTasks.isEmpty() && !CaseIdset.isEmpty())
        {
           ERTT_TaskCreationValidation.isairtelAccountResearchcompleted_New(ERTTasks,CaseIdset);
           
            
           
        }
    }
    
}

Here is Apex class with Logic written
 
public class ERTT_TaskCreationValidation {
    
   
     public static void isairtelAccountResearchcompleted_New(List<Task> ERTTTasks,Set<Id> caseIdset)    {
        list<Task> lstTAsk=new list<Task>();
		map<Id, Case> mapCaseWithTaskList = new  map<Id, Case>([select id, (Select id, Action__c from Tasks )  from Case where Id in: caseIdset]); 
        for(Task t : ERTTTasks)
        {
            Boolean validationFlag = true;
            Boolean validationFlag2 = true;
            System.debug('mapCaseWithTaskList.gett.WhatId.tasks'+ mapCaseWithTaskList.get(t.WhatId).tasks);
            if(mapCaseWithTaskList.get(t.WhatId).tasks.size()>0)
            	lstTAsk.add(mapCaseWithTaskList.get(t.WhatId).tasks);
            for(Task t1:  mapCaseWithTaskList.get(t.WhatId).tasks){
                if(t1.Action__c == 'airtel account contact Research')
                {
                    validationFlag = false;
                }
            }
            if(validationFlag){
                t.addError('Please Create a task for airtel account contact Research before creating any other Task');
            }
System.debug(' lstTAsk' +lstTAsk);
            if(lstTAsk.size()==2 && t.Action__c == '2nd field'){
                     validationFlag2=false;
                 }
                 if(validationFlag2){
                    t.addError('Please Create a task for 2nd field before creating any other Task');
                 }
            
        }
    }
    

}

Now the problem is when Task is getting created at Case ,the second Error message is thrown which is "Please Create a task for 2nd field before creating any other Task" whereas requirment is to first show the first error message 'Please Create a task for airtel account contact Research before creating any other Task' and then the second error message
User-added image


'Please Create a task for 2nd field before creating any other Task'

Any idea what is going wrong in the apex class ?

Your reply with  resolution is appreciated

Regards

Fiona

 
Hi folks,

How to resolve the this error in the  logic of the trigger handler class
 
Method does not exist or incorrect signature: void add(Object) from the type Set<Id>

Here is trigger apex
 

trigger TaskTrigger on Task (before insert) {
    if(Trigger.isBefore&&Trigger.isInsert){
        TaskTriggerHandler.beforeInsert(Trigger.New);
    }    
    
    Map<Id, Task> mapTaskWithRelatedTask = new Map<Id, Task>();
Set<Id> setWhatIds = new Set<Id>();

for (Task objTask : Trigger.New) {
    mapTaskWithRelatedTask.put(objTask.whatId, objTask);
}
for (AggregateResult ar : [SELECT whatId FROM Task WHERE whatId IN: mapTaskWithRelatedTask.keySet() AND Action__c = 'Airtel  contact' GROUP BY whatId]) 
{
    setWhatIds.add(ar.get('whatId'));
}
for (Task objTask : mapTaskWithRelatedTask.values()) {
    if (!setWhatIds.contains(objTask.whatId)) {
        objTask.addError('Please Create a task for airtel account contact Research before creating any other Task');
    }
}
}
Your help is appreciated

Regards

Fiona
 
Hi Folks,

I have a apex class which i am trying to execute via Developer console Anonymous apex
ERTT_TaskCreationValidation.isAccountResearchcompleted('01236000000OnsMAAS','01236000000OnsKAAS');

but getting the error as
Line: 1, Column: 28
Method does not exist or incorrect signature: void isAccountResearchcompleted(String, String) from the type ERTT_TaskCreationValidation


Here is Apex class for reference
 
public class ERTT_TaskCreationValidation {
    public static void isAccountResearchcompleted(List<Task> ERTTTasks,Set<Id> caseIdset)
    {
        map<id, Task> mapTaskDetails ;
		map<Id, Case> mapCaseWithTaskList = new  map<Id, Case>([select id, (Select id, Action__c from Tasks )  from Case where Id in: caseIdset]); 
        for(Task t : ERTTasks)
        {
            Boolean validationFlag = true;
            for(Task t1:  mapCaseWithTaskList.get(t.WhatId).tasks)
            {
                if(t1.Action__c == 'Airtel Account Research')
                {
                    validationFlag = false;
                }
            }
            if(validationFlag)
            {
                t.addError('Please Create a task for Airtel Account Research before creating any other Task');
            }
            
        }
    }
}

Your response in appreciated

Regards
Fiona
 
Hi Folks,

Apex class shows only 48% whereas wrote tests for all lines,any idea why shows only 48%

apex code
 
public class ETRR_TaskCreationValidation {
    public static void isairtel account contactResearchcompleted(List<Task> ETRRTasks,Set<Id> caseIdset)
    {
        map<id, Task> mapTaskDetails ;
        map<Id, Case> mapCaseWithTaskList = new  map<Id, Case>([select id, (Select id, Action__c from Tasks )  from Case where Id in: caseIdset]); 
        for(Task t : ETRRTasks)
        {
            Boolean validationFlag = true;
            
            for(Task t1:  mapCaseWithTaskList.get(t.WhatId).tasks)
            {
                if(t1.Action__c == 'airtel account contact Research')
                {
                    validationFlag = false;
                }
            }
            
            if(validationFlag)
            {
                t.addError('Please Create a task for airtel account contact Research before creating any other Task');
            }
            
        }
    }
    public static void is1stairtel contactcompleted(List<Task> ETRRTasks,Set<Id> caseIdset)
    {
        map<id, Task> mapTaskDetails ;
        map<Id, Case> mapCaseWithTaskList = new  map<Id, Case>([select id, (Select id, Action__c from Tasks )  from Case where Id in: caseIdset]); 
        for(Task t : ETRRTasks)
        {
            Boolean validationFlag = true;
            if(mapCaseWithTaskList.get(t.WhatId).tasks.size()>1){
                for(Task t1:  mapCaseWithTaskList.get(t.WhatId).tasks)
                {
                    
                    if( t1.Action__c == '1st airtel contact')
                    {
                        validationFlag = false;
                    }
                    
                }
                
            }
            if(validationFlag)
            {
                t.addError('Please Create a task for 1st airtel contact before creating any other Task');
            }
            
        }
    }
}

Here is test class
 
@isTest
public class ETRR_TaskCreationValidation_Test {
    
    @isTest
    private static void testETRRValidation()
    {
        Id caseRecordTypeId = [select id from Recordtype where DeveloperName  = 'Executive_Response' and sobjecttype = 'Case' ].Id ;
        Id taskrecordTypeId_ETRR = [select id, DeveloperName from RecordType where sobjecttype = 'Task' AND developername = 'ETRR_Task_Record_Type' ].Id; 
        
        Case c = new case(recordtypeId = caseRecordTypeId);
        insETRR c;
        
        try
        {
            task t = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id );
            insert t;
            task t2 = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id );
            insert t2;
        }
        Catch(System.DmlException dmlex)
        {
            system.assETRREquals('FIELD_CUSTOM_VALIDATION_EXCEPTION', dmlex.getDmlStatusCode(0));     
            task t = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id, Action__c = 'airtel account airtel contact Research' );
            insert t; 
            task t1 = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id );
            insert t1; 
             task t2 = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id, Action__c = '1st airtel contact' );
            insert t2; 
            task t3 = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id );
            insert t3; 
            
        }
        
        
    }
}

Your response is appreciated

Regards
Fiona
Dear folks,

have this Record Triggered  (Action & Related Records)Flow which creates a Task for a cases for some record types..

Here is what Flow does

Start Conditon Requirements
The triggering record met the condition requirements.
Entry Conditions
1. Owner_Type__c (User) Equals User
2. RecordTypeId (0012344441Q000000P57QQAS) Equals 0012344441Q000000P57QQAS
3. RecordTypeId (001234444Q000000P57QQAS) Equals 001234444Q000000P57QQAS
Logic: Advanced Logic ((2 OR 3) AND 1)

Get Records: All Tasks On Case
Find all Task records where

Action__c Does not equal 1st Contact
Store the values of these fields in All_tasks_On_Case: Id
Result

Successfully found records.

Decision:Check for Null Tasks
Outcome executed: Task_Exists
Outcome conditions

{!All_tasks_On_Case} ([Task (00T2C00000JFYmkUAH)]) Is null false
All conditions must be true (AND)

New Task(Quick Actions) Create New Task
Inputs

OwnerId = {!$Record.OwnerId} (00536000006YCPvAAO)
ActivityDate = {!CreateTaskNow} (6/21/2022 9:48 PM)

Here is the Error

Info
Error Occurred:

You are unable to change ownership of a New Task record.

How to resolve this error

Regards

Fiona
 
Hi Folks,

How do i  add New Task With Case for particular Record Type within the case Related tab here

User-added image
Your reponse is appreciated

Regards
Fiona
 

Dear Folks,

Need to show  a flow validation message to restrict Task creation on Case for a particular Task Record Type.

Problem is I dont see a "New Task" available on Case Record page ,but when i open the Case record ,I see the "New Task" button and the picklist to select the Task,also i checked there is no explicit mention of Task related to Case object like Look up or Master detail except WhatId
can anyone explain how this New Task is shown up in Case page?
User-added image

Your response is highly appreciated

Regards
Fiona

Dear folks,

Wrote the test class for Trigger test class ,can't see the coverage ,can someone review the class and suggest the fix

Error i get is 


Class.PrepaidEmailSubjectAswTest.PrepaidEmailSubjectAswTest: line 7, column 1
 
@isTest 
private with sharing class  PrepaidEmailSubjectAswTest {
    
     testmethod static void ert_PrepaidEmailSubjectAswTest(){
        Test.starttest();
        
        Id RecordTypeIdCase = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Executive Response').getRecordTypeId();
        Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email',RecordTypeId = RecordTypeIdCase,Subject = 'Airtel');  
        
        insert cas; 
        
        Test.stoptest();
        
        
    }
}
Here is the Trigger apex which has label EmailSubjectAsw and the label has value 'Airtel',
this apex  trigger solution shows how to parse out an   Email Subject in email-to-case using RegEx and search for 
target word "Airtel"(case insensitive and exact match only )
trigger PrepaidEmailSubjectAsw on Case (before insert) {
    
    String searchWords;
    List<String> strings;
    
    List<Group> lstPre = [SELECT Id from Group where Type = 'Queue' AND DeveloperNAME = 'Prepaid_Queue'  LIMIT 1];
    
    id rtid = Schema.Sobjecttype.Case.getRecordTypeInfosByName().get('Executive Rep').getRecordTypeId();
    
    if(Trigger.isbefore && Trigger.IsInsert){      
        for (Case c : Trigger.new) {
            searchWords = Label.EmailSubjectAsw;
            strings = searchWords.split(',');
            
            
            if(c.Subject!=Null  && c.RecordTypeId==rtid && lstPre.size() > 0){
                if (isStringInTarget(strings, c.Subject)) {
                    
                    
                    c.OwnerId =lstPre[0].id;    
                }                             
            }    
        }
    }
    
    
    public static Boolean isStringInTarget(List<String> strings, String target) {
        String strRegEx = '(?i)\\b(';
        
        for (String s : strings) {
            strRegEx = strRegEx + s + '|'; 
        }
        strRegEx = strRegEx.removeEnd('|'); 
        strRegEx = strRegEx + ')\\b';
        Matcher matcher=Pattern.compile(strRegEx).matcher(target);
        Boolean result= matcher.find();
        return result;
    }
}

Your help is appreciated

Regards

Fiona
Dear folks,

Wrote the test class for Trigger test class ,can't see the coverage ,can someone review the class and suggest the fix
 
@isTest 
private class EmailSubjectAswTest {
    
     private static testmethod void EmailSubjectAswTestTest(){
    
    
        Id RecordTypeIdCase = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Executive Rep').getRecordTypeId();
        Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email',RecordTypeId = RecordTypeIdCase,Subject = 'Airtel');  
        
        insert cas; 
    
    
   
     
    }
}

Here is the Trigger apex which has label EmailSubjectAsw and the label has value 'Airtel'
 
trigger PrepaidEmailSubjectAsw on Case (before insert) {
    
    String searchWords;
    List<String> strings;
    
    List<Group> lstPre = [SELECT Id from Group where Type = 'Queue' AND DeveloperNAME = 'Prepaid_Queue'  LIMIT 1];
    
    id rtid = Schema.Sobjecttype.Case.getRecordTypeInfosByName().get('Executive Rep').getRecordTypeId();
    
    if(Trigger.isbefore && Trigger.IsInsert){      
        for (Case c : Trigger.new) {
            searchWords = Label.EmailSubjectAsw;
            strings = searchWords.split(',');
            
            
            if(c.Subject!=Null  && c.RecordTypeId==rtid && lstPre.size() > 0){
                if (isStringInTarget(strings, c.Subject)) {
                    
                    
                    c.OwnerId =lstPre[0].id;    
                }                             
            }    
        }
    }
    
    
    public static Boolean isStringInTarget(List<String> strings, String target) {
        String strRegEx = '(?i)\\b(';
        
        for (String s : strings) {
            strRegEx = strRegEx + s + '|'; 
        }
        strRegEx = strRegEx.removeEnd('|'); 
        strRegEx = strRegEx + ')\\b';
        Matcher matcher=Pattern.compile(strRegEx).matcher(target);
        Boolean result= matcher.find();
        return result;
    }
}

Your help is appreciated

Regards

Fiona
Dear Friends, 

At a conceptual level,  below  is what  Trigger code is doing  

1 Query for Salesforce queue name Prepaid
2 Iterate over the Email 2 Case records for Record Type as "Executive Response " I get (from Trigger.new)
3 Calls .contains() on the Case's Subject to see if  target word "Airtel" exists
4 Update the OwnerId to  queue ​​​​​​​
trigger PrepaidEmailSubjectAsw on Case (before insert) {

    if(Trigger.isBefore && Trigger.isDelete){
        
      List<Group> lstPre = [SELECT Id from Group where Type = 'Queue' AND DeveloperNAME = 'Prepaid'  LIMIT 1];
        if(!lstPre.isEmpty()){
            for (Case c : Trigger.new) {
                
                   if(c.Subject!=Null && c.Subject.Contains('Airtel')==True && c.RecordType.Name == 'Executive Response'){
                       c.ownerId = lstPre[0].Id;
            
        }
        
    }
 update lstPre;
    }
    }
}

Problem is i dont see the Case owner got changed to queue as Prepaid,can you suggest what mistake is there

User-added image
Thanks In Advance

Regards

Fiona

 
Dear Friends,

At a conceptual level,  need a Trigger code  to do four things 

1 Query for Salesforce queue name Prepaid
2 Iterate over the Email 2 Case records for Record Type as "Executive Response " I get (from Trigger.new)
3 Call .contains() on the Case's Subject to see if your target word exists
4 Update the OwnerId to your queue if it does

Thanks In Advance,your help is highly appreciated

Fiona
Dear Folks,

I have a queue named "Prepaid" and want to route Email 2 case to a particular Prepaid Queue  when emails  contains "Airtel" in Subject

Wrote a Trigger for Email 2 case queue such that  it triggers when Email subject is AIRTEL(Space Before and After)

Step 1:
Created below Custom Label with   string to match against. As I want to route emails which contains Airtel in Subject to a above Prepaid queue

EmailSubjectAsw = “Airtel”

Step 2:
Created Case Trigger (beforeInsert) and used this code snippet below:
 
trigger PrepaidEmailSubjectAsw on Case (before insert) {

					
					public static void setCaseType(List<Case> records) {
					String searchWords;
					List<String> strings;
					for(Case c : records) {
						searchWords = Label.EmailSubjectAsw;
						strings = searchWords.split(',');
						if (isStringInTarget(strings, c.Subject)) {
							continue; 
						}
							} // end for loop
				} 
				public static Boolean isStringInTarget(List<String> strings, String target) {
					String strRegEx = '(?i)\\b(';
					// case insensitive and exact match only 
					for (String s : strings) {
						strRegEx = strRegEx + s + '|'; // build up a list of strings using | separator 
					}
					strRegEx = strRegEx.removeEnd('|'); // get rid of the last OR
					strRegEx = strRegEx + ')\\b';
					Matcher matcher=Pattern.compile(strRegEx).matcher(target);
					Boolean result= matcher.find();
					return result;
					ID queueId = [SELECT Queue.Id FROM queuesobject WHERE queue.name='Prepaid'];
					Case.OwnerId = queueId;
				}
				}

Getting Error as
 
Line 26 Illegal assignment from List<QueueSobject> to Id
            Line 27 A value cannot be stored to OwnerId in type Case
            Line 26 Unreachable statement


Can some one provide resolution above and  fix the Trigger code 


Thanks In Advance,your help is appreciated

Fiona



 
How To Make Record Triggered flow Only when Email subject is AIRTEL(Space Before and After)

Consider the scenario when i want to make   Record Triggered flow happen Only when Email subject contains airtel
IT SHOULD NOT TRIGGER for scenarios like

LOVEAIRTEL
COMEONAIRTELFANS

Something like Subject contains AIRTEL(Space Before and After)

Tried below subject with providing keyboard before and after space in Subject Value,but Flow is not getting triggered for word  AIRTEL

User-added image
Your help is appreciated

Fiona


 
Hi,

Developed this rule which is showing correct validation as per condition,but problem is after i ener the amount in settlement amount field basically the field is no more BLANK ,the validation message doesnt goes away 

User-added image


Here is the rule 
AND(
OR(
RecordType.Name = "Executive Response",
ISBLANK(Settlement_dollar_amount__c),
ISPICKVAL( Opened_By_Source__c, "Airtel/Fairshake"),
ISPICKVAL( Opened_By_Source__c, "Airtel - Radvocate"),
ISPICKVAL( Opened_By_Source__c, "Airtel - Radvocate/Fairshake")
)
&&
ISBLANK(Source_Name__r.Name)
,
OR
($Profile.Name = "EETR Case Worker", $Profile.Name = "EETR Reviewer",$Profile.Name = "EETR Coordinator")
)


Please let me know why the validation message doesnt goes away after i enter the settlment amount in the Case Record

Regards
Fiona
Hi ,

i need add Validation message must be triggered only for ERT users,from the thread (https://developer.salesforce.com/forums/ForumsMain?id=9062I000000Ue3aQAC )
got solution as
AND($Profile.Name = 'ERT users', ISBLANK(Settlement Dollar Amount), OR(RecordType.DeveloperName  = "recordtype_first",
RecordType.DeveloperName = "recordtype_second"))

Now i want to add a source picklist values in above rule ,how to do that where we have source picklist values as STR1/STR2, str3 - str4, and Str5 - Str6/Str7

Your help is appreciated

Regards

Fiona
Hi,

How To Make Below Changes in  Existing Case Field
  1. Make an existing filed named "Settlement Dollar Amount" field as required
  2. Add helper text to this feild "Settlement Dollar Amount"-
  3. Add validation message for this field "Settlement Dollar Amount"
  4. Validation message must be triggered only for ERT users
Your help is appreciated

Regards

Fiona
Dear Folks,

I need to build a record triggered flow which route cases for below conditions
  •    Email subject contains Telecommunication OR AWS
  •    Case with Record Types - Airtel OR  Vodafone 
  •    Picklist field when it has value as "Prepaid"

Your help with flow is highly appreciated
REGARDS.
Fiona

 
sHow to make a Public queue available to profile,for example created a queue for Case ,now would liket that only particular user should acess
Hi Folks,

I have a Email2case  setup where in i have set Up Email 2 Case to move to Customer escalations queue..

Now my question is  How do i make a case can't be re-opened if set to closed greater than 7 days. ,I DO NOT want to writre Trigger or Apex for this ,Is  it Possible to achieve this using flow?

Regards

Fiona

 
Hi,

I have a requirement Whenever HiringManager record is deleted,want to delete the Position as well ,Both HiringManager(Parent) and Position(Child) are custom objects,Position having lookup with HiringManager

In essence i cant  make this relationship of HiringManager(Parent) and Position(Child) like master detail but i want to achieve the functionity like whenever parent is deleted child should also get deleted

here is trigger code
trigger DeleteChild on HiringManager__c (before delete) {
    
    if(Trigger.isBefore && Trigger.isDelete){
        
        List<Position__c> lstPostns = [Select id,HiringManager__r.Name From Position__c Where id IN : Trigger.OldMap.KeySet() ];
        
        if(!lstPostns.isEmpty()){
            
            for(Position__c postns : lstPostns)
            {
                postns.id	= null;
                
            }
            
            upsert lstPostns;
        }
        
    }

}

Can you suggest what is goin wrong on above trigger

Regards

Fiona
Hi,

Dear folks,

Here is what i want to do and thankfully was able to get answer using thread below with List
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000BjjoQAC
,but now i am rewriting the same code using Map,but am getting error as 
 
Method does not exist or incorrect signature: void get(String) from the type Map
Here is what the end goal is 
 
For example, if s = "zbax" and k = 2, then the resulting integer would be 8 by the following operations:

Convert: "zbax" ➝ "(26)(2)(1)(24)" ➝ "262124" ➝ 262124
Transform #1: 262124 ➝ 2 + 6 + 2 + 1 + 2 + 4 ➝ 17
Transform #2: 17 ➝ 1 + 7 ➝ 8

Here is code with Map
public class SDASMapConvert {
    

    
    
public static Integer returnInteger(String z, integer k){
        Integer retInt;
        String key = 'abcdefghijklmnopqrstuvwxyz';

        List<String>myAlphabets = z.split('');
        Map<String, String> myMap = new Map<String, String>();
        String strarr = '';

       for (integer i = 0; i < myAlphabets.size(); i += 2) {
        myMap.put(myAlphabets[i], myAlphabets[i + 1]);
    }

    for (String s : myMap.keySet()) {
        System.debug(s + ' is ' + map.get(s));
        strarr += string.valueOf(s);
    }
        
        system.debug('strarr --> ' + strarr);
        String s = '';
        for(integer i = 0; i < k ; i++){
            system.debug(' strarr --> ' + strarr);
            Integer total = 0;
            for(String s1 : strarr.split('')){
                total += integer.valueOf(s1);
            }
            system.debug(' total --> ' + total);
            strarr = string.valueOf(total);
        }
        
        system.debug(' ************* ' + strarr);
        if(!string.isEmpty(strarr))
            retInt = integer.valueOf(strarr);
        
        system.debug(' ************* ' + retInt);
        
        return retInt;
    }
    


}

Regards
Fiona
Dear folks,

Here is what i want to do
 
For example, if s = "zbax" and k = 2, then the resulting integer would be 8 by the following operations:

Convert: "zbax" ➝ "(26)(2)(1)(24)" ➝ "262124" ➝ 262124
Transform #1: 262124 ➝ 2 + 6 + 2 + 1 + 2 + 4 ➝ 17
Transform #2: 17 ➝ 1 + 7 ➝ 8



Hence ,Wrote a apex class for To  convert string into an integer by replacing each letter with its position in the alphabet,but it doesnt seems working,error i get on Anonymus Console Window for below command
is 
Line: 14, Column: 1
System.TypeException: Invalid integer: a
Here is anonymous code
SDSAfterConvert.returnInteger();

Here is apex code
 
public class SDSAfterConvert {
    
    
public static List<Integer> returnInteger(){


List<Integer> inputList = new List<Integer>();
             
String[] myAlphabets = new String[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'g'};
 
for (String s1 : myAlphabets) {
   
    System.debug(s1);
    Integer d = integer.ValueOf(s1);
    inputList.add(d);
}
        
return inputList;
             
}
    
}



Regards,
Fiona​​​​​​​
 
Hi folks,

How to resolve the this error in the  logic of the trigger handler class
 
Method does not exist or incorrect signature: void add(Object) from the type Set<Id>

Here is trigger apex
 

trigger TaskTrigger on Task (before insert) {
    if(Trigger.isBefore&&Trigger.isInsert){
        TaskTriggerHandler.beforeInsert(Trigger.New);
    }    
    
    Map<Id, Task> mapTaskWithRelatedTask = new Map<Id, Task>();
Set<Id> setWhatIds = new Set<Id>();

for (Task objTask : Trigger.New) {
    mapTaskWithRelatedTask.put(objTask.whatId, objTask);
}
for (AggregateResult ar : [SELECT whatId FROM Task WHERE whatId IN: mapTaskWithRelatedTask.keySet() AND Action__c = 'Airtel  contact' GROUP BY whatId]) 
{
    setWhatIds.add(ar.get('whatId'));
}
for (Task objTask : mapTaskWithRelatedTask.values()) {
    if (!setWhatIds.contains(objTask.whatId)) {
        objTask.addError('Please Create a task for airtel account contact Research before creating any other Task');
    }
}
}
Your help is appreciated

Regards

Fiona
 
Hi Folks,

I have a apex class which i am trying to execute via Developer console Anonymous apex
ERTT_TaskCreationValidation.isAccountResearchcompleted('01236000000OnsMAAS','01236000000OnsKAAS');

but getting the error as
Line: 1, Column: 28
Method does not exist or incorrect signature: void isAccountResearchcompleted(String, String) from the type ERTT_TaskCreationValidation


Here is Apex class for reference
 
public class ERTT_TaskCreationValidation {
    public static void isAccountResearchcompleted(List<Task> ERTTTasks,Set<Id> caseIdset)
    {
        map<id, Task> mapTaskDetails ;
		map<Id, Case> mapCaseWithTaskList = new  map<Id, Case>([select id, (Select id, Action__c from Tasks )  from Case where Id in: caseIdset]); 
        for(Task t : ERTTasks)
        {
            Boolean validationFlag = true;
            for(Task t1:  mapCaseWithTaskList.get(t.WhatId).tasks)
            {
                if(t1.Action__c == 'Airtel Account Research')
                {
                    validationFlag = false;
                }
            }
            if(validationFlag)
            {
                t.addError('Please Create a task for Airtel Account Research before creating any other Task');
            }
            
        }
    }
}

Your response in appreciated

Regards
Fiona
 
Hi Folks,

Apex class shows only 48% whereas wrote tests for all lines,any idea why shows only 48%

apex code
 
public class ETRR_TaskCreationValidation {
    public static void isairtel account contactResearchcompleted(List<Task> ETRRTasks,Set<Id> caseIdset)
    {
        map<id, Task> mapTaskDetails ;
        map<Id, Case> mapCaseWithTaskList = new  map<Id, Case>([select id, (Select id, Action__c from Tasks )  from Case where Id in: caseIdset]); 
        for(Task t : ETRRTasks)
        {
            Boolean validationFlag = true;
            
            for(Task t1:  mapCaseWithTaskList.get(t.WhatId).tasks)
            {
                if(t1.Action__c == 'airtel account contact Research')
                {
                    validationFlag = false;
                }
            }
            
            if(validationFlag)
            {
                t.addError('Please Create a task for airtel account contact Research before creating any other Task');
            }
            
        }
    }
    public static void is1stairtel contactcompleted(List<Task> ETRRTasks,Set<Id> caseIdset)
    {
        map<id, Task> mapTaskDetails ;
        map<Id, Case> mapCaseWithTaskList = new  map<Id, Case>([select id, (Select id, Action__c from Tasks )  from Case where Id in: caseIdset]); 
        for(Task t : ETRRTasks)
        {
            Boolean validationFlag = true;
            if(mapCaseWithTaskList.get(t.WhatId).tasks.size()>1){
                for(Task t1:  mapCaseWithTaskList.get(t.WhatId).tasks)
                {
                    
                    if( t1.Action__c == '1st airtel contact')
                    {
                        validationFlag = false;
                    }
                    
                }
                
            }
            if(validationFlag)
            {
                t.addError('Please Create a task for 1st airtel contact before creating any other Task');
            }
            
        }
    }
}

Here is test class
 
@isTest
public class ETRR_TaskCreationValidation_Test {
    
    @isTest
    private static void testETRRValidation()
    {
        Id caseRecordTypeId = [select id from Recordtype where DeveloperName  = 'Executive_Response' and sobjecttype = 'Case' ].Id ;
        Id taskrecordTypeId_ETRR = [select id, DeveloperName from RecordType where sobjecttype = 'Task' AND developername = 'ETRR_Task_Record_Type' ].Id; 
        
        Case c = new case(recordtypeId = caseRecordTypeId);
        insETRR c;
        
        try
        {
            task t = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id );
            insert t;
            task t2 = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id );
            insert t2;
        }
        Catch(System.DmlException dmlex)
        {
            system.assETRREquals('FIELD_CUSTOM_VALIDATION_EXCEPTION', dmlex.getDmlStatusCode(0));     
            task t = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id, Action__c = 'airtel account airtel contact Research' );
            insert t; 
            task t1 = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id );
            insert t1; 
             task t2 = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id, Action__c = '1st airtel contact' );
            insert t2; 
            task t3 = new task(recordtypeId = taskrecordTypeId_ETRR, WhatId = c.Id );
            insert t3; 
            
        }
        
        
    }
}

Your response is appreciated

Regards
Fiona
Hi Folks,

How do i  add New Task With Case for particular Record Type within the case Related tab here

User-added image
Your reponse is appreciated

Regards
Fiona
 

Dear Folks,

Need to show  a flow validation message to restrict Task creation on Case for a particular Task Record Type.

Problem is I dont see a "New Task" available on Case Record page ,but when i open the Case record ,I see the "New Task" button and the picklist to select the Task,also i checked there is no explicit mention of Task related to Case object like Look up or Master detail except WhatId
can anyone explain how this New Task is shown up in Case page?
User-added image

Your response is highly appreciated

Regards
Fiona

Dear Friends,

At a conceptual level,  need a Trigger code  to do four things 

1 Query for Salesforce queue name Prepaid
2 Iterate over the Email 2 Case records for Record Type as "Executive Response " I get (from Trigger.new)
3 Call .contains() on the Case's Subject to see if your target word exists
4 Update the OwnerId to your queue if it does

Thanks In Advance,your help is highly appreciated

Fiona
How To Make Record Triggered flow Only when Email subject is AIRTEL(Space Before and After)

Consider the scenario when i want to make   Record Triggered flow happen Only when Email subject contains airtel
IT SHOULD NOT TRIGGER for scenarios like

LOVEAIRTEL
COMEONAIRTELFANS

Something like Subject contains AIRTEL(Space Before and After)

Tried below subject with providing keyboard before and after space in Subject Value,but Flow is not getting triggered for word  AIRTEL

User-added image
Your help is appreciated

Fiona


 
Hi,

Developed this rule which is showing correct validation as per condition,but problem is after i ener the amount in settlement amount field basically the field is no more BLANK ,the validation message doesnt goes away 

User-added image


Here is the rule 
AND(
OR(
RecordType.Name = "Executive Response",
ISBLANK(Settlement_dollar_amount__c),
ISPICKVAL( Opened_By_Source__c, "Airtel/Fairshake"),
ISPICKVAL( Opened_By_Source__c, "Airtel - Radvocate"),
ISPICKVAL( Opened_By_Source__c, "Airtel - Radvocate/Fairshake")
)
&&
ISBLANK(Source_Name__r.Name)
,
OR
($Profile.Name = "EETR Case Worker", $Profile.Name = "EETR Reviewer",$Profile.Name = "EETR Coordinator")
)


Please let me know why the validation message doesnt goes away after i enter the settlment amount in the Case Record

Regards
Fiona
Hi,

How To Make Below Changes in  Existing Case Field
  1. Make an existing filed named "Settlement Dollar Amount" field as required
  2. Add helper text to this feild "Settlement Dollar Amount"-
  3. Add validation message for this field "Settlement Dollar Amount"
  4. Validation message must be triggered only for ERT users
Your help is appreciated

Regards

Fiona
Hi Folks,

I have a Email2case  setup where in i have set Up Email 2 Case to move to Customer escalations queue..

Now my question is  How do i make a case can't be re-opened if set to closed greater than 7 days. ,I DO NOT want to writre Trigger or Apex for this ,Is  it Possible to achieve this using flow?

Regards

Fiona

 
Hi folks,

I have a custom code for dependent Picklist lightning component which is inserted in the case ,like below,now my requirement is whenever user wants to close the case ,i need to display a message in my custom picklist lightning component as below

"Level 1, level 2 and level 3 field must be populated before saving."

Here is the case stages as "CLOSED" and custom picklist component screenshot

User-added image


Your help is highly apreciated

Regards,
Fiona
Hi All,
Getting below error on Lightning Web Components SuperBadge at Step 4.All the Boat Types are displaying in dropdown and when I choose different Boat Types, results are showing. 
Challenge Not yet complete... here's what's wrong:
We can’t find the correct settings set for the lightning-combobox in the component boatSearchForm HTML. Check that the component was created according to the requirements, including the correct function for the onchange event, correct options, and values, using the correct case sensitivity.

boarSearchForm.html
-------------------------------
<template>
  <lightning-card>
      <lightning-layout horizontal-align="center" vertical-align="end">
      <lightning-layout-item class="slds-align-middle" padding="horizontal-medium">
          <lightning-combobox variant="label-hidden"
            label="Boat Type"
            value={value}
            placeholder="All Types"
            options={searchOptions}
            onchange={handleSearchOptionChange} class="slds-align-middle">
          </lightning-combobox>
      </lightning-layout-item>
    </lightning-layout>
  </lightning-card>
</template>

boatSearchForm.js
---------------------------
import { LightningElement,wire,track } from 'lwc';
import getBoatTypes from "@salesforce/apex/BoatDataService.getBoatTypes";
export default class BoatSearchForm extends LightningElement {
    selectedBoatTypeId = '';
    value='';
    // Private
    error = undefined; 
   
    // Needs explicit track due to nested data
    @track searchOptions;
    label;
    //value;
    
    // Wire a custom Apex method
    @wire(getBoatTypes)
      boatTypes({ error, data }) {
      if (data) {
         // console.log('Dataloaded',data);
          this.searchOptions = data.map(type => {
              // TODO: complete the logic
            return {
                label:type.Name,
                value:type.Id
            }     
           
         
        });      
        this.searchOptions.unshift({ label: 'All Types', value: '' });
      } else if (error) {
        this.searchOptions = undefined;
        this.error = error;
      }
    }
    
    // Fires event that the search option has changed.
    // passes boatTypeId (value of this.selectedBoatTypeId) in the detail
    handleSearchOptionChange(event) {
      //  event.preventDefault();
      // Create the const searchEvent
      //const boatTypeId=event.detail.value;
      this.selectedBoatTypeId=event.detail.value;
      console.log('Selected Boat Type Id', this.selectedBoatTypeId);
      // searchEvent must be the new custom event search
      const searchEvent= new CustomEvent('search',{detail:this.selectedBoatTypeId});
     // const searchEvent = new CustomEvent('search', {        detail: { boatTypeId: this.selectedBoatTypeId }      });
      this.dispatchEvent(searchEvent);
    }
}

Appreciated your help.

Thanks,
Naren