• James George 717
  • NEWBIE
  • 60 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 12
    Replies
Hi Friends,
Please help me on below scenerio, and let me know why the assert is failing. experts please suggest
As per my understanding the LeadSource value is populated in the batch class, but after executing the test class assert is not finding it, eventhough I placed assert after the Test.stopTest() method.

Again by providing the value in the test class, the assert works, is this the correct way to test?
as the value is suppose to be set by the execute method, it seems odd to me to set that value in the test class to pass the test
eg:
l.LeadSource = 'Dreamforce';

LeadProcessor.class
global class LeadProcessor implements Database.Batchable<sObject> {
   
    global Integer count = 0;

    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator('SELECT Id, LeadSource FROM Lead');
    }

    global void execute(Database.BatchableContext bc, List<Lead>l_lst){
        List<lead> l_lst_New = new List<Lead>();
        for(Lead l:l_lst){
            l.LeadSource = 'Dreamforce';
            l_lst_New.add(l);
            count = count + 1;
        }
        Update l_lst_New;
    }

    global void finish(Database.BatchableContext bc){
        System.debug('count = '+count);
    }
}

LeadProcessorTest.class
@isTest
public class LeadProcessorTest {
@isTest
    public static void testit(){
        List<Lead> l_lst = new List<Lead>();
        for(Integer i=0;i<200;i++ ){
            Lead l = new Lead();
            l.LastName = 'name'+i;
            l.Company = 'Company';
            l.status = 'Random Status';
            l_lst.add(l);
        }
        INSERT l_lst;

        Test.startTest();
        LeadProcessor lp = new LeadProcessor();
        Database.executeBatch(lp);
        Test.stopTest();
        List<Lead> l_lstX = [SELECT Id, LastName, LeadSource FROM Lead];
        for(Lead l:l_lstX){
            //System.debug('Lead Last Name ' + l.LastName + ' LeadSource='+l.LeadSource);
        }
        System.assertEquals(200, [select count() from Lead where LeadSource = 'Dreamforce'],'The count should be 200');
    }
}

Thanks,
James
Hi All,
Is there any way to display only Debug logs, while executing anonymous apex on VS code.
Current all the junk data is displayed and makes it hard to read the debug values.

Any help appreciated

Thanks,
James
Hi Friends,
Help me why I'm not able to pass List in the below code, it compiles but always returns none and the execute method never executes if the value is List.

 
public Database.QueryLocator start(Database.BatchableContext bc) {
        List<String> temp = new List<String>();
        temp.add('James');
        temp.add('George');
        String query = 'SELECT Id, FirstName, LastName ' +
        ' FROM Contact ' +
        ' WHERE LastName =\'' + temp + '\'' ;
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext bc, List<Contact> scope){
        // process each batch of records
        System.debug('Executing execute---->');
    }

Log shows this 

|SOQL_EXECUTE_BEGIN|[43]|Aggregations:0|SELECT Id, FirstName, LastName  FROM Contact  WHERE LastName ='(James, George)'

Appreciating any help.

Thanks,
James

Hi All,
Please help me on this issue, what can be the reason.

public class OpportunityTriggerHandler extends TriggerHandler {
    private Map newOppMap; 
     private Map OldOppMap; 
     public OpportunityTriggerHandler() {
         this.newOppMap = (Map) Trigger.newMap;
         this. OldOppMap  = (Map) Trigger.oldMap; 
     } 
 }

trying to save the code found on this link:

https://360coder.wordpress.com/2019/07/04/triggerhandler-salesforce/


Error screenshot

User-added image

Hi All,
Please help me on this.
I have created a custom object called 'Purple__c' but, when I try to refer I had to use the Developer Name to access it, why I'm not able to access the object without the prefix/developer name in apex code.
This is happening only in the trailhead.

Sample code (this works but I do not want to put adminxyz__ as prefix):
trigger Purple on adminxyz__Purple__c (before insert) {
    for(adminxyz__Purple__c purple: Trigger.New){
        purple.adminxyz__IsHuman__c = true;
    }
    }

Thanks,
James George
Hi All,
Hopefully somebody can help me on resolving the issue.
From today, I'm getting an error on LWC component from internal file.
No changes have been made to these files, suddenly the error starting popingup... let me know if anybody have any insights

Please find the error.
Uncaught (in promise) TypeError: LWC component's @wire target property or method threw an error during value provisioning. Original error:
[Cannot assign to read only property 'value' of object '#<Object>']
    at kn.set (aura_prod.js:12)
    at e.RecordDraft.reinitializeField (recordUiUtils.js:1)
    at re.initialize (recordUiUtils.js:1)
    at e.RecordDraft.initializeDependentPicklistManagement (recordUiUtils.js:1)
    at detailPanel_Prs_Communication__c___012000000000000AAA___Full___Create___RecordLayout2.createRecordDraft (recordLayout2.js:1)
    at y (recordLayout2.js:1)
    at eval (recordLayout2.js:1)
    at detailPanel_Prs_Communication__c___012000000000000AAA___Full___Create___RecordLayout2.finishDataInitialization (recordLayout2.js:1)
    at L (recordLayout2.js:1)
    at detailPanel_Prs_Communication__c___012000000000000AAA___Full___Create___RecordLayout2.handleGetCreateCloneRecord (recordLayout2.js:1)

 
Hi Friends,
I have made a query with a sub-query in the VS-Code using the command SFDX: Execute Anonymous Apex with editor contents.
Query:
List<Account> accountList = [SELECT Id, Name, (SELECT Id, Contact__c FROM Party_Contacts__r) 
                                     FROM Account 
                                     WHERE Id ='0019C00000N3RiOAXC'];
System.debug('-----------------------------------------------');
System.debug(accountList);
System.debug('-----------------------------------------------');
The result returned only the parent object
10:12:07.21 (35328991)|HEAP_ALLOCATE|[6]|Bytes:69
10:12:07.21 (35346523)|USER_DEBUG|[6]|DEBUG|accountList=(Account:{Id=0019C00000N3RiOAXC, Name=1031 BATA LLC})
10:12:07.21 (35358253)|STATEMENT_EXECUTE|[7]

But the same query when I do it in Developer Console using the SOQL Query Editor displays the parent and child results.
Query Editor Result:
User-added image

What should I do to get the same kind of result in the VS-Code Output

Let me know your comments.
Thanks,
JG
    
Hi Friends,
Let me know if there is any way I can see the Methods in the Apex Class Grouped on a side bar, so I can naviagte between methods without scrolling the lines of code.

Currently whole apex class file is loaded as a flat file editorwith minimum indentation between the methods.

Let me know your comments.

Thanks,
JG
 
Hi Friends,
I am facing a strange issue with the Apex Replay Debugger, while debugging, evenif the variables hold value it displays as [].
This is happening for List, Set datatypes.

Have anybody faced this issue.

Please see the screenshot for more info
User-added image
Hi Friends,
While debugging the apex batch class using the Replay Debugger, if multiple log files are present for a single batch class which one should select for debugging purpose.

Please see the screenshot.User-added image

Thanks
James George
Hi Friends,
I have created couple of Big Objects in our SF environment where SF Analytic studio is installed.

I cannot see the custom Big Object object created while creating the Dataset.
Can anybody point me the right way?

Thanks,
JG
Hi All,
I'm new to the SF Analytics, and have a question about creating a Analytic dataset using Salesforce External Data Objects defined in our salesforce org.

Is it possible for SF Analytics to reach out to External Data Objects specified below screenshot.
User-added image
Thanks,
JG
 
Hi All,
Hopefully somebody can help me on resolving the issue.
From today, I'm getting an error on LWC component from internal file.
No changes have been made to these files, suddenly the error starting popingup... let me know if anybody have any insights

Please find the error.
Uncaught (in promise) TypeError: LWC component's @wire target property or method threw an error during value provisioning. Original error:
[Cannot assign to read only property 'value' of object '#<Object>']
    at kn.set (aura_prod.js:12)
    at e.RecordDraft.reinitializeField (recordUiUtils.js:1)
    at re.initialize (recordUiUtils.js:1)
    at e.RecordDraft.initializeDependentPicklistManagement (recordUiUtils.js:1)
    at detailPanel_Prs_Communication__c___012000000000000AAA___Full___Create___RecordLayout2.createRecordDraft (recordLayout2.js:1)
    at y (recordLayout2.js:1)
    at eval (recordLayout2.js:1)
    at detailPanel_Prs_Communication__c___012000000000000AAA___Full___Create___RecordLayout2.finishDataInitialization (recordLayout2.js:1)
    at L (recordLayout2.js:1)
    at detailPanel_Prs_Communication__c___012000000000000AAA___Full___Create___RecordLayout2.handleGetCreateCloneRecord (recordLayout2.js:1)

 
Hi Friends,
Please help me on below scenerio, and let me know why the assert is failing. experts please suggest
As per my understanding the LeadSource value is populated in the batch class, but after executing the test class assert is not finding it, eventhough I placed assert after the Test.stopTest() method.

Again by providing the value in the test class, the assert works, is this the correct way to test?
as the value is suppose to be set by the execute method, it seems odd to me to set that value in the test class to pass the test
eg:
l.LeadSource = 'Dreamforce';

LeadProcessor.class
global class LeadProcessor implements Database.Batchable<sObject> {
   
    global Integer count = 0;

    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator('SELECT Id, LeadSource FROM Lead');
    }

    global void execute(Database.BatchableContext bc, List<Lead>l_lst){
        List<lead> l_lst_New = new List<Lead>();
        for(Lead l:l_lst){
            l.LeadSource = 'Dreamforce';
            l_lst_New.add(l);
            count = count + 1;
        }
        Update l_lst_New;
    }

    global void finish(Database.BatchableContext bc){
        System.debug('count = '+count);
    }
}

LeadProcessorTest.class
@isTest
public class LeadProcessorTest {
@isTest
    public static void testit(){
        List<Lead> l_lst = new List<Lead>();
        for(Integer i=0;i<200;i++ ){
            Lead l = new Lead();
            l.LastName = 'name'+i;
            l.Company = 'Company';
            l.status = 'Random Status';
            l_lst.add(l);
        }
        INSERT l_lst;

        Test.startTest();
        LeadProcessor lp = new LeadProcessor();
        Database.executeBatch(lp);
        Test.stopTest();
        List<Lead> l_lstX = [SELECT Id, LastName, LeadSource FROM Lead];
        for(Lead l:l_lstX){
            //System.debug('Lead Last Name ' + l.LastName + ' LeadSource='+l.LeadSource);
        }
        System.assertEquals(200, [select count() from Lead where LeadSource = 'Dreamforce'],'The count should be 200');
    }
}

Thanks,
James
Hi All,
Is there any way to display only Debug logs, while executing anonymous apex on VS code.
Current all the junk data is displayed and makes it hard to read the debug values.

Any help appreciated

Thanks,
James
Hi Friends,
Help me why I'm not able to pass List in the below code, it compiles but always returns none and the execute method never executes if the value is List.

 
public Database.QueryLocator start(Database.BatchableContext bc) {
        List<String> temp = new List<String>();
        temp.add('James');
        temp.add('George');
        String query = 'SELECT Id, FirstName, LastName ' +
        ' FROM Contact ' +
        ' WHERE LastName =\'' + temp + '\'' ;
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext bc, List<Contact> scope){
        // process each batch of records
        System.debug('Executing execute---->');
    }

Log shows this 

|SOQL_EXECUTE_BEGIN|[43]|Aggregations:0|SELECT Id, FirstName, LastName  FROM Contact  WHERE LastName ='(James, George)'

Appreciating any help.

Thanks,
James

Hi All,
Please help me on this issue, what can be the reason.

public class OpportunityTriggerHandler extends TriggerHandler {
    private Map newOppMap; 
     private Map OldOppMap; 
     public OpportunityTriggerHandler() {
         this.newOppMap = (Map) Trigger.newMap;
         this. OldOppMap  = (Map) Trigger.oldMap; 
     } 
 }

trying to save the code found on this link:

https://360coder.wordpress.com/2019/07/04/triggerhandler-salesforce/


Error screenshot

User-added image

Hi All,
Please help me on this.
I have created a custom object called 'Purple__c' but, when I try to refer I had to use the Developer Name to access it, why I'm not able to access the object without the prefix/developer name in apex code.
This is happening only in the trailhead.

Sample code (this works but I do not want to put adminxyz__ as prefix):
trigger Purple on adminxyz__Purple__c (before insert) {
    for(adminxyz__Purple__c purple: Trigger.New){
        purple.adminxyz__IsHuman__c = true;
    }
    }

Thanks,
James George
Hi Friends,
I have made a query with a sub-query in the VS-Code using the command SFDX: Execute Anonymous Apex with editor contents.
Query:
List<Account> accountList = [SELECT Id, Name, (SELECT Id, Contact__c FROM Party_Contacts__r) 
                                     FROM Account 
                                     WHERE Id ='0019C00000N3RiOAXC'];
System.debug('-----------------------------------------------');
System.debug(accountList);
System.debug('-----------------------------------------------');
The result returned only the parent object
10:12:07.21 (35328991)|HEAP_ALLOCATE|[6]|Bytes:69
10:12:07.21 (35346523)|USER_DEBUG|[6]|DEBUG|accountList=(Account:{Id=0019C00000N3RiOAXC, Name=1031 BATA LLC})
10:12:07.21 (35358253)|STATEMENT_EXECUTE|[7]

But the same query when I do it in Developer Console using the SOQL Query Editor displays the parent and child results.
Query Editor Result:
User-added image

What should I do to get the same kind of result in the VS-Code Output

Let me know your comments.
Thanks,
JG
    
Hi Friends,
Let me know if there is any way I can see the Methods in the Apex Class Grouped on a side bar, so I can naviagte between methods without scrolling the lines of code.

Currently whole apex class file is loaded as a flat file editorwith minimum indentation between the methods.

Let me know your comments.

Thanks,
JG
 
Hi Friends,
I have created couple of Big Objects in our SF environment where SF Analytic studio is installed.

I cannot see the custom Big Object object created while creating the Dataset.
Can anybody point me the right way?

Thanks,
JG