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

  • Chatter
    Feed
  • 0
    Best Answers
  • 6
    Likes Received
  • 0
    Likes Given
  • 119
    Questions
  • 47
    Replies
Getting these stack messages
Class.TestDataFactory.InsertTestData: line 166, column 1 Class.OrderTests.SetupTestData: line 7, column 1
As am logged in as Salesforce Admin in my sandbox,i should not get this error while sharing record,any ideas how to resolve the error in below test code Checked the access ,i have full access in PricebookEntry standard object
also checked the below scenbarios mentioned in URL https://www.forcetree.com/2011/12/insufficientaccessoncrossreferenceentit.html
NOTE: A common cause for this issue is the below scenario. Read on, if that's not the case for you. *If you are trying to share "Record X" with "User Y" and "User Y" already has access to "Record X" this error happens.
=============OrderTests.apxc=========================
 
@isTest
            private class OrderTests {
                static User testUser;
                
                @testSetup
                static void SetupTestData() {
                    TestDataFactory.InsertTestData(20);
                    testUser = TestDataFactory.CreateTestUser(); // create a test user with necessary permissions
                }
                
                @isTest
                static void OrderUpdate_UnitTest() {
                    // create the test data as the test user
                    System.runAs(testUser) {
                        Order selectedOrder = [Select name,Status, Id from Order limit 1];
                        Product2 oldProd = [Select Quantity_Ordered__c, Name, Id from Product2 limit 1];
                        
                        selectedOrder.Status = Constants.ACTIVATED_ORDER_STATUS;
                        update selectedOrder;
                        
                        Product2 updatedProd = [Select Quantity_Ordered__c, Name, Id from Product2 limit 1];
                        
                        TestDataFactory.VerifyQuantityOrdered(oldProd,updatedProd,Constants.DEFAULT_ROWS);
                    }
                }
                
                @isTest
                static void OrderExtension_UnitTest() {
                    // create the test data as the test user
                    System.runAs(testUser) {
                        PageReference reference = Page.OrderEdit;
                        Test.setCurrentPage(reference);
                        Order CurOrder = [Select Id,Status from Order limit 1];
                        ApexPages.StandardController controller = new Apexpages.StandardController(CurOrder);
                        OrderExtension extension = new OrderExtension(controller);
                        System.assertEquals(5, extension.orderItemList.size());
                        extension.selectedFamily = 'Dessert';
                        extension.SelectFamily();
                        extension.OnFieldChange();
                        extension.First();
                        extension.Next();
                        extension.Previous();
                        extension.Last();
                        extension.GetHasNext();
                        extension.GetPageNumber();
                        extension.GetHasPrevious();
                        extension.GetTotalPages();
                        extension.GetFamilyOptions();
                        extension.Save();
                        ChartHelper.GetInventory();
                    }
                } 
            }

============================TestDataFactory.aspxc====================
 
@isTest
            private class OrderTests {
                static User testUser;
                
                @testSetup
                static void SetupTestData() {
                    TestDataFactory.InsertTestData(20);
                    testUser = TestDataFactory.CreateTestUser(); // create a test user with necessary permissions
                }
                
                @isTest
                static void OrderUpdate_UnitTest() {
                    // create the test data as the test user
                    System.runAs(testUser) {
                        Order selectedOrder = [Select name,Status, Id from Order limit 1];
                        Product2 oldProd = [Select Quantity_Ordered__c, Name, Id from Product2 limit 1];
                        
                        selectedOrder.Status = Constants.ACTIVATED_ORDER_STATUS;
                        update selectedOrder;
                        
                        Product2 updatedProd = [Select Quantity_Ordered__c, Name, Id from Product2 limit 1];
                        
                        TestDataFactory.VerifyQuantityOrdered(oldProd,updatedProd,Constants.DEFAULT_ROWS);
                    }
                }
                
                @isTest
                static void OrderExtension_UnitTest() {
                    // create the test data as the test user
                    System.runAs(testUser) {
                        PageReference reference = Page.OrderEdit;
                        Test.setCurrentPage(reference);
                        Order CurOrder = [Select Id,Status from Order limit 1];
                        ApexPages.StandardController controller = new Apexpages.StandardController(CurOrder);
                        OrderExtension extension = new OrderExtension(controller);
                        System.assertEquals(5, extension.orderItemList.size());
                        extension.selectedFamily = 'Dessert';
                        extension.SelectFamily();
                        extension.OnFieldChange();
                        extension.First();
                        extension.Next();
                        extension.Previous();
                        extension.Last();
                        extension.GetHasNext();
                        extension.GetPageNumber();
                        extension.GetHasPrevious();
                        extension.GetTotalPages();
                        extension.GetFamilyOptions();
                        extension.Save();
                        ChartHelper.GetInventory();
                    }
                } 
            }



            /**
             * @name TestDataFactory
             * @description Contains methods to construct and/or validate commonly used records
            **/
            public with sharing class TestDataFactory {

                /**
                 * @name ConstructCollaborationGroup
                 * @description
                **/
                
                 public static User CreateTestUser() {
                    Profile p = [SELECT Id FROM Profile WHERE Name='Standard User' LIMIT 1];
                    User u = new User(
                        FirstName = 'Test',
                        LastName = 'User',
                        Email = 'testuser@example.com',
                        Alias = 'tuser',
                        Username = 'testuser@example.com',
                        CommunityNickname = 'TestUser',
                        TimeZoneSidKey = 'America/Los_Angeles',
                        LocaleSidKey = 'en_US',
                        EmailEncodingKey = 'UTF-8',
                        ProfileId = p.Id,
                        LanguageLocaleKey = 'en_US'
                    );
                    return u;
                }
                
                public static CollaborationGroup ConstructCollaborationGroup(){
                    return new CollaborationGroup(CollaborationType='Public',Name='TEST'+constants.INVENTORY_ANNOUNCEMENTS);

                    //ToDo: Ensure this method returns a single Chatter CollaborationGroup
                    //    whose Name starts with 'TEST' followed by the INVENTORY_ANNOUNCEMENTS constant
                    //    and configured so anyone can join, see and post updates.
                }

                /**
                 * @name CreateProducts
                 * @description Constructs a list of Product2 records for unit tests
                **/
                public static list<Product2> ConstructProducts(Integer cnt){
                    list<Product2> prods = new list<Product2>();

                    for(integer i=0;i<cnt;i++){
                        prods.add(new Product2(Name='Product'+i,IsActive=true,Initial_Inventory__c=10, family = Constants.PRODUCT_FAMILY.get(math.mod(i, Constants.PRODUCT_FAMILY.size())).getValue()));
                    }
                    return prods;
                    //ToDo: Ensure this method returns a list, of size cnt, of uniquely named Product2 records
                    //  with all the required fields populated
                    //  and IsActive = true
                    //  an Initial Inventory set to 10
                    //  and iterating through the product family picklist values throughout the list.
                }

                /**
                 * @name CreatePricebookEntries
                 * @description Constructs a list of PricebookEntry records for unit tests
                **/
                public static List<PricebookEntry> ConstructPricebookEntries(List<Product2> prods){

                    List<PricebookEntry> entries = new List<PricebookEntry>();
                    for(integer i=0;i<prods.size();i++){
                        entries.add(new PricebookEntry(product2Id = prods.get(i).Id, Pricebook2Id = constants.STANDARD_PRICEBOOK_ID, UnitPrice = 12, IsActive = true));
                    }
                    return entries;

                    //ToDo: Ensure this method returns a corresponding list of PricebookEntries records
                    //  related to the provided Products
                    //  with all the required fields populated
                    //  and IsActive = true
                    //  and belonging to the standard Pricebook
                }

                /**
                 * @name CreateAccounts
                 * @description Constructs a list of Account records for unit tests
                **/
                public static list<Account>  ConstructAccounts(Integer cnt){
                    list<Account> accs = new list<Account>();

                    for(integer i=0;i<cnt;i++){
                        accs.add(new Account(Name='Account'+i));
                    }
                    return accs;
                    //ToDo: Ensure this method returns a list of size cnt of uniquely named Account records
                    //  with all of the required fields populated.
                }

                /**
                 * @name CreateContacts
                 * @description Constructs a list of Contacxt records for unit tests
                **/
                public static List<Contact> ConstructContacts(Integer cnt, List<Account> accts){
                    List<Contact> cs = new list<Contact>();

                    for(integer i=0;i<cnt;i++){
                            cs.add(new Contact(FirstName='Fname'+i,LastName='Lname'+i,AccountId=accts.get(math.mod(i, accts.size())).Id));
                    }
                        
                    return cs;

                    //ToDo: Ensure this method returns a list, of size cnt, of uniquely named Contact records
                    //  related to the provided Accounts
                    //  with all of the required fields populated.
                }

                /**
                 * @name CreateOrders
                 * @description Constructs a list of Order records for unit tests
                **/
                public static List<Order> ConstructOrders(Integer cnt, List<Account> accts){
                    List<Order> cs = new list<Order>();

                   for(integer i=0;i<cnt;i++){
                            cs.add(new Order(status='Draft',EffectiveDate= System.today(),AccountId=accts.get(math.mod(i, accts.size())).Id,Pricebook2Id=Constants.STANDARD_PRICEBOOK_ID));
                    }
                        
                    return cs;

                    //ToDo: Ensure this method returns a list of size cnt of uniquely named Order records
                    //  related to the provided Accounts
                    //  with all of the required fields populated.
                }

                /**
                 * @name CreateOrderItems
                 * @description Constructs a list of OrderItem records for unit tests
                **/
                public static List<OrderItem> ConstructOrderItems(integer cnt, list<pricebookentry> pbes, list<order> ords){
                    List<OrderItem> cs = new list<OrderItem>();

                    for(integer i=0;i<cnt;i++){
                        OrderItem oi = new OrderItem();
                        oi.Quantity = Constants.DEFAULT_ROWS;
                        oi.OrderId = ords.get(math.mod(i, ords.size())).Id;
                        oi.PricebookEntryId = pbes.get(math.mod(i, pbes.size())).Id;
                        oi.UnitPrice = 250;
                        cs.add(oi);
                    }
                    
                    return cs;
                    
                    //ToDo: Ensure this method returns a list of size cnt of OrderItem records
                    //  related to the provided Pricebook Entries
                    //  and related to the provided Orders
                    //  with all of the required fields populated.
                    //  Hint: Use the DEFAULT_ROWS constant for Quantity as it will be used in the next challenge
                }

                /**
                 * @name SetupTestData
                 * @description Inserts accounts, contacts, Products, PricebookEntries, Orders, and OrderItems.
                **/
                public static void InsertTestData(Integer cnt){
                    INSERT ConstructCollaborationGroup();
                    list<Account> accs = ConstructAccounts(cnt);
                    INSERT accs;

                    INSERT ConstructContacts(cnt,accs);

                    list<Product2> prods = ConstructProducts(cnt);
                    INSERT prods;
                    
                    list<PriceBookEntry> ents =ConstructPricebookEntries(prods);
                    INSERT ents;
                    
                    list<Order> ords = ConstructOrders(cnt, accs);
                    INSERT ords;

                    INSERT ConstructOrderItems(cnt, ents, ords);

                    //ToDo: Ensure this method calls each of the construct methods
                    //  and inserts the results for use as test data.

                }

                public static void VerifyQuantityOrdered(Product2 originalProduct, Product2 updatedProduct, Integer qtyOrdered){
                    System.assertEquals(updatedProduct.Quantity_Ordered__c, originalProduct.Quantity_Ordered__c + qtyOrdered);
                }
            }

Your help to resolve issue is appreciated
Fiona
Hi ,

I have a question if some one wants to learn and do certification on Salesforce B2C / Velocity  /CPQ world then does the person should atleast have knowledge about salesforce sales and service cloud fundamentals like Roles profiles and apex programming ,if yes what is the logical connection  of learning sales cloud service cloud with Salesforce B2C / Velocity / CPQ area

Your response is highly appreciated

 
Dear folks,

I wrote this code to  Return an array of characters in reversed order for alphanumeric characters ,but i keep getting error as

Expression must be a list type: String
 
public class assessment {
 public static List<String> reverseAlphaNumericCharacters(String s) {
    List<String> reversedChars = new List<String>();
    for (Integer i = s.length() - 1; i >= 0; i--) {
        if (isAlphaNumeric(s[i])) {
            reversedChars.add(s[i]);
        }
    }
    return reversedChars;
}

private static Boolean isAlphaNumeric(String c) {
    return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || ('0' <= c && c <= '9');
}

}

Kindly let me know what wrong am doing?

Thanks
Tarun

 
Dear team,

I have an custom obj Case type data ,there is a permission set which is active for this object,and few users are associated with this
permission set...My requirement is to enable the users to not delete any case types

What changes i need to in permission set?

Your reply is appreciated

Fiona
Hi,

here is batch code which is executing currently showing as zero records processed in  AysncApexJob , no errors though ,what i want is whenever batch find Zero record in SOQL of start method then batch should fail with exception or show error message 
 
global class CaseCopyBatch implements Database.Batchable<sObject>, Database.Stateful {
					private List<Batch_Case_Type__c> processedRecords;
				global Database.QueryLocator start(Database.BatchableContext BC) {
					processedRecords = new List<Batch_Case_Type__c>();
					// collect the batches of records or objects to be passed to execute        
					String query = 'SELECT Case__c, Lvl_1__c, Lvl_2__c,Lvl_3__c,UniqueGUID__c  FROM Batch_Case_Type__c WHERE createddate = today AND IsProcessed__c = false';
					return Database.getQueryLocator(query);
				}
				global void execute(Database.BatchableContext BC, List<Batch_Case_Type__c> exeList) {   
					// process each batch of records
					List<Case_Type__c> listCTD = new List<Case_Type__c>();
				   
					for(Batch_Case_Type__c exe : exeList)
					{        
						listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Lvl_1__c=exe.Lvl_1__c,Lvl_2__c=exe.Lvl_2__c,Lvl_3__c=exe.Lvl_3__c,ERTUniqueGUID__c=exe.UniqueGUID__c));
					   exe.IsProcessed__c = true;    
					}
					try {
						
						insert listCTD;
						//only successful batches will be processed 
						processedRecords.addAll(exeList);
						update processedRecords;
					} catch(Exception e) {
						System.debug(e);
					}
				}   
				global void finish(Database.BatchableContext BC) {
				   
				  
				}
				}

Your response is highly appreciated

Regards
Fiona


 
Hi,

Need a SOQL to find  list of users who have Admin profile and want to add some columns like object access , record access etc ... So i know  what these profile can do  below SOQL is not helping me much,can someone suggest what is missing here
SELECT sObjectType, PermissionsCreate, PermissionsRead, PermissionsEdit, PermissionsDelete, PermissionsModifyAllRecords,
PermissionsViewAllRecords FROM ObjectPermissions
WHERE ParentId IN ( SELECT Id
FROM permissionset
WHERE PermissionSet.Profile.Name = 'System Administrator' )

Thanks in advance
Fiona

 
Dear Folks,

Written a anonymous apex to update the user's profile name from Profile1 to Profile 2,i see anonymous apex ran successfully ,but i dont see the Profile.name got changed,any idea what is going wrong with below code
List<User> lstUsers = new List<User>();

for(User userToChangePermission : [SELECT ID,firstname,lastname,username,isActive,Profile.Name FROM User WHERE Profile.Name = 'Profile1' LIMIT 100 ])

{userToChangePermission.Profile.Name = 'Profile2';
lstUsers.Add(userToChangePermission);}

if(!lstUsers.isEmpty())
{
System.debug(lstUsers);
Update lstUsers;    
}

Your help is appreciated

Regards
Fiona
 
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,

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​​​​​​​
 
Created a new Custom object ,now i want to create this Custom Object as Tab in the App ,but when i create a "Lightning App",can't see the Custom object in Navigation Items,I checked in profiles as well ,i had full access to the custom object as i am salesforce admin

User-added image
Your help is highly appreciated

Fiona
Hi Gurus,
How do i  Import Apex Classes Dev Sandbox into Visual Studio Code After successfully doing  SFDX: Authorise Org for my dev org which is a scratch org sandbox, basically I would like to execute my apex unit tests from Visual studio code..but the problem is I see only LWC project got created with project.json file  ..Here is my VSCode

User-added image

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