• Jennifer Prather
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies
I received an error when testing a lightning web component. 

Invalid key value "[object Object]" in [Object: vm undefined (93)]. Key must be a string or number.

I am not sure what this error means or what it is referrencing. Does anyone know what this means?
I am having difficulty styling the PDF tp make it more readable for users. I was trying to create each section in the table format. Does anyone have any suggestions on how to do that?
<apex:page standardController="Committee_Applicant__c" renderAs="pdf">
    <head>
    </head>
    <body>
    <center>
    	<h1>
        	TVC
   	</h1>
    	<h3>
            Application
        </h3>
    </center>
    <h4>
        Part 1: Applicant's Section
    </h4>
    <table>
        <tr>
            <th>Applicant's Name:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Applicants_Name__c}"/></td>
        </tr>
        <tr>
            <th>Home Address:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Home_Address__c}"/></td>
        </tr>
        <tr>
            <th>City:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Home_City__c}"/></td>
            <th>State:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Home_State__c}"/></td>
            <th>ZIP Code + 4:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Home_ZIP_Code__c}"/></td>
        </tr>
    </table>
    <h4>
        Part 2: Business Section
    </h4>
    <table>
        <tr>
            <th>Applicant's Job Title/Company:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Applicants_Job_Title_Company__c}"/></td>
        </tr>
        <tr>
            <th>Main Responsibilities:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Main_Responsibilities__c}"/></td>
        </tr>
        <tr>
            <th>Work Address:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_Address__c}"/></td>
        </tr>
        <tr>
            <th>City:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_City__c}"/></td>
            <th>State:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_State__c}"/></td>
            <th>ZIP Code + 4:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_ZIP_Code__c}"/></td>
        </tr>
        <tr>
            <th>Work Email:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_Email__c}"/></td>
            <th>Work Phone Number:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_Phone_Number__c}"/></td>
        </tr>
    </table>
    <h4>
        Part 3: Committee Selection Section
    </h4>
   	
        <b><p>
            Select the committee for which you are applying for membership:
        </p></b>
    
    <table>
        <tr>
            <th>Veterans Employment and Training Advisory Committee:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.VET_Advisory_Committee__c}"/></td>
            <th>Preference:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.VET_Preference__c}"/></td>
        </tr>
        <tr>
            <th>Fund for Veterans' Assistance Advisory Committee:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.FVA_Advisory_Committee__c}"/></td>
            <th>Preference:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.FVA_Preference__c}"/></td>
        </tr>
        <tr>
            <th>Veterans County Service Officer Advisory Committee:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.VCSO_Advisory_Committee__c}"/></td>
            <th>Preference:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.VCSO_Preference__c}"/></td>
        </tr>
    </table>
    <br/>
    <table>
         <tr>
             <th>Provide any additional information that you would like the selection committee to consider:</th> 
         </tr>
         <tr>
             <td><apex:outputText value="{!Committee_Applicant__c.Additional_Information__c}"/></td>
        </tr>
    </table>
    <br/>
    <table>
         <tr>
             <th>Briefly tell us why you would like to serve on the selected committees.</th> 
         </tr>
         <tr>
             <td><apex:outputText value="{!Committee_Applicant__c.Why_Serve__c}"/></td>
        </tr>
    </table>
    <br/>
    <table>
         <tr>
             <th>Briefly explain your experience with the Open Meetings Act (if applicable).</th> 
         </tr>
         <tr>
             <td><apex:outputText value="{!Committee_Applicant__c.Open_Meetings_Act__c}"/></td>
        </tr>
    </table>
    </body>
</apex:page>

 
I was trying to add a counter to an input rich text lightning web component. I can get it to display the character count but cannot get it to count down. I was getting an error saying the counter variable I called was not being used as well as the maxlength.
<template>
    <lightning-input-rich-text
        type="text" value={value} maxlength="100">
    </lightning-input-rich-text>
    <span id="counter">100</span>
</template>
 
/* eslint-disable no-unused-vars */
import { LightningElement, track, api } from 'lwc';

export default class InputRichText extends LightningElement {
    @api value;
    @track value;

    itemsChange(_oninput){
        let counter = this.getElementById("counter");
        let maxlength = this.getAttribute("maxlength");
        counter.textContent = maxlength - this.value.length;
    }
}

 
I am trying to test a couple of triggers and classes. I am unable to get the test coverage up to 75%. Here is my classes and triggers: 
 
public class RollUpOrder {
	
    public static void upOrder(List<Order> listOfOrder){
        Set<id> accountIds = new Set<id>();
        List<Account> listOfAccounts = new List<Account>();
        List<Order> listOrders = new List<Order>();
        
        For(Order orders : listOrders){
            accountIds.add(orders.Id);
        }
        
        List<Account> listAccount = [SELECT Id, Name, Number_of_Orders__c, (SELECT Id FROM Orders) FROM Account WHERE Id IN :accountIds];
        
        For(Account acc : listAccount){
            if(acc.Orders.size()>0)
                acc.Number_of_Orders__c = acc.Orders.size();
            	listOfAccounts.add(acc);
        }
        if(listOfAccounts.size()>0)
            update listOfAccounts;
    }
}
 
public class orderCounter {
	
    public static void countOrders(Set<Id> accIds){
        List<Account> accountsToUpdate = new List<Account>();
        Map<Id, Account> accountsMap = new Map<Id, Account>([SELECT Id, Number_of_Orders__c FROM Account WHERE Id IN :accIds]);
        List<AggregateResult> res = [SELECT AccountId, count(Id) FROM Order WHERE AccountId IN :accIds GROUP BY AccountId];
        
        for(AggregateResult accRes : res){
            accountsMap.get(String.valueOf(accRes.get('AccountId'))).Number_of_Orders__c = Integer.valueOf(accRes.get('expr0'));
            accountsToUpdate.add(accountsMap.get(String.valueOf(accRes.get('AccountId'))));
        }
        update accountsToUpdate;
    }
}
 
trigger RollUpOrderTrigger on Order (after insert, after update, after delete, after undelete) {
	
    if(trigger.isAfter && (trigger.isInsert || trigger.isUpdate || trigger.isUndelete)){
        RollUpOrder.upOrder(trigger.new);
    }
    else if(trigger.isAfter && trigger.isDelete){
        RollUpOrder.upOrder(trigger.old);
    }
}
 
trigger orderCounterTrigger on Order (after insert, after update, after delete) {
	
    Set<Id> orderIds = new Set<Id>();
    
    for(Order orders : Trigger.new){
        orderIds.add(orders.AccountId);
    }        
    if(Trigger.isUpdate || Trigger.isDelete){
        for(Order ords : Trigger.old){
            orderIds.add(ords.AccountId);
        }
    }
    orderCounter.countOrders(orderIds);
}

Here is my test class:
@isTest
private class TestRollUp {
	
    @isTest static void TestOrdRollUp(){
        
        Account newAcc = new Account(Name = 'Test');
        insert newAcc;
        
        List<Order> newOrder = new List<Order>();
        Order newOrd = new Order(Name = 'Test', AccountId = newAcc.Id, EffectiveDate = Date.newInstance(2020,2,3), Status = 'Draft');
        newOrder.add(newOrd);
        insert newOrder;
        
        Test.startTest();
        newAcc.Number_of_Orders__c = newOrder.size();
        update newAcc;
        Test.stopTest();
        
        newAcc = [SELECT Number_of_Orders__c FROM Account WHERE Id = :newAcc.Id];
        System.debug('Number after trigger: ' + newAcc.Number_of_Orders__c);
        System.AssertEquals(1, newAcc.Number_of_Orders__c);
    }      
  }

I am not sure how to get the test coverage up. I am having trouble finding a way to test the IF statements.
    
Trying to understand which edition to chose. For sandboxes, is it developer or the production edition?
I received an error when testing a lightning web component. 

Invalid key value "[object Object]" in [Object: vm undefined (93)]. Key must be a string or number.

I am not sure what this error means or what it is referrencing. Does anyone know what this means?
I am having difficulty styling the PDF tp make it more readable for users. I was trying to create each section in the table format. Does anyone have any suggestions on how to do that?
<apex:page standardController="Committee_Applicant__c" renderAs="pdf">
    <head>
    </head>
    <body>
    <center>
    	<h1>
        	TVC
   	</h1>
    	<h3>
            Application
        </h3>
    </center>
    <h4>
        Part 1: Applicant's Section
    </h4>
    <table>
        <tr>
            <th>Applicant's Name:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Applicants_Name__c}"/></td>
        </tr>
        <tr>
            <th>Home Address:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Home_Address__c}"/></td>
        </tr>
        <tr>
            <th>City:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Home_City__c}"/></td>
            <th>State:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Home_State__c}"/></td>
            <th>ZIP Code + 4:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Home_ZIP_Code__c}"/></td>
        </tr>
    </table>
    <h4>
        Part 2: Business Section
    </h4>
    <table>
        <tr>
            <th>Applicant's Job Title/Company:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Applicants_Job_Title_Company__c}"/></td>
        </tr>
        <tr>
            <th>Main Responsibilities:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Main_Responsibilities__c}"/></td>
        </tr>
        <tr>
            <th>Work Address:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_Address__c}"/></td>
        </tr>
        <tr>
            <th>City:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_City__c}"/></td>
            <th>State:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_State__c}"/></td>
            <th>ZIP Code + 4:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_ZIP_Code__c}"/></td>
        </tr>
        <tr>
            <th>Work Email:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_Email__c}"/></td>
            <th>Work Phone Number:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.Work_Phone_Number__c}"/></td>
        </tr>
    </table>
    <h4>
        Part 3: Committee Selection Section
    </h4>
   	
        <b><p>
            Select the committee for which you are applying for membership:
        </p></b>
    
    <table>
        <tr>
            <th>Veterans Employment and Training Advisory Committee:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.VET_Advisory_Committee__c}"/></td>
            <th>Preference:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.VET_Preference__c}"/></td>
        </tr>
        <tr>
            <th>Fund for Veterans' Assistance Advisory Committee:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.FVA_Advisory_Committee__c}"/></td>
            <th>Preference:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.FVA_Preference__c}"/></td>
        </tr>
        <tr>
            <th>Veterans County Service Officer Advisory Committee:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.VCSO_Advisory_Committee__c}"/></td>
            <th>Preference:</th>
            <td><apex:outputText value="{!Committee_Applicant__c.VCSO_Preference__c}"/></td>
        </tr>
    </table>
    <br/>
    <table>
         <tr>
             <th>Provide any additional information that you would like the selection committee to consider:</th> 
         </tr>
         <tr>
             <td><apex:outputText value="{!Committee_Applicant__c.Additional_Information__c}"/></td>
        </tr>
    </table>
    <br/>
    <table>
         <tr>
             <th>Briefly tell us why you would like to serve on the selected committees.</th> 
         </tr>
         <tr>
             <td><apex:outputText value="{!Committee_Applicant__c.Why_Serve__c}"/></td>
        </tr>
    </table>
    <br/>
    <table>
         <tr>
             <th>Briefly explain your experience with the Open Meetings Act (if applicable).</th> 
         </tr>
         <tr>
             <td><apex:outputText value="{!Committee_Applicant__c.Open_Meetings_Act__c}"/></td>
        </tr>
    </table>
    </body>
</apex:page>

 
I am trying to test a couple of triggers and classes. I am unable to get the test coverage up to 75%. Here is my classes and triggers: 
 
public class RollUpOrder {
	
    public static void upOrder(List<Order> listOfOrder){
        Set<id> accountIds = new Set<id>();
        List<Account> listOfAccounts = new List<Account>();
        List<Order> listOrders = new List<Order>();
        
        For(Order orders : listOrders){
            accountIds.add(orders.Id);
        }
        
        List<Account> listAccount = [SELECT Id, Name, Number_of_Orders__c, (SELECT Id FROM Orders) FROM Account WHERE Id IN :accountIds];
        
        For(Account acc : listAccount){
            if(acc.Orders.size()>0)
                acc.Number_of_Orders__c = acc.Orders.size();
            	listOfAccounts.add(acc);
        }
        if(listOfAccounts.size()>0)
            update listOfAccounts;
    }
}
 
public class orderCounter {
	
    public static void countOrders(Set<Id> accIds){
        List<Account> accountsToUpdate = new List<Account>();
        Map<Id, Account> accountsMap = new Map<Id, Account>([SELECT Id, Number_of_Orders__c FROM Account WHERE Id IN :accIds]);
        List<AggregateResult> res = [SELECT AccountId, count(Id) FROM Order WHERE AccountId IN :accIds GROUP BY AccountId];
        
        for(AggregateResult accRes : res){
            accountsMap.get(String.valueOf(accRes.get('AccountId'))).Number_of_Orders__c = Integer.valueOf(accRes.get('expr0'));
            accountsToUpdate.add(accountsMap.get(String.valueOf(accRes.get('AccountId'))));
        }
        update accountsToUpdate;
    }
}
 
trigger RollUpOrderTrigger on Order (after insert, after update, after delete, after undelete) {
	
    if(trigger.isAfter && (trigger.isInsert || trigger.isUpdate || trigger.isUndelete)){
        RollUpOrder.upOrder(trigger.new);
    }
    else if(trigger.isAfter && trigger.isDelete){
        RollUpOrder.upOrder(trigger.old);
    }
}
 
trigger orderCounterTrigger on Order (after insert, after update, after delete) {
	
    Set<Id> orderIds = new Set<Id>();
    
    for(Order orders : Trigger.new){
        orderIds.add(orders.AccountId);
    }        
    if(Trigger.isUpdate || Trigger.isDelete){
        for(Order ords : Trigger.old){
            orderIds.add(ords.AccountId);
        }
    }
    orderCounter.countOrders(orderIds);
}

Here is my test class:
@isTest
private class TestRollUp {
	
    @isTest static void TestOrdRollUp(){
        
        Account newAcc = new Account(Name = 'Test');
        insert newAcc;
        
        List<Order> newOrder = new List<Order>();
        Order newOrd = new Order(Name = 'Test', AccountId = newAcc.Id, EffectiveDate = Date.newInstance(2020,2,3), Status = 'Draft');
        newOrder.add(newOrd);
        insert newOrder;
        
        Test.startTest();
        newAcc.Number_of_Orders__c = newOrder.size();
        update newAcc;
        Test.stopTest();
        
        newAcc = [SELECT Number_of_Orders__c FROM Account WHERE Id = :newAcc.Id];
        System.debug('Number after trigger: ' + newAcc.Number_of_Orders__c);
        System.AssertEquals(1, newAcc.Number_of_Orders__c);
    }      
  }

I am not sure how to get the test coverage up. I am having trouble finding a way to test the IF statements.