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

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 87
    Questions
  • 36
    Replies
Hi Gurus,

Need help in getting the Apex class to working to output a string of comma-delimited years and year ranges,and remove all duplicates and invalid inputs.
 
public class SortYearAndYearRangesString{
public static List<Integer> sortSpecialString(String input){
    List<String> inputList = input.split(',');
    Set<Integer> output = new Set<Integer>();
    system.debug('input ' + input);
    system.debug('inputList ' + inputList);
    for (String s : inputList){
        Set<Integer> tempSet = new Set<Integer>();
        s.remove(' ');
        if (s.contains('-')){
            //// break the ranges and fill in years
            List<String> tempSet2 = s.split('-');
            for (String s2 : tempSet2){
                try{
                    ///capture valid integers
                    Integer tempInt = Integer.valueOf(s2);
                    tempSet.add(tempInt);
                } catch (Exception e){
                    tempSet.clear();
                    break;
                }
            }
            System.debug('set ' + tempSet);
            if (tempSet.size() > 1){
                List<Integer> tempList = new List<Integer>(tempSet);
                tempList.sort ();
                Integer r = tempList.size() - 1;
                // iterate through the years
                for (Integer i = tempList.get(0); i < tempList.get(r); i++){
                    tempSet.add(i) ;
                }
            }
        } else{
            try{
                ///capture valid integers
                Integer tempInt = Integer.valueOf(s);
                tempSet.add(tempInt);
            } catch (Exception e){
                continue;
            }
        }
        output.addAll(tempSet);
    }

    // output is currently set of ints, need to convert to list of integer

    List<Integer> finalOutput = new List<Integer>(output);
    finalOutput.sort ();
    System.debug('finalOutput :' + finalOutput);
    return finalOutput;
}}

Here is anonymous apex output
 
public static void validateSolution() {
             String input = '2017, 2018,2020-2023,1800-1700,2020,20a9,19z5-1990,2025,20261,2013';
             List<Integer> expected = new List<Integer> {2013,2017,2018,2020,2021,2022,2023,2025};
             List<Integer> actual = SortYearAndYearRangesString.sortSpecialString(input);
             
             System.assertEquals(expected, actual, 'Invalid Results');
             }
            }

Your Help is highly appreciated

Fiona​​​​​​​
 
Tried writing a sortmethod where i was given a a string of comma-delimited years and year ranges,

Expectation is to get a string of comma-delimited years and year ranges,and remove all duplicates and invalid inputs.

My class is not doing it
public class sortYearAndYearRangesString {
  public static List<String> sortSpecialString(String input) {
       system.debug(input);
        List<String> inputList = input.split('');
      system.debug(inputList);
    Map<Integer,String> stringMap = new Map<Integer,String>();
      system.debug(stringMap);
    List<String> output = new List<String>();
    for (Integer i=0; i<inputList.size(); i++) {
        String charac = inputList[i];
        if(!charac.isAlphaNumeric()) {
             system.debug(charac);
            stringMap.put(i,charac);
        }else {
            output.add(charac);
            system.debug(output);
        }
    }
    String finalString =  String.join(output,'');
      system.debug(finalString);
    List<String> resultList = finalString.reverse().split('');
    for( Integer I : stringMap.keySet() ){
        system.debug(I);
        resultList.add(I,stringMap.get(I));
         system.debug(resultList);
        
       
	}
      return resultList;      
       }
Tried validating the solution in Anonymous Apex but no sucess
 
public static void validateSolution() {
 String input = '2017, 2018,2020-2023,1800-1700,2020,20a9,19z5-1990,2025,20261,2013';
 List<Integer> expected = new List<Integer> {2013,2017,2018,2020,2021,2022,2023,2025};
 List<Integer> actual = sortYearAndYearRangesString(input);
 
 System.assertEquals(expected, actual, 'Invalid Results');
 }
}

can someone help to make code changes below,your help is highly appreciated

Regards,

Fiona
 
Hi team,

I have a requirement where LWC component is fired everytime when a case is opened,I want to change LWC component to work only for NEW cases,what changes needs to be done in the LWC

Here is JS code
import { LightningElement } from 'lwc';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';

export default class ERTCaseTypeInformation extends LightningElement {


    connectedCallback() {
        var toast = new ShowToastEvent({
                 'title': 'Case Type Level 1, level 2 and level 3 fields ',
                 'message': 'must be selected before saving'
             });
             this.dispatchEvent(toast);
       }

}

here is HTML
<template>

    </template>

here is meta xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
  <masterLabel>ERT CaseType Levels Info Component</masterLabel>
  <description>ERT CaseType Levels Info Component.</description>
  <targets>
      <target>lightning__RecordPage</target>
      <target>lightning__AppPage</target>
      <target>lightning__HomePage</target>
  </targets>
</LightningComponentBundle>
Regards,
Fiona
 
Dear Friends,
Should parent apex need to be instantiated 
User-added image

Your help is appreciated

Regards,

Fiona
Correct answer is needed for the MCQ ,question is shall i use Process builder or Flow builder for handling customer service calls

User-added imageYour help is highly appreciated

Regards,
Fiona

 
is it possible to get these app analytics from SFMC
  • Analytics
  • Sales on the app that came from email, will those sales still be attributed to the email channel?
  • How are we going to be able to see the % of # of people that opened an email and were directed to the app, and see that behavior and compare vs when they are directed to the site?
  • Will this now give us access to app push revenue stats? If so where can we access that?
Your help is highly appreciated
Regards,

Fiona
Hi Folks,
What is Problem on Code coverage on the Batch APEX class
User-added image

Your help is highly appreciated
Fiona
Hi,

Please provide the answer to below question
What is Most Efficient way to instantiate the parentAccount Variable in Attched Apex Method

Here is code
User-added image
Your help is appreciated

Fiona
Hi Folks,
Have a LWC component which is pushed successffully to scratch org using
sfdx force:source:deploy --sourcepath force-app\main\default\lwc\eRTCaseTypeLevelInfo

PS C:\sf\LWCSpecialist> sfdx force:source:deploy --sourcepath force-app\main\default\lwc\eRTCaseTypeLevelInfo
 »   Warning: sfdx-cli update available from 7.121.8 to 7.123.1.
Deploy ID: 0Af7c00000tcgy9BBV
SOURCE PROGRESS | ████████████████████████████████████████ | 1/1 Components

=== Deployed Source
FULL NAME             TYPE                      PROJECT PATH
────────────────────  ────────────────────────  ────────────────────────────────────────────────────────────────────────────────
eRTCaseTypeLevelInfo  LightningComponentBundle  force-app\main\default\lwc\eRTCaseTypeLevelInfo\eRTCaseTypeLevelInfo.html
eRTCaseTypeLevelInfo  LightningComponentBundle  force-app\main\default\lwc\eRTCaseTypeLevelInfo\eRTCaseTypeLevelInfo.js
eRTCaseTypeLevelInfo  LightningComponentBundle  force-app\main\default\lwc\eRTCaseTypeLevelInfo\eRTCaseTypeLevelInfo.js-meta.xml


Though i see the LWC app in Org but unable to find the LWC in Custom component section of Lightning App Builder Page or HomePage

Please note 
not showing in App Builder when exposed = True and Target tags defined as below
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
  <apiVersion>52.0</apiVersion>
  <isExposed>true</isExposed>
  <masterLabel> CaseType Levels Info Component</masterLabel>
  <description>ERT CaseType Levels Info Component.</description>
  <targets>
      <target>lightning__RecordPage</target>
      <target>lightning__AppPage</target>
      <target>lightning__HomePage</target>
  </targets>
</LightningComponentBundle>

Your help is highly appreciated

Regards,
Fiona
 
I need to send  a information toast message in Lightning Web component(LWC) as Record Page is Loaded 
without any button click or change event

Below link has code but i dont need onclick ,it should show message by default
<lightning-button label="Show Info" onclick={showInfoToast}></lightning-button>

LWC recipes (https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_toast)

How to get this default Toast message in LWC?

Thanks for your help
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
Dear folks,

Hello Team, i want to send an array of items or a comma separated list from a REST to a custom flow, but i don't know how i can iterate or preprocessor that list, if is an array which is the right way to do it, or if is a comma separated how i can converted into an array?

User-added image
Your help is highly appreciated

Regards,
Fiona
Hi Folks,
Trust you doing great ...!

How to create a chatter post default template so that user can update and post that template?

Any idea how to create a chatter post template? The website information am seeing only lets me put fields 
in which is more like approval process type stuff

What i need is the user can edit this chatter post default template below
User-added image

Your help is highly appreciated

Regards

Fiona
Hi folks,
How to resolve Illegal assignment from void to System.HttpsResponse in Test class

User-added image 
here is class
// Set mock callout class 
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGeneratorAPI());
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock. 
        Test.starttest();
        HerokuBanSync basicAcct = new HerokuBanSync();
        basicAcct.getBANInfoUpdate('990135742');
        Test.stoptest();
        
         // Set mock callout class 
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock. 
      
        HttpResponse res = basicAcct.getBANInfoUpdate('990135742');
        
        // Verify response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '{"GSMStackableSOC__c":"false"}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());




Thanks in advance
Fiona

 
Hi folks,

while calling a service at test class at Line 58 saying
here is test class code 
// Set mock callout class 
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock. 
        HttpResponse res = HerokuBanSync.getBANInfoUpdate('990135742');
        
        // Verify response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '{"GSMStackableSOC__c":"false"}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());

User-added image
How to resolve the "Non static method cannot be referenced from a static context:" error

Thanks in advance
Fiona




 
Hi,

Wrote this test class for Integration apex class with heroku ,how to increase the test coverage form 76% to 90% and also write system.assert statements
 here is test apex class
@isTest
private class HerokuPANSyncTest {
    
    @isTest static void testCallout() {
        HerokuServices__c herokuServices =new HerokuServices__c();
        herokuServices.Name='BasicAccountDetails';
        herokuServices.EndPointUrl__c = 'https://account-tax-PAN-batch-sync-sta.herokuapp.com/basic_account_details';
        insert herokuServices;
        
        API_Proxy_Endpoints__c proxyEnd = new API_Proxy_Endpoints__c();
        proxyEnd.API_EndPoint__c = 'https://qat02.api.ABC.COM/oauth2/v6/tokens';
        proxyEnd.Name = 'OAUTH Endpoint';
        insert proxyEnd;
        
        API_Proxy_Endpoints__c proxyEndPAN = new API_Proxy_Endpoints__c();
        proxyEndPAN.API_EndPoint__c = 'https://PAN-sync-dev.herokuapp.com/api/updatePANInfo?env=QLAB02';
        proxyEndPAN.Name = 'PANUpdate';
        insert proxyEndPAN;
        
        HerokuServices__c herokuServices2 =new HerokuServices__c();
        herokuServices2.Name='PANUpdate';
        herokuServices2.EndPointUrl__c = 'https://b2c-PAN-sync.herokuapp.com/updatePANInfoConsumer';
       // herokuServices2.EndPointUrl__c = 'https://PAN-sync-dev-apigee.herokuapp.com/api/';
        insert herokuServices2;
        
        Apigee_Services__c apigService = new Apigee_Services__c();
        apigService.Name = 'APIGEE B2C Salesforce SaaS';
        apigService.Apigee_CS__c = 'SCRET';
        apigService.Apigee_CK__c = 'KEY';
        apigService.Apigee_Token_URL__c = 'https://qat03.api.ABC.COM/oauth2/v4/tokens';
        insert apigService;
        
        AuthToken__c token = new AuthToken__c();
        token.Name='heroku';
        token.Token_URL__c='https://pos-auth-app.herokuapp.com/services/oauth2/token';
        token.audience__c = 'https://account-tax-PAN-batch-sync-sta.herokuapp.com/';
        token.client_id__c = 'key';
        token.client_secret__c= 'secret';
        token.grant_type__c='client_credentials';
        insert token;
         
        // Set mock callout class 
        Test.seposck(HttpCallouposck.class, new MockHttpResponseGeneratorAPI());
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCallouposck. 
        Test.starttest();
        HerokuPANSync basicAcct = new HerokuPANSync();
        basicAcct.getPANInfoUpdate('411057');
        Test.stoptest();
      }  
}



Here is apex class
public with sharing virtual class HerokuPANSync {
    @TestVisible
    public static final Integer MAX_TIMEOUT = 120000;
    
    public PANInfo getPANInfo(String PANNumber){
        
        //SM_Authentication auth = new SM_Authentication();
        //string access_token = auth.heroku_token();     
        String access_token = SM_APIHandler.generatetoken_SaaS_v6(); // Getting the Proxy token form APIGee
        
        //calling endpoint from custom settings
        //HerokuServices__c herokuServices = HerokuServices__c.getValues('PANUpdate');
        API_Proxy_Endpoints__c herokuServices = API_Proxy_Endpoints__c.getValues('PANUpdate');
        //string endPoint = herokuServices.EndPointUrl__c; 
        String endPoint = herokuServices.API_EndPoint__c;       
        HttpRequest req = new HttpRequest();
        req.setEndpoint(endPoint);
        req.setHeader('PANNumber', PANNumber);
        req.seSMethod('GET');
        req.setTimeout(MAX_TIMEOUT);        
        req.setHeader('Authorization', 'Bearer ' + access_token);
        
        // http call
        Http http = new Http(); 
        new HI_PopTokenGen().buildAuthKey(req);  //Building Auth key for Pop Token.       
        HTTPResponse res = http.send(req);        
        System.debug(res.getStatusCode()); 
        System.debug(res.getStatus());
        if(res.getStatusCode() == 200){            
            PANInfo response = (PANInfo)JSON.deserialize(res.getBody(), PANInfo.class);
            system.debug(res.getBody());
            System.debug('$$$$$ response'+response);            
            return response;            
        }        
        else{  
            System.debug('****Enter into Else *****');
            PANInfo response = new PANInfo();
           
            PAN__c PAN = new PAN__c();
            response.PAN = PAN;
            response.PAN.Last_Samson_Response_DateTime__c = system.now();
            
            response.PAN.Last_Samson_Status__c = '' + res.getStatusCode();  
            
            System.debug('response from samson'+ response);
            return response;    
        }        
       // return null;        
    }

    public void getPANInfoUpdate(String PANNumber){
        
        PANInfo PANResp = getPANInfo(PANNumber);
        if(PANResp != null){
            system.debug('PANResp id'+PANResp);
            PANResp.PAN.PAN_Number__c = PANNumber;
            PANResp.updateRecords();
        }      
    }
    
    public class PANInfo{
        public PAN__c PAN;

        public void updateRecords(){
            SavePoint sp = Database.setSavePoint();
            
            system.debug('PANInfo ss'+PAN);
            
            try{
                
                Database.upsert(PAN, PAN__c.PAN_Number__c, true);
            }
            catch(DMLException e){
                Database.rollback(sp);
                System.debug(e.getStackTraceString());
            }
        }
    }    
}




Your  help is highly appreciated
Fiona
Hi,

I have a requirement where need to create  private key and upload it to Salesforce certificates then need to provide APIGEE with the public key. ,how to this step by step?

Any help on this is highly appreciated

Regards
Fiona

 
Dear Folks,

I need to create and add this kind of Tick marked screen flow in one of my Tab ,how do i do it?

User-added image
Regards
Fiona
Dear folks,

How to find smallest number in array using Map

Example 1:

Input: nums = [2,5,6,9,10]

Explanation:
The smallest number in nums is 2.


Here is code tried using Maps but no success
public class GCDArray {
    public static List<String> greatestdiv(String input) {
        system.debug(input);
        List<String> inputList = input.split('');
        system.debug(inputList);
        Map<String,Integer> counts = new Map<String,Integer>();
        system.debug(counts);
        for(String s1:inputList) {
            counts.put(s1,0);
            system.debug(counts);
        }
        for(String s1:inputList) {
            counts.put(s1,counts.get(s1)+1);
        }
        system.debug(counts);
        String maxKey = counts.isEmpty()?null:new List<String>(counts.keyset())[0];
        system.debug(maxKey);
        for(String s1:counts.keySet()) {
            maxKey = counts.get(s1)>counts.get(maxKey)?s1:maxKey;
        }
        system.debug('The smallest number in array is'+ maxKey);
        system.debug(counts.get(maxKey));
        
        List<String> resultList = maxKey.split('');
        for( Integer S : counts.keySet() ){
            system.debug(S);
            resultList.add(S,counts.get(S));
            system.debug(resultList);
            
            
        }
        
        
        return resultList;      
    }
    
    
}

Regards,
Fiona
 
Hi Folks,

Trying to solve the problem of Find Greatest Common Divisor of Array

Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums.

The greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.

Example 1:

Input: nums = [2,5,6,9,10]
Output: 2
Explanation:
The smallest number in nums is 2.
The largest number in nums is 10.
The greatest common divisor of 2 and 10 is 2.

Example 2:

Input: nums = [7,5,6,8,3]
Output: 1
Explanation:
The smallest number in nums is 3.
The largest number in nums is 8.
The greatest common divisor of 3 and 8 is 1.

Example 3:

Input: nums = [3,3]
Output: 3
Explanation:
The smallest number in nums is 3.
The largest number in nums is 3.
The greatest common divisor of 3 and 3 is 3.

Here is code tried using Maps but no success ,any help is appreciated
 
public class GCDArray {
    public static List<String> greatestdiv(String input) {
        system.debug(input);
        List<String> inputList = input.split('');
        system.debug(inputList);
        Map<String,Integer> counts = new Map<String,Integer>();
        system.debug(counts);
        for(String s1:inputList) {
            counts.put(s1,0);
            system.debug(counts);
        }
        for(String s1:inputList) {
            counts.put(s1,counts.get(s1)+1);
        }
        system.debug(counts);
        String maxKey = counts.isEmpty()?null:new List<String>(counts.keyset())[0];
        system.debug(maxKey);
        for(String s1:counts.keySet()) {
            maxKey = counts.get(s1)>counts.get(maxKey)?s1:maxKey;
        }
        system.debug('The smallest number in array is'+ maxKey);
        system.debug(counts.get(maxKey));
        
        List<String> resultList = maxKey.split('');
        for( Integer S : counts.keySet() ){
            system.debug(S);
            resultList.add(S,counts.get(S));
            system.debug(resultList);
            
            
        }
        
        
        return resultList;      
    }
    
    
}

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,

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 folks,

while calling a service at test class at Line 58 saying
here is test class code 
// Set mock callout class 
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock. 
        HttpResponse res = HerokuBanSync.getBANInfoUpdate('990135742');
        
        // Verify response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '{"GSMStackableSOC__c":"false"}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());

User-added image
How to resolve the "Non static method cannot be referenced from a static context:" error

Thanks in advance
Fiona




 
Dear gurus,

I have a problem where 

GIVEN there is a string of characters, and i need to ivoke a reverse method is invoked such that it returns an array of characters in reversed order for alphanumeric characters only however all other non-alphanumeric characters need to retain their original position -
How to Implement solution in Apex?

I tried below code but no luck
public class assessment {
  public static List<String> reverseSpecialString(String input) {
        List<String> resultList = new List<String>();
         // IMPLEMENT
        resultList = input.split('');
        string reversedString='';
        for(integer i=resultList.size()-1;i>=0;i--)
            {
             
            reversedString=reversedString+resultList[i];
               
            }
    
       
        
        
         return resultList;
      
       }
    
    public static void validateSolution() {
        String input = 'ABC@HI#J2';
        List<String> expected = new List<String> {'2','J','I','@','H','C','#','B','A'};
        List<String> actual = reverseSpecialString(input);
        
        System.assertEquals(expected, actual, 'Invalid Results');
    }
}

Thanks,
Fiona​​​​​​​

 
Dear Pals,

I need to  Fire ShowNavigateToList After ShowToast On Single Save Function Of JS file,somehow only ShowToast working and not the ShowNavigateToList,Here is  what i have written for Save button,basically after the record is Upserted i want the page to move to ListView,what change is needed below
 
onConfirm:function(component, event, helper){
        var picklist=component.find('ddLevel1');
        var picklistvalue=picklist.get('v.value');
        var picklistdep=component.find('ddLevel2');
        var picklistvaluedep2=picklistdep.get('v.value');
        var picklistoldL1=component.get('v.oldL1');
        var picklistoldL2=component.get('v.oldL2');
        var picklistoldL3=component.get('v.oldL3');
        var ertrecordGuid=component.get('v.ertGUID');
        var picklistdep3=component.find('ddLevel3');
        var picklistvaluedep3=picklistdep3.get('v.value');
        var action = component.get("c.savecasetype");
       
        action.setParams({  'level1' : picklistvalue,
                          'level2' : component.get('v.secondlevelselected'),
                          'level3' : picklistvaluedep3,
                          'oldlevel1' : picklistoldL1,
                          'oldlevel2' : picklistoldL2,
                          'oldlevel3' : picklistoldL3,
                          'guid':ertrecordGuid,
                          'id' : component.get("v.recordId")});
        
        
        var toastEvent = $A.get("e.force:showToast");
        action.setCallback(this, function(e) {
            if(e.getState()=='SUCCESS'){
                var result=e.getReturnValue();
                        
                
                if(result==='successfull'){
                    toastEvent.setParams({
                        "title": "Success!",
                        "message": "The record has been Upserted  successfully."
                         
                    });
                    
                    toastEvent.fire();
                   
                }else{
                   
                    toastEvent.setParams({
                        "title": "Error",
                        "message": "The record has not been Upserted  successfully."
                    });
                    toastEvent.fire();
                }
            }
            
            
          
             $A.get('e.force:refreshView').fire(); 
             
        });
        
           var action = component.get("c.getListViews");
    action.setCallback(this, function(response){
        var state = response.getState();
        if (state === "SUCCESS") {
            var listviews = response.getReturnValue();
            var navEvent = $A.get("e.force:navigateToList");
            navEvent.setParams({
                "listViewId": listviews.Id,
                "listViewName": null,
                "scope": "Case"
            });
            navEvent.fire();
        }
    });
        $A.enqueueAction(action);
        
          
        
    }

Here is ListView controller
 
@AuraEnabled 

public static List<ListView> getListViews() { 

    List<ListView> listviews = 

        [SELECT Id, Name FROM ListView WHERE SobjectType = 'Case' and Name='Recently Viewed Cases']; 

  

   

    return listviews; 

}



Your help is needed and appreciated
Regards,
Fiona​​​​​​​

 
Hi Pals,

My code is showing Red for Upsert statement,can someone help me in completing Test apex class write up for Upsert statments below
@isTest
public class ERT_MultiLevelSelectEditTest {
  
  @testSetup static void setup() {
        
    Case_Type_Data__c ct = new Case_Type_Data__c();
    ct.Level_1__c = 'Test Level 1';
    ct.Level_2__c = 'Test Level 2';
    ct.Level_3__c = 'Test Level 3';
    insert ct; 

    }
    
  @isTest
   static  void testGetLevel1()
   {
    
    Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
    insert cas;
    ERT_Case_Type__c  obj = new ERT_Case_Type__c ();
    obj.Level_1__c = 'Test Level 1';
    obj.Level_2__c = 'Test Level 2';
    obj.Level_3__c = 'Test Level 3';
    obj.Case__c = cas.id;
    upsert obj;
       
   test.startTest();
   List<ERT_MultiLevelSelectEdit.LevelWrapper> lstWrapper= ERT_MultiLevelSelectEdit.getLevel1(obj.id);
   test.stopTest();
   system.assertEquals('Test Level 1', lstWrapper[0].strL1val);
     
   
     
    

   }

  @isTest
   static void testGetLevel2()
   {
   test.startTest();
   List<String> s = ERT_MultiLevelSelectEdit.getLevel2('Test Level 1');
   test.stopTest();
   system.assertEquals('Test Level 2', s[0]);
      
   

   }
    
  @isTest
   static void testGetLevel3()
   {
    test.startTest();
    List<String> s = ERT_MultiLevelSelectEdit.getLevel3('Test Level 1','Test Level 2');
    test.stopTest();
    system.assertEquals('Test Level 3', s[0]);
   }
    
  @isTest 
   static  void testsaveCaseType(){
   
        Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
        insert cas;
       
        ERT_Case_Type__c obj=new ERT_Case_Type__c();
        string one='one';
        string two='two';
        string three='three';
        test.startTest();
        String testing=ERT_MultiLevelSelectEdit.savecasetype(one,two,three,cas.id);
        test.stopTest();
        system.assertEquals('successfull', testing);
    }
    
 public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
    }
    
    

}


Here is controller class
public class ERT_MultiLevelSelectEdit {
    @AuraEnabled
    public static List<LevelWrapper> getLevel1(string recID){
        List<String> tempLst1 = new List<String>();
        list<LevelWrapper> lstWrap=new list<LevelWrapper>();
        
        list<ERT_Case_Type__c>  lstertcase=new list<ERT_Case_Type__c>();
        lstertcase=[select id,Level_1__c,Level_2__c,Level_3__c from ERT_Case_Type__c where id=:recID];
        string strL1,strL2,strL3;
        if(lstertcase.size()>0){
            strL1=lstertcase[0].Level_1__c;
            strL2=lstertcase[0].Level_2__c;
            strL3=lstertcase[0].Level_3__c;
        }
        
        for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c]) {
            LevelWrapper obj= new LevelWrapper();
            string strLev1=(string)ar.get('Level_1__c');
            obj.strLevelType='recL1';
            obj.strL1val=strLev1;
            if(strLev1==strL1)
                obj.isSelected=true;
            else
                obj.isSelected=false; 
            lstWrap.add(obj);
            
        }

        for(string ar:getLevel2(strL1)){
            if(strL1!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL2';
                obj.strL2val=strLev2;
                if(strLev2==strL2)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        
        for(string ar:getLevel3(strL1,strL2)){
            if(strL2!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL3';
                obj.strL3val=strLev2;
                if(strLev2==strL3)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        System.debug(' wrapper '+lstWrap);
        return lstWrap;
        
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel2(string strName){
        List<String> tempLst2 = new List<String>();
        for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
        {
            tempLst2.add(''+ar.get('Level_2__c'));
        }
        
        return tempLst2;
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel3(string strName1,string strName2){
        List<String> tempLst3 = new List<String>();
        for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
        {
            tempLst3.add(''+ar.get('Level_3__c'));
        }
        
        return tempLst3;
        
        
    } 
    
    @AuraEnabled
    public  static String  savecasetype(string level1,string level2,string level3,string id){
        string strMsg='successfull';
        try{
            ERT_Case_Type__c obj=new ERT_Case_Type__c();
            
            System.debug('CASE  = '+ Obj.Case__c); 
            Obj.Level_1__c=level1;
            System.debug('Level1  = '+ Obj.Level_1__c); 
            Obj.Level_2__c=level2;
            System.debug('Level2  = '+ Obj.Level_2__c); 
            Obj.Level_3__c=level3;
            System.debug('Level3  = '+ Obj.Level_3__c);
            List<Case_Type__c> lstCTD = new List<Case_Type__c>();
            lstCTD=[select id,Level_1__c,Level_2__c,Level_3__c from Case_Type__c];
            
            lstCTD[0].Level_1__c=level1;
            
            lstCTD[0].Level_2__c=level2;
            
             lstCTD[0].Level_3__c=level3;
            if(id.startsWithIgnoreCase('500'))
                Obj.Case__c = id;
            
            else
                obj.id=id;
            upsert  obj;
              upsert  lstCTD;
            
          
            
          
            
        }
        
        catch(Exception ex){
            strMsg='error';
        }
        return strMsg;  
    }
    
    public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
    }
    
    
    
 }

It shows   Red for Upsert statements

User-added image


Thanks
Fiona
 
Hi Gurus,

this is an apex controller code to insert a record,please help me in writing a code to load an existing record and modify it as well
 
public class PickListHandler {
    @AuraEnabled
    public static List<String> getLevel1(){
    List<String> tempLst1 = new List<String>();
        for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c])
    {
        tempLst1.add(''+ar.get('Level_1__c'));
    }

    return tempLst1;
      
      
    } 
    
    @AuraEnabled
    public static List<String> getLevel2(string strName){
    List<String> tempLst2 = new List<String>();
       for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
    {
       tempLst2.add(''+ar.get('Level_2__c'));
    }

    return tempLst2;
      
    } 
    
    @AuraEnabled
    public static List<String> getLevel3(string strName1,string strName2){
     List<String> tempLst3 = new List<String>();
      for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
    {
       tempLst3.add(''+ar.get('Level_3__c'));
    }

    return tempLst3;
      
      
    } 
         
     @AuraEnabled
     public  static String  savecasetype(string level1,string level2,string level3,string id){
     string strMsg='successfull';
          try{
     ERT_Case_Type__c obj=new ERT_Case_Type__c();
     Obj.Case__c = id;
     System.debug('CASE  = '+ Obj.Case__c); 
     Obj.Level_1__c=level1;
     System.debug('Level1  = '+ Obj.Level_1__c); 
     Obj.Level_2__c=level2;
     System.debug('Level2  = '+ Obj.Level_2__c); 
     Obj.Level_3__c=level3;
     System.debug('Level3  = '+ Obj.Level_3__c); 
     Insert obj;
  
     }
     
    catch(Exception ex){
            strMsg='error';
        }
     return strMsg;  
}
    
     
    
    

}

Your help is highly appreciated

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