• inbox outbox 7
  • NEWBIE
  • 30 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 5
    Replies
Hi!

I am not looking for a link which directs me to the salesforce documentation or some blog/website. 
Kindly give me a scenario or an example. Please explain. 

Thank you. 
I am looking for a scenario as to, when we use apex sharing over declarative ways. 
 
Thank you!

Lightning templates can't be open from a mobile app (salesforc 1) however you can navigate to them from a browser. 
Is that right?

 
Hi all, 
Happy New Year!


Could you guys tell me the scenarios as to when we use callouts in batch apex?
I would like to point out that I am looking for input on the scenarios that you guys faced or know/read about. 
I am inclined more towards when than the how part of this. 

 
Hello guys, 

Could any one tell me the difference between these two classes?
We have Auth 2.0 JWT Bearer token flow for Einstein API Authentication. 
To generate the JWT file, can we use JSON.serialize() method instead of JSONGenerator class.?

Eg. code:
JSONGenerator body = JSON.createGenerator(false);
        body.writeStartObject(); // {
        body.writeStringField('iss', this.iss);
        body.writeNumberField('iat', rightNow);




 
Bold part of the code is not covered in the test class. 
@httpPatch
    global static updateWrapper updateAccount(String Desciption){
        RestRequest req= Restcontext.request;
        String requestURI= req.requestURI;
        String accountId= requestURI.substringAfterLast('/');
        
        List<Account> accList= [SELECT ID, Description FROM Account WHERE ID =: accountId];
        Account acc;
        updateWrapper updateWrapper= new updateWrapper();
        IF(accList != null && accList.size() >0){
            <b>acc= new Account(Id=accountId, Description= Desciption);
            UPDATE acc;
            updateWrapper.accRec= acc;
            updateWrapper.message= 'Account updated';</b>
        }else{
            updateWrapper.message= 'Account record not found';
        }
        return updateWrapper;    
    
 global class updateWrapper{
        global Account accRec;
        global String message;
    }
Test class:
@isTest
    public static void updateAccountTest_else(){
        String recordId= createTestRecord();
        String url= '/services/apexrest/v1/Account'+recordId+'1';
            
        RestRequest req= New RestRequest();
        req.httpMethod= 'PATCH';
        req.requestURI= url;
        
        RestContext.request= req;
       
        Test.startTest();
        AccountManager.updateAccount('some random text with else');
        Test.stopTest();
    }


    static Id createTestRecord(){
        Account testAcc= New Account();
        testAcc.Name= 'testAccount';
        INSERT testAcc;
        
        Contact testCon= New Contact();
        testCon.LastName= 'test contact';
        testCon.AccountId= testAcc.Id;
        INSERT testCon;
        
        return testAcc.Id;
        
    }


 
Below is the code:
Test class doesn't cover the bold part of the code. 
@httpGet
    global static accountWrapper accountInformation(){
        RestRequest req= Restcontext.request;
      // String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        String requestURI= req.requestURI;
        String accountId= requestURI.substringAfterLast('/');
        List<Account> accList= [SELECT ID, Name, Rating, Description, Industry, Phone, Fax
                                FROM Account WHERE ID =: accountId];
        
        List<Contact> conList= [SELECT ID, Name, FirstName, LastName, Email, Phone 
                                FROM Contact WHERE accountId IN: accList ];
        
        List<Case> caseList= [SELECT Id, CaseNumber, Subject, Description, Status, Owner.Name
                              FROM Case WHERE accountId IN: accList];
        
        accountWrapper wrapper= new accountWrapper();
        if(!accList.isEmpty()){
            wrapper.accountRecord= accList.get(0);
            wrapper.conList= conList;
            wrapper.caseList= caseList;
        }
        
        return wrapper;
    }

  global class accountWrapper{
        global Account accountRecord;
        global List<Contact> conList;
        global List<Case> caseList;
    }
Test class:
@isTest
    public static void deleteAccountTest(){
        String recordId= createTestRecord();
        String url= '/services/apexrest/v1/Account'+recordId;
            
        RestRequest req= New RestRequest();
        req.httpMethod= 'DELETE';
        req.requestURI= url;
        
        RestContext.request= req;
        
        try{
        Test.startTest();
        AccountManager.deleteAccount(	);
        Test.stopTest();
        }catch(system.Exception ex){
            system.assertNotEquals(null, ex.getMessage());
        }
    }


    static Id createTestRecord(){
        Account testAcc= New Account();
        testAcc.Name= 'testAccount';
        INSERT testAcc;
        
        Contact testCon= New Contact();
        testCon.LastName= 'test contact';
        testCon.AccountId= testAcc.Id;
        INSERT testCon;
        
        return testAcc.Id;
        
    }



 
========================== CLASS====================

@httpDelete
    global static String deleteAccount(){
        RestRequest req= Restcontext.request;
        String requestURI= req.requestURI ;
        String accountId= requestURI.substringAfterLast('/');
        List<Account> accList= [SELECT ID, Name, Rating, Description, Industry, Phone, Fax
                                FROM Account WHERE ID =: accountId];
        if(accList != null && accList.size() >0 ){
            try{
               DELETE accList; 
               return '{"message": "Account deleted"}';
            }Catch(system.Exception ex){
                String errorMessage= ex.getMessage();
                return '{"message":"'+errorMessage+'"}';
            }
        }else{
            return '{"message": "No record found"}';
        }
    }

====================TEST CLASS===================
 @isTest
    public static void deleteAccountTest(){
        String recordId= createTestRecord();
        String url= '/services/apexrest/v1/Account'+recordId;
            
        RestRequest req= New RestRequest();
        req.httpMethod= 'DELETE';
        req.requestURI= url;
        
        RestContext.request= req;
       
        Test.startTest();
        AccountManager.deleteAccount(	);
        Test.stopTest();
    }

 static Id createTestRecord(){
        Account testAcc= New Account();
        testAcc.Name= 'testAccount';
        INSERT testAcc;
        
        Contact testCon= New Contact();
        testCon.LastName= 'test contact';
        testCon.AccountId= testAcc.Id;
        INSERT testCon;
        
        return testAcc.Id;
        
    }
I have trouble with the try catch block. 
public class IntWrapper implements Comparable{
    public Integer int;
    public static String order = 'ASC';
    
    public IntWrapper(Integer val){
        int = val;
    }

    public Integer compareTo(Object input){
        Integer result;
        if(IntWrapper.order == 'ASC'){
            result = compareASC(input);
        } else {
            result = compareDESC(input);
        }
        return result;
    }

    private Integer compareASC(Object input){
        Integer intIn = (Integer)input;
        if(int < intIn){
            return -1;
        } else if(int > intIn){
            return 1;
        } else {
            return 0;
        }
    }

    private Integer compareDESC(Object input){
        Integer intIn = (Integer)input;
        if(int < intIn){
            return 1;
        } else if(int > intIn){
            return -1;
        } else {
            return 0;
        }
    }
}

List<IntWrapper> someList = new List<IntWrapper>{new IntWrapper(1), new IntWrapper(2), new IntWrapper(3), new IntWrapper(4), new IntWrapper(5)};

// First sort ensures we're in ASC order
someList.sort();

// Set the static flag, sort again, et voila, list is reversed
IntWrapper.order = 'DESC';
someList.sort();

I want to be able to reverse a list of accounts using this approach. 
Please correct my code and advice me on what I am doing wrong.
public List<Account> sortingMethod1() {
            List<Account> accList= new List<Account>();
            accList.add(new Account(Name= 'a'));
            accList.add(new Account(Name= 'z'));
            accList.add(new Account(Name= 'c'));
            accList.add(new Account(Name= 'd'));
            accList.add(new Account(Name= 'p'));
            accList.add(new Account(Name= 'n'));
            INSERT accList;
    
            List<Account> reversedList= new LIst<Account>();
            for(integer I= accList.size()-1; i>=0; i--){
                reversedList.add(accList.get(I));
            }
    
            return reversedList;
        }

 
Could anyone explain what is a test-runner software?
When we deploy the code to production, test-runner is going to pick each and every test from code and is going to run all the tests. It will then give the code coverage. 
 
I want to know the difference between shared limits, collective limits and cumulative cross-namespace limits?
Per-transaction limits for managed packages:
With this governor limit, there is no limit to the number of certified namespaces that can be accessed through a single transaction. However, the prerequisite is that the number of operations that can be performed in a single namespace does not exceed the per-transaction limits. In addition, the total number of operations that can be performed in any transaction across the namespace is limited. The total limit for each namespace is 11 times. Shared limits on all namespaces are not affected by collective limits, such as a limit on maximum CPU time.
Description                   | Cumulative Cross-namespace Limits 
The total number of SOQL queries issued | 1,100
I want to check the data response for wire adapters but I don't see the object in the dev console. 
There is no error, I am able to see the output on UI but I want to be able to see in the dev console for chrome so that I can accordingly customize my data. 
I am looking for a scenario as to, when we use apex sharing over declarative ways. 
 
Thank you!
I am looking for a scenario as to, when we use apex sharing over declarative ways. 
 
Thank you!
Hi all, 
Happy New Year!


Could you guys tell me the scenarios as to when we use callouts in batch apex?
I would like to point out that I am looking for input on the scenarios that you guys faced or know/read about. 
I am inclined more towards when than the how part of this. 

 
Below is the code:
Test class doesn't cover the bold part of the code. 
@httpGet
    global static accountWrapper accountInformation(){
        RestRequest req= Restcontext.request;
      // String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        String requestURI= req.requestURI;
        String accountId= requestURI.substringAfterLast('/');
        List<Account> accList= [SELECT ID, Name, Rating, Description, Industry, Phone, Fax
                                FROM Account WHERE ID =: accountId];
        
        List<Contact> conList= [SELECT ID, Name, FirstName, LastName, Email, Phone 
                                FROM Contact WHERE accountId IN: accList ];
        
        List<Case> caseList= [SELECT Id, CaseNumber, Subject, Description, Status, Owner.Name
                              FROM Case WHERE accountId IN: accList];
        
        accountWrapper wrapper= new accountWrapper();
        if(!accList.isEmpty()){
            wrapper.accountRecord= accList.get(0);
            wrapper.conList= conList;
            wrapper.caseList= caseList;
        }
        
        return wrapper;
    }

  global class accountWrapper{
        global Account accountRecord;
        global List<Contact> conList;
        global List<Case> caseList;
    }
Test class:
@isTest
    public static void deleteAccountTest(){
        String recordId= createTestRecord();
        String url= '/services/apexrest/v1/Account'+recordId;
            
        RestRequest req= New RestRequest();
        req.httpMethod= 'DELETE';
        req.requestURI= url;
        
        RestContext.request= req;
        
        try{
        Test.startTest();
        AccountManager.deleteAccount(	);
        Test.stopTest();
        }catch(system.Exception ex){
            system.assertNotEquals(null, ex.getMessage());
        }
    }


    static Id createTestRecord(){
        Account testAcc= New Account();
        testAcc.Name= 'testAccount';
        INSERT testAcc;
        
        Contact testCon= New Contact();
        testCon.LastName= 'test contact';
        testCon.AccountId= testAcc.Id;
        INSERT testCon;
        
        return testAcc.Id;
        
    }



 
========================== CLASS====================

@httpDelete
    global static String deleteAccount(){
        RestRequest req= Restcontext.request;
        String requestURI= req.requestURI ;
        String accountId= requestURI.substringAfterLast('/');
        List<Account> accList= [SELECT ID, Name, Rating, Description, Industry, Phone, Fax
                                FROM Account WHERE ID =: accountId];
        if(accList != null && accList.size() >0 ){
            try{
               DELETE accList; 
               return '{"message": "Account deleted"}';
            }Catch(system.Exception ex){
                String errorMessage= ex.getMessage();
                return '{"message":"'+errorMessage+'"}';
            }
        }else{
            return '{"message": "No record found"}';
        }
    }

====================TEST CLASS===================
 @isTest
    public static void deleteAccountTest(){
        String recordId= createTestRecord();
        String url= '/services/apexrest/v1/Account'+recordId;
            
        RestRequest req= New RestRequest();
        req.httpMethod= 'DELETE';
        req.requestURI= url;
        
        RestContext.request= req;
       
        Test.startTest();
        AccountManager.deleteAccount(	);
        Test.stopTest();
    }

 static Id createTestRecord(){
        Account testAcc= New Account();
        testAcc.Name= 'testAccount';
        INSERT testAcc;
        
        Contact testCon= New Contact();
        testCon.LastName= 'test contact';
        testCon.AccountId= testAcc.Id;
        INSERT testCon;
        
        return testAcc.Id;
        
    }
I have trouble with the try catch block.