• RichardR1
  • NEWBIE
  • 140 Points
  • Member since 2019
  • Salesforce Admin trying to learn to code

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 42
    Questions
  • 30
    Replies
It does not look like I have an option to access apex classes from my Org using Visual Studio Code.
Hello everyone, I created a custom list of Event records using a custom controller and Visualforce page. In the list the user can edit an Event but after saving the change, it also changes the last modified date of the other records on the list, even though there was no change to the data. What can I do so that Salesforce will only update the record that was changed?
Below is my current custom controller:
public class EventsMDHomePage{

    public List<Event> eventsToday {get; set;}

    public EventsMDHomePage() {
        eventsToday = [
            SELECT FIELDS(STANDARD)
            FROM Event
            WHERE OwnerId =: UserInfo.getUserId() AND ActivityDate =: date.today()
            ORDER BY StartDateTime ASC
            LIMIT 1000];
    }
    
    public PageReference saveEvents() {
        try{
            update eventsToday;
        }
        catch(DmlException ex){
            ApexPages.addMessages(ex);
        }
        return null;
    }      
}
Hi guys, for some reason my test class says Pass in the Developer Console but code coverage is 0% at the same time. How can it pass the test if there is 0%? I only used a test class generator because I'm not good at creating test classess yet.

Here is my custom controller:
public class ContactTasks{
    public Event event;
    public ContactTasks() {
        event = [SELECT FIELDS(STANDARD) FROM Event WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }
    public Event getEvent(){
        return event;
    }
    List <Task> relatedTasks;
        public List<Task> getrelatedTasks(){
        relatedTasks = [SELECT FIELDS(STANDARD)
                FROM Task
                WHERE WhoId= :this.event.WhoId
                ORDER BY ActivityDate DESC];
        return relatedTasks;
    }

    
}
Here is my test class:
@isTest
private class ContactTasks_Test{
  @testSetup
  static void setupTestData(){
    test.startTest();
    Contact contact_Obj = new Contact(LastName='Test');
    Insert contact_Obj;
    Event eventobj = new Event(WhoId = contact_Obj.id, DurationInMinutes = 10, ActivityDateTime = Datetime.now());
    Insert eventobj;
    Task task_Obj = new Task(WhoId = contact_Obj.id, ActivityDate = Date.today(), Status = 'Not Started', Priority = 'High', Description = '12', IsReminderSet = false, IsRecurrence = false, Placeholder_for_next_call_set__c = false, BD_Meeting_scheduled_by_InMail__c = false, Duplicate_Meeting__c = false, Automatic_Reply__c = false, Candidate_InMail__c = false, Bounced__c = false);
    Insert task_Obj; 
    test.stopTest();
  }
  static testMethod void test_getEvent_UseCase1(){
    List<Task> task_Obj  =  [SELECT Id,WhoId,WhatId,WhoCount,WhatCount,Subject,ActivityDate,Status,Priority,Description,IsRecurrence,Placeholder_for_next_call_set__c from Task];
    System.assertEquals(true,task_Obj.size()>0);
    PageReference pageRef = Page.ContactsTasks;
    pageRef.getParameters().put('id','test');
    Test.setCurrentPage(pageRef);
    Contact contact_Obj = new Contact(LastName='Test');
    Insert contact_Obj;
    Event eventobj = new Event(WhoId = contact_Obj.id, DurationInMinutes = 10, ActivityDateTime = Datetime.now());
    Insert eventobj;

  }

    static testMethod void test_getEvent_UseCase3(){
    List<Task> task_Obj  =  [SELECT Id,WhoId,WhatId,WhoCount,WhatCount,Subject,ActivityDate,Status,Priority,Description,IsRecurrence,Placeholder_for_next_call_set__c from Task];
    System.assertEquals(true,task_Obj.size()>0);
    PageReference pageRef = Page.ContactsTasks;
    pageRef.getParameters().put('id','test');
    Test.setCurrentPage(pageRef);


    task_Obj[0].ActivityDate = date.parse('7/13/2022');
    task_Obj[0].Status='Not Started';
    task_Obj[0].Priority='High';
    task_Obj[0].Description = '0';

  }
  static testMethod void test_getrelatedTasks_UseCase1(){
    List<Task> task_Obj  =  [SELECT Id,WhoId,WhatId,WhoCount,WhatCount,Subject,ActivityDate,Status,Priority,Description,IsRecurrence,Placeholder_for_next_call_set__c from Task];
    System.assertEquals(true,task_Obj.size()>0);
    PageReference pageRef = Page.ContactsTasks;
    pageRef.getParameters().put('id','test');
    Test.setCurrentPage(pageRef);

  }

    static testMethod void test_getrelatedTasks_UseCase2(){
    List<Task> task_Obj  =  [SELECT Id,WhoId,WhatId,WhoCount,WhatCount,Subject,ActivityDate,Status,Priority,Description,IsRecurrence,Placeholder_for_next_call_set__c from Task];
    System.assertEquals(true,task_Obj.size()>0);
    PageReference pageRef = Page.ContactsTasks;
    pageRef.getParameters().put('id','test');
    Test.setCurrentPage(pageRef);


    task_Obj[0].ActivityDate = date.parse('7/13/2022');
    task_Obj[0].Status='Not Started';
    task_Obj[0].Priority='High';
    task_Obj[0].Description = '0';

  }
}
Hi all, I created a Visualforce page where I need to rerender some formula fields (number output) but I cannot get them to rerender. I was able to do rerender on other elements in my page though, such as an html text.
<apex:page standardController="Contact" extensions="npsExtension" showHeader="false" sidebar="false">
<apex:form >
  <apex:actionFunction name="save" action="{!saveRecords}" reRender="k,l,m,n" />
<table >
   <tr >
        <td >
            <apex:outputText id="k" style="color:{!if(nps.Phone_Call__c='No','red','black')}"  value="Phone Call"/>
        </td>
        <td><apex:inputField onchange="myFunction()" value="{!nps.Phone_Call__c}" /></td>
        <td><apex:outputField id="l" value="{!nps.Phone_Call_Score__c}" /></td>
        <td><apex:outputField id="m" value="{!nps.Phone_Call_Weight__c}" /></td>
        <td><apex:outputField id="n" value="{!nps.Relationship_Score__c}" /></td>
    </tr>
</table >
<script>
   function myFunction(){
       save();
   };
</script>
</apex:page>

 
I have been searching for days but can't seem to find any clue. I have tried "lightning-datatable" component but it does not work. I was able to do it in Visualforce but now I need to do it in Lightning. Any idea where to start?
How do I go about dividing a record detail page into two or more pages but can still be accessed on the same record detail page? For example, if there are many fields in a detail page, instead of scrolling down to access more fields, you can click on a button that hides the 1st page and shows the 2nd page which shows the rest of the fields. There should also be an option to go back to first page.
Newbie dev here. Does anyone know why inline editing was disabled when I added the script below? The only reason I added it is because every time the page loads, the cursor moves to a specific field in the page, even though that was not last position of the cursor
 
<script>
    window.onload = function(){
        window.scrollTo(0,0);
    };
</script>

Not sure if you wanna see my Visualforce page since it's so long. I realize there is a similar question but it was not enough for me to resolve the issue.
I am trying to access a managed package vf page from Salesforce order(This is working fine), But I am getting an error message when I are accessing it from Communities. Any inputs on this??
I have checked all the vf page permission on community profile and all the setting are good, not sure why this is happening, Once I click on the page it is being redirect to a new page and showing the error as per the screenshot...Any inputs on this??User-added image
What's the simplest way in Visualforce to show a related list that is sorted by a certain field? It should also be inline-editing enabled. Please post sample Visualforce and controller extension/ controller codes.
Hi all, I am trying to learn development while building Apex classes. I got this error upon trying to deploy a custom controller and test class from sandbox to production:
"System.NullPointerException: Attempt to de-reference a null object"

Here is my controller:
public class MyController {

public final Contact c;
ApexPages.StandardController sc;
MyController m;
public MyController(ApexPages.StandardController sc) {
    this.c = (Contact)sc.getRecord();
}

public void quicksave() {
    Job_Applicant__c j = (Job_Applicant__c) sc.getRecord();
    update j.Contact_Candidate__r;
}
}

Here is my test class for the controller:
@isTest
public class testMyController{
public static testMethod void testMyController() {

    Contact c = new Contact(LastName = 'testmycontroller');
    insert c;
    
    Job_Applicant__c j = new Job_Applicant__c(Contact_Candidate__c = c.id);
    insert j;
    
        ApexPages.StandardController sc = new ApexPages.standardController(c);
    MyController m = new MyController(sc);
    System.assertEquals(m.c, c);
    
    Test.startTest();
    m.quicksave();
    test.stopTest();
}
}

Thanks
Hello, I am just learning development but I need to be able to use my custom controller I created for use in a visualforce page in production. I can't get past code coverage failure when I try to deploy. Not sure if there's something wrong with my custom controller. I tried all the existing test classes available in production. Below is the code for my controller:
public class MyController {

public ApexPages.StandardController sc;

public MyController(ApexPages.StandardController sc) {
    this.sc = sc;
}

public void quicksave() {
    AVTRRT__Job_Applicant__c j = (AVTRRT__Job_Applicant__c) sc.getRecord();
    update j.AVTRRT__Contact_Candidate__r;
}
}

 

Hello, I am new and teaching myself Visualforce development and I need help. I created a visualforce page to be placed on a child custom object record detail page.

All I want to do is allow my users to be able to edit some fields from the parent object (Contact) while they are on the child object (Job Applicant) record page. I was able to show the fields in the visualforce page, however, when I test it by make editing the field values and clicking Save, the changes do not save at all. I need to accomplish this in Classic interface.

<apex:page standardController="Job_Applicant__c" sidebar="false" >
   <apex:form >
   <apex:inlineEditSupport />
   <apex:pageBlock mode="maindetail" >
   <apex:pageBlockSection  >
           
         <apex:pageBlockSectionItem> <apex:outputField value="{!Job_Applicant__c.Contact_r.Handle_with_care__c}" /> </apex:pageBlockSectionItem>
         <apex:pageBlockSectionItem > <apex:outputField value="{!Job_Applicant__c.Contact_r.Geographic_Preferences_Notes__c}"/> </apex:pageBlockSectionItem>

   </apex:pageBlockSection>
 <apex:commandButton action="{!quicksave}" value="Save" />
   </apex:pageBlock>
   </apex:form>
</apex:page>
Hello. Does anyone know how to read the REPORT_DESCRIPTION from workbench?

I'm just looking to see if I can find any information about the row count of the report that was exported.

I downloaded some logs for ReportExport, not so much details on there except for the REPORT_DESCRIPTION column. See actual content below:
 
?last_modified_user_id=005j000000DTznr&irpe19=true&irpe18=true&irpe17=true&irpe16=true&irpe15=true&irpe14=true&_CONFIRMATIONTOKEN=VmpFPSxNakF5TUMwd09DMHhNRlF5TVRvME5qbzFNeTQxTkRWYSxEdlZpb0RCZV93NzZyNVdmcjlmZURTLFltVmxOakV4&cfsize=12&irpe13=true&tfg=0&irpe23=true&irpe22=true&irpe21=true&irpe20=true&rt=2&save_drill=0&Yman=no&cc10=false&currency=000&co=1&l=1&cp=b&cs=default&ct=none&v=142&ctsize=18&last_modified_date=7%2F15%2F2020+5%3A17+PM&bg2=16777215&bg1=16777215&cc22=false&cc23=false&colDt_c=CREATED_DATE&details=yes&pc0=00Nf100000Bnlin&export=Export&pc2=00N3a00000Ctr8r&pc1=00Nj0000003m1b9&pc3=00Nj000000AGKXy&cc19=false&colDt_q=custom&cc17=false&cc18=false&cc15=false&cc16=false&cc13=false&cc14=false&cc11=false&cc12=false&cc20=false&cc21=false&fg=0&scope=organization&irpe12=true&irpe11=true&irpe10=true&enc=ISO-8859-1&irpe7=true&irpe6=true&irpe9=true&irpe8=true&irpe3=false&irpe2=false&pv1=Connected%2CScheduled%2CMet+With+-+Intro+Meeting%2CMet+With+-+Follow-up+Meeting%2CClient%2CFormer+Client&irpe5=true&pv0=Peterson+Loftin&irpe4=true&pv3=6%2F8%2F2020&pv2=True&xf=localecsv&irpe1=false&irpe0=false&id=00O3a0000054WD8&cr_lowcolor0=12735572&cr_lowcolor2=12735572&cr_lowcolor1=12735572&csize=3&c_13=FIRST_NAME&cust_owner=005j000000DTznr&c_14=LAST_NAME&c_11=00Nj0000003I1rm&c_12=00Nj000000CMtyp&c_1=00Nf100000BnN4F&c_0=00Nf100000BnN4A&c_10=00Nj000000BdfLk&c_3=00Nf100000Ckeyk&show_grandtotal=true&c_2=00Nj000000BeTpB&c_5=00N3a00000Ctop4&c_4=00N3a00000CtouY&c_7=00Nf100000CIWvA&c_6=00N3a00000CtopE&c_9=00Nf100000CCSvd&chsa=mbars&c_8=00Nf100000CCSvY&cnt=52&sortdir=up&chda=no&c_28=00Nf100000CI1fd&c_29=00Nj000000CMInQ&c_26=00Nj0000003OdCU&duel0=00Nf100000BnN4A%2C00Nf100000BnN4F%2C00Nj000000BeTpB%2C00Nf100000Ckeyk%2C00N3a00000CtouY%2C00N3a00000Ctop4%2C00N3a00000CtopE%2C00Nf100000CIWvA%2C00Nf100000CCSvY%2C00Nf100000CCSvd%2C00Nj000000BdfLk%2C00Nj0000003I1rm%2C00Nj000000CMtyp%2CFIRST_NAME%2CLAST_NAME%2C00Nj000000Ap9SQ%2CACCOUNT.NAME%2C00Nj0000003RVJa%2C00Nj000000BfRv1%2C00Nf100000BnJav%2C00Nj0000003LJTd%2C00Nf100000CO0P1%2C00Nf100000Bnlin%2C00Nj0000003m1b9%2CCONTACT_ID%2C00Nj000000AGKXy%2C00Nj0000003OdCU%2C00Nj0000006fJGJ%2C00Nf100000CI1fd%2C00Nj000000CMInQ%2C00Nj0000008u4wB%2C00Nj0000008u4vS%2C00Nj000000CMtyk%2C00Nj000000CMtz4%2C00Nj000000CMtyu%2C00N3a00000Ctumk%2C00Nj000000CMtyG%2C00Nf100000CNA9y%2C00Nf100000CN3us%2CEMAIL%2C00Nj0000003OMa3%2C00Nj0000003OMV3%2C00Nf100000Bncp1%2C00Nj0000003BwGG%2C00Nj0000008lWc1%2C00Nj0000003sZif%2C00Nj00000097oRN%2C00Nj0000008txcC%2C00Nj0000008u51p%2C00Nj0000008voJC%2C00Nj0000003IIdG%2C00N3a00000CqNL1&topn=all&c_27=00Nj0000006fJGJ&c_35=00N3a00000Ctumk&c_36=00Nj000000CMtyG&c_33=00Nj000000CMtz4&chum=no&c_34=00Nj000000CMtyu&c_31=00Nj0000008u4vS&c_32=00Nj000000CMtyk&c_30=00Nj0000008u4wB&chsv=no&chst=no&format=tt&c_19=00Nf100000BnJav&sort=00Nf100000CO0P1&chsp=no&show_subtotals=true&c_17=00Nj0000003RVJa&c_18=00Nj000000BfRv1&c_15=00Nj000000Ap9SQ&c_16=ACCOUNT.NAME&c_24=CONTACT_ID&c_25=00Nj000000AGKXy&c_22=00Nf100000Bnlin&c_23=00Nj0000003m1b9&c_20=00Nj0000003LJTd&c_21=00Nf100000CO0P1&bgdir=2&chco=no&lsk=1&cr_highcolor1=5554772&cr_highcolor2=5554772&c_48=00Nj0000008u51p&sideBySide=false&c_49=00Nj0000008voJC&cc1=false&cc0=false&cc3=false&cc2=false&cc5=false&cc4=false&cc7=false&c_51=00N3a00000CqNL1&cc6=false&cc9=false&cc8=false&c_50=00Nj0000003IIdG&cust_name=Marj+-+Tracker&cr_midcolor0=12763732&cr_midcolor1=12763732&sal=yes&cr_midcolor2=12763732&cust_devName=Marj_Tracker&cheh=no&last_modified_by=Prince+Garcia&c_39=EMAIL&c_37=00Nf100000CNA9y&c_38=00Nf100000CN3us&c_46=00Nj00000097oRN&c_47=00Nj0000008txcC&pn1=ne&c_44=00Nj0000008lWc1&cr_highcolor0=5554772&pn0=eq&c_45=00Nj0000003sZif&pn3=le&c_42=00Nf100000Bncp1&pn2=eq&c_43=00Nj0000003BwGG&c_40=00Nj0000003OMa3&c_41=00Nj0000003OMV3
Without using Einstein Analytics, what would it take to be able to link a dashboard which automatically selects a filter based on the link that I sent the user, so the user won't have to select the filters? This would be useful in our case where a dashboard have as many as 50 filters at a time.
I'm trying to setup a workflow rule that writes the values of custom fields created directly in my organization to fields that exist on a visualforce page in a managed package. The workflow rule criteria is set to "created and everytime the record is edited."

The workflow rule works as expected when on a standard page; but the workflow rule isn't triggered when I edit fields on the visualforce page.

Is there a limitation preventing workflow rules from triggering when a visualforce page is being used for both the edit and detail views of the record? If so, is there a work around? I would prefer not to use an apex trigger for this particular task.

Thank you for your help.

I need to render a field based on values in a multi select picklist.  Basically if it contains Special Project, then render the special project field.  However, I can't use includes in the render formula or so says the error message.  Here is what I'm using.  Is there another way to do this?

 

 <apex:pageBlockSectionItem rendered="{!Includes(InteractionRequest.Interaction_Type__c, 'Special Project')  }">
                           
<apex:outputLabel value="Special Projects" for="{!InteractionRequest.Special_Projects__c}"/> 
     <apex:inputField value="{!InteractionRequest.Special_Projects__c}" required="false" />

</apex:pageBlockSectionItem>