• Jacob Elliott 8
  • NEWBIE
  • 65 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 8
    Replies

Hey All, I have a LWC in a flow screen and when I click next, the screen refreshes but won't move to the next action in the flow. I'm not trying to use custom navigation. 
 

The purpose of the screen is to accept Mail/FileInfo collection of records and allow the user to decide to which team to send the records. It then outputs the collection "sendLegal" back to the flow.

HTML
 

<template>
    
    <template if:true={_mailList}>
        <template for:each={_mailList} for:item="mail">
            <lightning-layout-item key={mail.Id} size="3" class="slds-p-around_none">
                <div class="slds-box slds-p-around_none slds-m-top_x-small slds-m-bottom_medium slds-m-horizontal_none">
                    <lightning-layout>
                        <lightning-layout-item  key={mail.Id} padding="around-small">
                            <div class="custom-box slds-box slds-p-around_medium slds-text-align_center">
                                <lightning-button value={mail.Id} variant="Success" label="Legal" title="Download action with base variant" icon-name="utility:email" class="slds-m-left_x-small" onclick={handleLegal}></lightning-button>
                            </div>
                        </lightning-layout-item>
                        <lightning-layout-item padding="around-small">
                            <div class="custom-box slds-box slds-p-around_medium slds-text-align_center">
                                <lightning-button value={mail.Id} variant="Success" label="Doc" title="Download action with base variant" icon-name="utility:email" class="slds-m-left_x-small" onclick={handleDoc}></lightning-button>
                            </div>
                        </lightning-layout-item>
                        <lightning-layout-item padding="around-small">
                            <div class="custom-box slds-box slds-p-around_medium slds-text-align_center">
                                <lightning-button value={mail.Id} variant="Success" label="DT" title="Download action with base variant" icon-name="utility:email" class="slds-m-left_x-small" onclick={handleDT}></lightning-button>
                            </div>
                        </lightning-layout-item>
                        <lightning-layout-item padding="around-small">
                            <div class="custom-box slds-box slds-p-around_medium slds-text-align_center">
                              <p>{mail.Name}</p>
                            </div>
                        </lightning-layout-item>
                    </lightning-layout>
                </div>
            </lightning-layout-item>
        </template>
    </template>
</template>

Javascript
import { LightningElement, api, wire, track } from 'lwc';
import { FlowAttributeChangeEvent} from 'lightning/flowSupport';

export default class MedRecAlertsScreen extends LightningElement {
    @track _mailList = [];
    @api sendLegal = [];
    @track sendDoc = [];
    @track sendDT = [];

    @api
    get mailList(){
        let docUrl;
            return this._mailList = mailList.map(row => { 
                docUrl = `/${row.Id}`;
                return {...row , docUrl} 
            }) 
    }

    set mailList(val){
        let docUrl;
            this._mailList = val.map(row => { 
                docUrl = `/${row.Id}`;
                return {...row , docUrl} 
            }) 
    } 

    handleLegal(event){
        var tempLegal =[];
        console.log("clicked legal");
        if (event.target.iconName == "utility:email"){
            console.log("Icon Email");
            tempLegal.push(event.target.value);
            /* this.sendLegal.push(tempLegal[0]);
            console.log(this.sendLegal); */
            event.target.iconName = "utility:clear";
            event.target.variant = "Destructive";
            this.sendLegal.push(this._mailList.filter(mail => mail.Id == tempLegal[0]));
            for(let i = 0; i < this.sendLegal.length; i++){ console.log(this.sendLegal.length);}
            const attributeChangeEvent = new FlowAttributeChangeEvent('sendLegal', this.sendLegal);
            this.dispatchEvent(attributeChangeEvent); 
        } else if(event.target.iconName == "utility:clear"){
            console.log("Icon Clear");
            console.log("Icon Email");
            tempLegal.push(event.target.value);
            this.sendLegal.pop(tempLegal[0]);
            console.log(this.sendLegal);
            event.target.iconName = "utility:email";
            event.target.variant = "success";
            for(let i = 0; i < this.sendLegal.length; i++){ console.log(this.sendLegal.length);}
        }
    }


    @track mailcolumns = [{
            label: 'Legal Team',
            type:  'button',
            typeAttributes: 
            {
                iconName: 'utility:email',
                label: 'Legal', 
                name: 'legalTeam', 
                title: 'editTitle', 
                disabled: false, 
                value: 'test'
            },
            sortable: true,
    },
        {
        label: 'Documents Team',
        type:  'button',
        typeAttributes: 
            {
                iconName: 'utility:email',
                label: 'Doc', 
                name: 'documentsTeam', 
                title: 'editTitle', 
                disabled: false, 
                value: 'test'
            },
        sortable: true
    },
        {
        label: 'Disbursements Team',
        type:  'button',
        typeAttributes: 
            {
                iconName: 'utility:email',
                label: 'DT', 
                name: 'dtTeam', 
                title: 'editTitle', 
                disabled: false, 
                value: 'test'
            },
        sortable: true
    },
        {
        label: 'Document Name',
        fieldName: 'docUrl',
        type: 'url',
        typeAttributes: {label: { fieldName: 'Name' }, 
        target: '_blank'}, 
        sortable: true
    },
    ];
}

XML
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>Mail Alert Screen</masterLabel>
    <description>For Mail Team To Choose Who To Alert</description>
    <targets>
        <target>lightning__FlowScreen</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__FlowScreen">
            <property name="mailList" type="@salesforce/schema/litify_docs__File_Info__c[]"/>
            <property name="sendLegal" type="@salesforce/schema/litify_docs__File_Info__c[]" role="outputOnly"/>
           
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

​​​​​​​FlowLWC screen​​​​​​​
Hello All, I'm trying to create a parent component that uses wire service to grab task records and then sorts them into two maps(?) to be consumed by child components. I need them sorted by Status = Completed or Status != Completed.

I'm having trouble figuring out how to iterate over the returned records.

Any help would be greatly appreciated!

Controller
public with sharing class ATLController {
    @AuraEnabled(Cacheable=true)
    public static List<Task> getTasks(String recordId) {
        return [SELECT Id, Subject, TaskSubtype, ActivityDate FROM Task WHERE WhatId = :recordId];
    }
}
JS
import { LightningElement, api, wire } from 'lwc';

export default class AtlBase extends LightningElement {
    @api recordId;

    completedTaskList = [];
    upcomingTaskList = [];

    @wire(getTasks, {recordId:'$recordId'}) 
        tasks; 

        for(let task in tasks){
            if(task.Status === 'Completed'){
                completedTaskList.push(task);
            } else if(task.Status != 'Completed'){
                upcomingTaskList.push(task);
            }
        }
}


 
Is there a way to allow the user to single click to open the select, and then single click to select a value?

I have a table with a "Pay?" column that is a select list field that uses inline-edit on dbl click, which works, but I would like it to work on a single click. Unfortunately, when I change the event to onclick, it will open up the select box but toggle off and on when I try to select a value because I am using a single click on the cell.

Is there a way to allow the user to single click to open the select, and then single click to select a value?

Page:
<apex:page controller="DTTestPageController" lightningStylesheets="true">
    <apex:pageMessages />

 <apex:form id="form">  
    
    <apex:pageBlock mode="inlineEdit" id="pageblock1">  
        <div id="header" class="headerborder">
            <p id="title">DT Worksheet</p>

            <p id="select">
            <apex:selectList size="1" id="filter" value="{!pickValue}">
                <apex:actionSupport event="onchange"  action="{!GetMedicals}" rerender="table1"/>
                <apex:selectOption itemLabel="All" itemValue="All" ></apex:selectOption>
                    <apex:selectOption itemLabel="Needs Review" itemValue="Review" ></apex:selectOption>
                    <apex:selectOption itemLabel="Pay" itemValue="Pay"></apex:selectOption>
                    <apex:selectOption itemLabel="Don't Pay" itemValue="Dont Pay"></apex:selectOption>
            </apex:selectList>
            <apex:commandButton id="alert" value="Alert" rerender="" action="{!alertUser}"/>
        </p>

        </div>
        <apex:pageBlockButtons location="bottom">  
               <apex:commandButton id="saveButton" value="Save" rerender="" action="{!saveme}"/>  
               <apex:commandButton id="cancelButton" value="Cancel" rerender="table1"/>  
        </apex:pageBlockButtons> 
    
        

        <div class="tableborder" id="border">
    <apex:pageBlockTable value="{!lstMedicals}" var="med" id="table1">
        
        <apex:column headerValue="Medical Bill Number" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputLink value="/{!med.Id}" styleClass="link">
                            {!med.Name}
                      </apex:outputLink>
                </apex:actionRegion>  
        </apex:column>

            <apex:column headerValue="Provider" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Provider_Name__c}">
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Pay?" headerClass="headerStyle" id="column1">
            
            
                <apex:actionRegion id="actionRegion1">
                      <apex:outputField value="{!med.Disburse__c}" id="pay">
                              <apex:inlineEditSupport event="onClick" showOnEdit="saveButton,cancelButton"/>
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Notes" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Disbursement_Note__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" id="note"/>
                      </apex:outputField>
                </apex:actionRegion> 
        </apex:column>
    </apex:pageBlockTable>
</div>
 </apex:pageBlock>  
</apex:form>

Controller:
public class DTTestPageController {
    /* private String sortOrder = 'LastName'; */
    public string pickValue{get; set;}
    public litify_pm__Matter__c matterId{get; set;}
    public Id recordTypeId = Schema.SObjectType.Medical_Bill__c.getRecordTypeInfosByName().get('Medical').getRecordTypeId();
    public list<Medical_Bill__c> lstMedicals{get; set;}

    public DTTestPageController(){
        pickValue = 'All';
        GetMedicals();
    }

    public void GetMedicals() {
        
        matterId = [SELECT Id, litify_pm__Principal_Attorney__c, Litigation_Attorney__c  FROM litify_pm__Matter__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
        

        


        if (pickValue == 'All') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c from Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId];
            
        }
        else if (pickValue == 'Review') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = null];
        }
        else if (pickValue == 'Pay') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = 'Yes'];
        }
        else if (pickValue == 'Dont Pay') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = 'No'];
        }
        else {
             lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c from Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId];
        }
        
    }

    public pagereference saveme()
    {
    try
    {
        System.debug(lstMedicals);
        update lstMedicals;
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Medical Bill List Updated!'));
    }   
    catch(DmlException ex)
    {
        ApexPages.addMessages(ex);

    }
    return NULL;
    }   

  /*   public void sortByFirstName() {
        this.sortOrder = 'LastName';
    } */

    public void alertUser() {
        Id profileId=userinfo.getProfileId();
        String profileName=[Select Id,Name from Profile where Id=:profileId].Name;
        Id ownerId;
        String assignedRole;
        String subject;

        if (profileName == 'Disbursements Team' || profileName == 'Disbursements Team Lead') {

            if (matterId.Litigation_Attorney__c == null) {
                ownerId = matterId.litify_pm__Principal_Attorney__c;
            }
            else {
                ownerId = matterId.Litigation_Attorney__c;
            }

            assignedRole = 'Attorney';
            subject = 'Verify The List Of Medical Bills We Are Paying Is Correct';

        }
        else {
            ownerId = '0056A000000mKxc';
            assignedRole = 'Disbursements';
            subject = 'The Attorny Has Reviewed The List of Medical Bills';
        }

        Task taskRecord = new Task();
        taskRecord.OwnerId = ownerId;
        taskRecord.Assigned_Role__c = assignedRole;
        taskRecord.Subject = subject;
        taskRecord.WhatId = matterId.Id;
        taskRecord.litify_pm__Matter__c = matterId.Id;
        taskRecord.ActivityDate = System.today();
        taskRecord.Priority = 'Normal';

        insert taskRecord;
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Alert Sent!'));  
    }
}

​​​​​​​​​​​​​​
I have a Visualforce table that isn't populating on page load. It will populate after I select a picklist value from #filter, but not until then. How can I make the data populate automatically on page load?

Page:
<apex:page controller="DTTestPageController" tabStyle="Lead" lightningStylesheets="true">
    <apex:messages/>
    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

<apex:form id="form">  
    
    <apex:pageBlock mode="inlineEdit" id="pageblock1">  
        <div id="header" class="headerborder">
            <p id="title">DT Worksheet</p>

            <p id="select">
            <apex:selectList size="1" id="filter" value="{!pickValue}">
                <apex:actionSupport event="onchange"  action="{!GetMedicals}" rerender="table1"/>
                <apex:selectOption itemLabel="All" itemValue="All" ></apex:selectOption>
                    <apex:selectOption itemLabel="Needs Review" itemValue="Review" ></apex:selectOption>
                    <apex:selectOption itemLabel="Pay" itemValue="Pay"></apex:selectOption>
                    <apex:selectOption itemLabel="Don't Pay" itemValue="Dont Pay"></apex:selectOption>
            </apex:selectList>
            <apex:commandButton id="alert" value="Alert" rerender=""/>
        </p>

        </div>
        <apex:pageBlockButtons location="bottom">  
               <apex:commandButton id="saveButton" value="Save" rerender="" action="{!saveme}"/>  
               <apex:commandButton id="cancelButton" value="Cancel" rerender=""/>  
        </apex:pageBlockButtons> 
    
        

        <div class="tableborder" id="border">
    <apex:pageBlockTable value="{!lstMedicals}" var="med" id="table1">
        
        <apex:column headerValue="Medical Bill Number" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputLink value="/{!med.Id}" styleClass="link">
                            {!med.Name}
                      </apex:outputLink>
                </apex:actionRegion>  
        </apex:column>

            <apex:column headerValue="Provider" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Provider_Name__c}">
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Pay?" headerClass="headerStyle" id="column1">
            

            

            <apex:facet name="header">
               <!--  <apex:commandLink action="{! sortByFirstName }" 
                    reRender="contacts_list">Pay
                </apex:commandLink> -->
            </apex:facet>
            
                <apex:actionRegion id="actionRegion1">
                      <apex:outputField value="{!med.Disburse__c}" id="pay">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton"/>
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Notes" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Disbursement_Note__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" id="note"/>
                      </apex:outputField>
                </apex:actionRegion> 
        </apex:column>
    </apex:pageBlockTable>
</div>
 </apex:pageBlock>  
</apex:form>  

    </html>

</apex:page>
Controller:
public class DTTestPageController {
    private String sortOrder = 'LastName';
    public string pickValue{get; set;}
    public litify_pm__Matter__c matterId{get; set;}
    public Id recordTypeId = Schema.SObjectType.Medical_Bill__c.getRecordTypeInfosByName().get('Medical').getRecordTypeId();
    public list<Medical_Bill__c> lstMedicals{get; set;}
    public void GetMedicals() {

        System.debug(pickValue);

    
        if (pickValue == 'All') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c from Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId];
            
        }
        else if (pickValue == 'Review') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = null];
        }
        else if (pickValue == 'Pay') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = 'Yes'];
        }
        else if (pickValue == 'Dont Pay') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = 'No'];
        }
        else {
             lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c from Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId];
        }
        
    }

    public pagereference saveme()
    {
    try
    {
        System.debug(lstMedicals);
        update lstMedicals;
        
    }   
    catch(DmlException ex)
    {
        ApexPages.addMessages(ex);

    }
    return NULL;
    }   

  /*   public void sortByFirstName() {
        this.sortOrder = 'LastName';
    } */

}


 
Hi all! Any help will be greatly appreciated! 

I have a VF page that is a list of records(Medical Bills) and the user can use inline edit to say whether or not we should pay(Disburse__c) the bill and give a reason why(Note/ Disbursement_Note__c). 

If the user decides to select no to pay(Disburse__c) then the Note field becomes required and if they try to save without leaving a note I would like to populate a Toast Message using  sforce.one.showToast().

The javascript function will need to iterate through a list of the medical bills, see if there is a Pay/Disburse value of no and a Note with the Value of Null and if so, display the toast message. 

Here is the VF Page:
 
<apex:page standardController="litify_pm__Matter__c" extensions="GetMedicals" lightningStylesheets="true">  

    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

    <head>
        
<script>
     function showToast() {
        
        var myList = new Array();
        myList = ‘{!lstMedicals}’;

        boolean showError = false;

        for(Medical_Bill__c med : myList){
            if(med.Disburse__c == 'No' || med.Disbursement_Note__c == null){
                showError = true;
            }
        }

        if(showError){
            
            sforce.one.showToast({
                "title": "Error!",
                "message": "Error.",
                "type": "success"
            });
        }
        else {
            sforce.one.showToast({
                "title": "Success!",
                "message": "Success.",
                "type": "success"
            });
        }
    } 
</script>

    </head>

    <apex:pageMessages id="showmsg"></apex:pageMessages>
     <apex:form >  
         
    <apex:pageBlock mode="inlineEdit">  
        <div id="header" class="headerborder">
            <p id="title">DT Worksheet</p>
        </div>
        <apex:pageBlockButtons location="bottom">  
               <apex:commandButton id="saveButton" value="Save" rerender="showmsg" onclick="showToast();"/>  
               <apex:commandButton id="cancelButton" value="Cancel" rerender="showmsg"/>  
        </apex:pageBlockButtons> 
    
        

        <div class="tableborder">
    <apex:pageBlockTable value="{!lstMedicals}" var="med">
        
        <apex:column headerValue="Medical Bill Number" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputLink value="/{!med.Id}" styleClass="link">
                            {!med.Name}
                      </apex:outputLink>
                </apex:actionRegion>  
        </apex:column>

            <apex:column headerValue="Provider" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Provider_Name__c}">
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Pay?" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Disburse__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" id="pay"/>
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Notes" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Disbursement_Note__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" id="note"/>
                      </apex:outputField>
                </apex:actionRegion> 
        </apex:column>
    </apex:pageBlockTable>
</div>
 </apex:pageBlock>  
</apex:form>  

</apex:page>

Here is the extension, if relevant:
public with sharing class GetMedicals {
    public List<Medical_Bill__c> lstMedicals{get;set;}

    public GetMedicals() {

    }

     public GetMedicals(ApexPages.StandardController controller)
     {
               lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c LIMIT 10 ];
    }

    public pagereference saveme()
    {
    try
    {
        update lstMedicals;
    }   
    catch(Exception e)
    {
        System.debug('Exception occurred '+String.valueOf(e));
    }
    return NULL;
    }       
}

​​​​​​​
I have a batch method that searches for all "Matters" with a certain record type. After they are found it loops though this list, assigns a new record type, and creates several "Stages" for the matter. I can't seem to write a Test class that covers more than 4% (cone of shame). Any help would be greatly appreciated!


Batch Class
 
global class MyBatchClass implements Database.Batchable<sObject> {
     global Database.QueryLocator start(Database.BatchableContext bc) {
        // collect the batches of records or objects to be passed to execute
         return Database.getQueryLocator(
            'SELECT ID, RecordTypeId FROM litify_pm__Matter__c Where litify_pm__Matter_Plan__c = \'a0h6A000002nWNrQAM\' AND (RecordTypeId = \'0126A000000NjDyQAK\' OR RecordTypeId = \'0126A000000xP0cQAE\')'
        );
    }
    global void execute(Database.BatchableContext bc, List<litify_pm__Matter__c> scope){
        // process each batch of records
        List<litify_pm__Matter__c> matters = new List<litify_pm__Matter__c>();
        //List<litify_pm__Matter_Stage_Activity__c> stages = new List<litify_pm__Matter_Stage_Activity__c>();
        //List<litify_pm__Matter_Stage_Activity__c> discoveryStages = new List<litify_pm__Matter_Stage_Activity__c>();
        litify_pm__Matter_Stage_Activity__c WorkSettled;
        litify_pm__Matter_Stage_Activity__c settled;
        litify_pm__Matter_Stage_Activity__c discovery;
        
        for (litify_pm__Matter__c matter : scope){
            if (matter.RecordTypeId == '0126A000000NjDyQAK'){
                matter.RecordTypeId = '0123s000000ywXyAAI';
                matters.add(matter);
            }
            else{
                matter.RecordTypeId = '0123s000000ywXzAAI';
                matters.add(matter);
            }
                
                
              
              litify_pm__Matter_Stage_Activity__c LitPrep = New litify_pm__Matter_Stage_Activity__c();
              LitPrep.Name = 'Litigation Preparation';
                LitPrep.litify_pm__Matter__c = matter.Id;
                LitPrep.litify_pm__Order__c = 8;
                LitPrep.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU022QAD';
                 LitPrep.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(LitPrep);
              upsert(LitPrep);  
            
              litify_pm__Matter_Stage_Activity__c Filed = New litify_pm__Matter_Stage_Activity__c();
              Filed.Name = 'Filed';
                Filed.litify_pm__Matter__c = matter.Id;
                Filed.litify_pm__Order__c = 9;
                Filed.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02CQAT';
                 Filed.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(Filed);
              upsert(Filed);
            
              litify_pm__Matter_Stage_Activity__c Served = New litify_pm__Matter_Stage_Activity__c();
              Served.Name = 'Served';
                Served.litify_pm__Matter__c = matter.Id;
                Served.litify_pm__Order__c = 10;
                Served.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02HQAT';
                 Served.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(Served);
              upsert(Served);
              
              litify_pm__Matter_Stage_Activity__c WrittenDiscovery = New litify_pm__Matter_Stage_Activity__c();
              WrittenDiscovery.Name = 'Written Discovery';
                WrittenDiscovery.litify_pm__Matter__c = matter.Id;
                WrittenDiscovery.litify_pm__Order__c = 11;
                WrittenDiscovery.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02HQAT';
                 WrittenDiscovery.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(WrittenDiscovery);
              upsert(WrittenDiscovery);
            
              litify_pm__Matter_Stage_Activity__c DOP = New litify_pm__Matter_Stage_Activity__c();
              DOP.Name = 'Deposition of Parties';
                DOP.litify_pm__Matter__c = matter.Id;
                DOP.litify_pm__Order__c = 12;
                DOP.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02MQAT';
                 DOP.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(DOP);
              upsert(DOP);
              
              litify_pm__Matter_Stage_Activity__c ExpertDep = New litify_pm__Matter_Stage_Activity__c();
              ExpertDep.Name = 'Expert Deposition';
                ExpertDep.litify_pm__Matter__c = matter.Id;
                ExpertDep.litify_pm__Order__c = 13;
                ExpertDep.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02MQAT';
                 ExpertDep.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(ExpertDep);
              upsert(ExpertDep);
            
              litify_pm__Matter_Stage_Activity__c Mediation = New litify_pm__Matter_Stage_Activity__c();
              Mediation.Name = 'Mediation';
                Mediation.litify_pm__Matter__c = matter.Id;
                Mediation.litify_pm__Order__c = 14;
                Mediation.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02MQAT';
                 Mediation.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(Mediation);
              upsert(Mediation);
              
              litify_pm__Matter_Stage_Activity__c Trial = New litify_pm__Matter_Stage_Activity__c();
              Trial.Name = 'Trial';
                Trial.litify_pm__Matter__c = matter.Id;
                Trial.litify_pm__Order__c = 15;
                Trial.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02RQAT';
                 Trial.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(Trial);
              upsert(Trial);
            
              litify_pm__Matter_Stage_Activity__c TrialPrep = New litify_pm__Matter_Stage_Activity__c();
              TrialPrep.Name = 'Trail Preparation';
                TrialPrep.litify_pm__Matter__c = matter.Id;
                TrialPrep.litify_pm__Order__c = 16;
                TrialPrep.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02RQAT';
                 TrialPrep.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(TrialPrep);
              upsert(TrialPrep);
            
            
            
                WorkSettled = [SELECT ID FROM litify_pm__Matter_Stage_Activity__c 
                           Where Name = 'Working to Settle' AND litify_pm__Matter__c = :matter.Id];
              WorkSettled.litify_pm__Order__c = 17;
              //stages.add(settled);
              update(WorkSettled);
                
              settled = [SELECT ID FROM litify_pm__Matter_Stage_Activity__c 
                           Where Name = 'Settled' AND litify_pm__Matter__c = :matter.Id];
              settled.litify_pm__Order__c = 18;
              //stages.add(settled);
              update(settled);
            
              discovery = [SELECT ID FROM litify_pm__Matter_Stage_Activity__c 
                           Where Name = 'Discovery' AND litify_pm__Matter__c = :matter.Id];
              //discoveryStages.add(discovery);
              delete(discovery);
        }
        update matters;
        //upsert stages;
        //delete discoveryStages;
    }    
    global void finish(Database.BatchableContext bc){
        // execute any post-processing operations
    }    
}

Test class (please don't laugh)
 
@isTest
private class MyBatchClassTest {
   static testMethod void BatchProcessAccount_TestMethod (){
         Test.StartTest();
        List<litify_pm__Matter__c> matter = [SELECT ID, RecordTypeId FROM litify_pm__Matter__c Where litify_pm__Matter_Plan__c = 'a0h6A000002nWNrQAM' AND (RecordTypeId = '0126A000000NjDyQAK' OR RecordTypeId = '0126A000000xP0cQAE')];
     
         litify_pm__Matter__c mat = new litify_pm__Matter__c(litify_pm__Display_Name__c = 'Darth', Case_Red_Flags__c='flag',
               litify_pm__Client__c ='0016A00000ITd3QQAT');
                insert mat;
         
         litify_pm__Matter_Stage_Activity__c stage = new litify_pm__Matter_Stage_Activity__c(Name = 'Settled', litify_pm__Order__c  =1,
                  litify_pm__Matter__c= mat.Id, litify_pm__Stage_Status__c = 'Idle');
                insert stage;
         
         List<litify_pm__Matter_Stage_Activity__c> stages = new List<litify_pm__Matter_Stage_Activity__c>();
         
         for (litify_pm__Matter__c i : matter){
             litify_pm__Matter_Stage_Activity__c stage1 = new litify_pm__Matter_Stage_Activity__c(Name = 'Settled', litify_pm__Order__c  =1,
                  litify_pm__Matter__c= i.Id, litify_pm__Stage_Status__c = 'Idle');
             stages.add(stage1);
         }
        insert(stages);
   
   MyBatchClass objBatch = new MyBatchClass();
   ID batchprocessid = Database.executeBatch(objBatch);
   Test.StopTest();
  }
    
}

​​​​​​​
Hello, I am trying to unlock a "Matter" record when the record goes into an approval process. A trigger will see that it is locked and then unlock the record. This is working, but my test class is only covering 66%. How can I get it to 100%? Thanks!

Trigger
trigger UnlockMatter on litify_pm__Matter__c (after insert, after update) {
    for(litify_pm__Matter__c matter : trigger.New) {
        If(Approval.isLocked(matter.Id)) {
            Approval.unlock(matter.Id);
        }
    }
}

Test Class
@isTest
public class TestUnlockMatter {
     @isTest static void TestEditMatterInApproval() {
          // Test data setup
          
          // Create A Party to assign to the matter
          Account party = new Account(litify_pm__First_Name__c='Jim', litify_pm__Last_Name__c='Halpert');
          insert party;
          
          // Create A Matter that is locked and unlock and edit it
          litify_pm__Matter__c matter = new litify_pm__Matter__c(litify_pm__Display_Name__c='Jim Halpert vs. Dwight Schrute', litify_pm__Client__c= party.Id);
          insert matter;
          Approval.lock(matter.Id);
         
         //Perform Test
         Test.startTest();
         Approval.unlock(matter.Id);
         matter.litify_pm__Display_Name__c ='Jim Halpert vs. Micheal Scott';
         Test.stopTest();
     }
}

 
I am trying to allow a user to select an object from a dropdown, and based on the chosen object, return a random number of records. The problem I'm having is that I am having trouble returning different types of object lists in the controller. What is the appropriate way to do this?

Controller
public with sharing class SearchObjectsToAudit {
    @AuraEnabled(Cacheable=true)
    public static Account[] searchAccounts(){
         return [SELECT Id, Name FROM Account ORDER BY Name LIMIT 50];
    }
    @AuraEnabled(Cacheable=true)
    public static Bear__c[] searchIntakes(){
         return [SELECT Id, Name FROM Intake ORDER BY Name LIMIT 50];
    }
    @AuraEnabled(Cacheable=true)
    public static Contact[] searchMatters(){
         return [SELECT Id, Name FROM Contact ORDER BY Name LIMIT 50];
    }
    @AuraEnabled(Cacheable=true)
    public static SearchObjects(String searchTerm) {
         System.debug(searchTerm);
         if (searchTerm == 'Account') {
            return searchAccounts();
        }

        else if (searchTerm == 'Intake') {
            return searchIntakes();
        }

        else if (searchTerm == 'Matters') {
            return searchMatters();
        }
        return null;
    }
}

HTML
<template>
    <lightning-combobox
        name="object"
        label="Object"
        value={searchTerm}
        placeholder="Select Object To Audit"
        options={options}
        onchange={handleChange} >
    </lightning-combobox>

    <lightning-card title="Bears" icon-name="utility:animal_and_nature">
			<div class="slds-card__body_inner">
				<!-- Start bear list -->
				<template if:true={bears.data}>
					<lightning-layout multiple-rows="true" pull-to-boundary="small">
						<template for:each={bears.data} for:item="bear">
							<lightning-layout-item key={bear.Id} size="3" class="slds-p-around_x-small">
                                    <p>{bear.Name}</p>
							</lightning-layout-item>
						</template>
					</lightning-layout>
					<!-- No bears found -->
					<template if:false={hasResults}>
						<div class="slds-align_absolute-center slds-m-vertical_small">
							This is beary disturbing, we did not find results...
						</div>
					</template>
				</template>
				<!-- End bear list -->
				<!-- Data failed to load -->
				<template if:true={bears.error}>
					<div class="slds-text-color_error">
						An error occurred while loading the bear list
					</div>
				</template>
			</div>
		</lightning-card>
</template>

JS File
import { LightningElement, track, wire} from 'lwc';
import SearchObjects from '@salesforce/apex/SearchObjectsToAudit.SearchObjects';
export default class ComboboxBasic extends LightningElement {
    @track value = 'Account';
    @track searchTerm = '';
	@wire(SearchObjects, {searchTerm: '$searchTerm'})
	bears;

    get options() {
        return [
            { label: 'Account', value: 'Account' },
            { label: 'Intake', value: 'Intake' },
            { label: 'Matter', value: 'Matter' },
        ];
    }

    handleChange(event) {
        window.clearTimeout(this.delayTimeout);
		const searchTerm = event.target.value;
		// eslint-disable-next-line @lwc/lwc/no-async-operation
		this.delayTimeout = setTimeout(() => {
			this.searchTerm = searchTerm;
		}, 300);

        this.value = event.detail.value;
    }
}


 
Hello, I am trying to iterate over a list of SObjects, but I'm not sure how to get it to display.

Here is the controller
public with sharing class RandomRecordAudit {
    @AuraEnabled(cacheable=true)
    public static map<string, string> getAllObjects(){
        map<string, string> objectList = new map<string, string>();
        for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        {
            Schema.DescribeSObjectResult objResult = o.getDescribe();
            objectList.put(objResult.getName(), objResult.getLabel());
        }
        return objectList;
    } 
}

Here is the JS file
import { LightningElement, track } from 'lwc';
import getAllObjects from '@salesforce/apex/RandomRecordAudit.getAllObjects';
export default class SObjectList extends LightningElement {
    
        @track objects;
        @track error;
    
        handleLoad() {
            getAllObjects()
                .then(result => {
                    this.objects = result;
                })
                .catch(error => {
                    this.error = error;
                });
        
    }
}

and here is the HTML
<template>
    <lightning-card title="ApexImperativeMethod" icon-name="custom:custom63">
        <div class="slds-m-around_medium">
            <template if:true={objects}>
                <template for:each={objects} for:item="object">
                    <p key={object.Id}>{object.Name}</p>
                </template>
            </template>
            <template if:true={error}>
                <p>Error</p>
                <c-error-panel errors={error}></c-error-panel>
            </template>
        </div>
    </lightning-card>
</template>

Any help is greatly appreciated, thanks!​​​​​​​
I have a Visualforce table that isn't populating on page load. It will populate after I select a picklist value from #filter, but not until then. How can I make the data populate automatically on page load?

Page:
<apex:page controller="DTTestPageController" tabStyle="Lead" lightningStylesheets="true">
    <apex:messages/>
    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

<apex:form id="form">  
    
    <apex:pageBlock mode="inlineEdit" id="pageblock1">  
        <div id="header" class="headerborder">
            <p id="title">DT Worksheet</p>

            <p id="select">
            <apex:selectList size="1" id="filter" value="{!pickValue}">
                <apex:actionSupport event="onchange"  action="{!GetMedicals}" rerender="table1"/>
                <apex:selectOption itemLabel="All" itemValue="All" ></apex:selectOption>
                    <apex:selectOption itemLabel="Needs Review" itemValue="Review" ></apex:selectOption>
                    <apex:selectOption itemLabel="Pay" itemValue="Pay"></apex:selectOption>
                    <apex:selectOption itemLabel="Don't Pay" itemValue="Dont Pay"></apex:selectOption>
            </apex:selectList>
            <apex:commandButton id="alert" value="Alert" rerender=""/>
        </p>

        </div>
        <apex:pageBlockButtons location="bottom">  
               <apex:commandButton id="saveButton" value="Save" rerender="" action="{!saveme}"/>  
               <apex:commandButton id="cancelButton" value="Cancel" rerender=""/>  
        </apex:pageBlockButtons> 
    
        

        <div class="tableborder" id="border">
    <apex:pageBlockTable value="{!lstMedicals}" var="med" id="table1">
        
        <apex:column headerValue="Medical Bill Number" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputLink value="/{!med.Id}" styleClass="link">
                            {!med.Name}
                      </apex:outputLink>
                </apex:actionRegion>  
        </apex:column>

            <apex:column headerValue="Provider" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Provider_Name__c}">
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Pay?" headerClass="headerStyle" id="column1">
            

            

            <apex:facet name="header">
               <!--  <apex:commandLink action="{! sortByFirstName }" 
                    reRender="contacts_list">Pay
                </apex:commandLink> -->
            </apex:facet>
            
                <apex:actionRegion id="actionRegion1">
                      <apex:outputField value="{!med.Disburse__c}" id="pay">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton"/>
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Notes" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Disbursement_Note__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" id="note"/>
                      </apex:outputField>
                </apex:actionRegion> 
        </apex:column>
    </apex:pageBlockTable>
</div>
 </apex:pageBlock>  
</apex:form>  

    </html>

</apex:page>
Controller:
public class DTTestPageController {
    private String sortOrder = 'LastName';
    public string pickValue{get; set;}
    public litify_pm__Matter__c matterId{get; set;}
    public Id recordTypeId = Schema.SObjectType.Medical_Bill__c.getRecordTypeInfosByName().get('Medical').getRecordTypeId();
    public list<Medical_Bill__c> lstMedicals{get; set;}
    public void GetMedicals() {

        System.debug(pickValue);

    
        if (pickValue == 'All') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c from Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId];
            
        }
        else if (pickValue == 'Review') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = null];
        }
        else if (pickValue == 'Pay') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = 'Yes'];
        }
        else if (pickValue == 'Dont Pay') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = 'No'];
        }
        else {
             lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c from Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId];
        }
        
    }

    public pagereference saveme()
    {
    try
    {
        System.debug(lstMedicals);
        update lstMedicals;
        
    }   
    catch(DmlException ex)
    {
        ApexPages.addMessages(ex);

    }
    return NULL;
    }   

  /*   public void sortByFirstName() {
        this.sortOrder = 'LastName';
    } */

}


 
Hi all! Any help will be greatly appreciated! 

I have a VF page that is a list of records(Medical Bills) and the user can use inline edit to say whether or not we should pay(Disburse__c) the bill and give a reason why(Note/ Disbursement_Note__c). 

If the user decides to select no to pay(Disburse__c) then the Note field becomes required and if they try to save without leaving a note I would like to populate a Toast Message using  sforce.one.showToast().

The javascript function will need to iterate through a list of the medical bills, see if there is a Pay/Disburse value of no and a Note with the Value of Null and if so, display the toast message. 

Here is the VF Page:
 
<apex:page standardController="litify_pm__Matter__c" extensions="GetMedicals" lightningStylesheets="true">  

    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

    <head>
        
<script>
     function showToast() {
        
        var myList = new Array();
        myList = ‘{!lstMedicals}’;

        boolean showError = false;

        for(Medical_Bill__c med : myList){
            if(med.Disburse__c == 'No' || med.Disbursement_Note__c == null){
                showError = true;
            }
        }

        if(showError){
            
            sforce.one.showToast({
                "title": "Error!",
                "message": "Error.",
                "type": "success"
            });
        }
        else {
            sforce.one.showToast({
                "title": "Success!",
                "message": "Success.",
                "type": "success"
            });
        }
    } 
</script>

    </head>

    <apex:pageMessages id="showmsg"></apex:pageMessages>
     <apex:form >  
         
    <apex:pageBlock mode="inlineEdit">  
        <div id="header" class="headerborder">
            <p id="title">DT Worksheet</p>
        </div>
        <apex:pageBlockButtons location="bottom">  
               <apex:commandButton id="saveButton" value="Save" rerender="showmsg" onclick="showToast();"/>  
               <apex:commandButton id="cancelButton" value="Cancel" rerender="showmsg"/>  
        </apex:pageBlockButtons> 
    
        

        <div class="tableborder">
    <apex:pageBlockTable value="{!lstMedicals}" var="med">
        
        <apex:column headerValue="Medical Bill Number" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputLink value="/{!med.Id}" styleClass="link">
                            {!med.Name}
                      </apex:outputLink>
                </apex:actionRegion>  
        </apex:column>

            <apex:column headerValue="Provider" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Provider_Name__c}">
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Pay?" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Disburse__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" id="pay"/>
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Notes" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Disbursement_Note__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" id="note"/>
                      </apex:outputField>
                </apex:actionRegion> 
        </apex:column>
    </apex:pageBlockTable>
</div>
 </apex:pageBlock>  
</apex:form>  

</apex:page>

Here is the extension, if relevant:
public with sharing class GetMedicals {
    public List<Medical_Bill__c> lstMedicals{get;set;}

    public GetMedicals() {

    }

     public GetMedicals(ApexPages.StandardController controller)
     {
               lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c LIMIT 10 ];
    }

    public pagereference saveme()
    {
    try
    {
        update lstMedicals;
    }   
    catch(Exception e)
    {
        System.debug('Exception occurred '+String.valueOf(e));
    }
    return NULL;
    }       
}

​​​​​​​
I have a batch method that searches for all "Matters" with a certain record type. After they are found it loops though this list, assigns a new record type, and creates several "Stages" for the matter. I can't seem to write a Test class that covers more than 4% (cone of shame). Any help would be greatly appreciated!


Batch Class
 
global class MyBatchClass implements Database.Batchable<sObject> {
     global Database.QueryLocator start(Database.BatchableContext bc) {
        // collect the batches of records or objects to be passed to execute
         return Database.getQueryLocator(
            'SELECT ID, RecordTypeId FROM litify_pm__Matter__c Where litify_pm__Matter_Plan__c = \'a0h6A000002nWNrQAM\' AND (RecordTypeId = \'0126A000000NjDyQAK\' OR RecordTypeId = \'0126A000000xP0cQAE\')'
        );
    }
    global void execute(Database.BatchableContext bc, List<litify_pm__Matter__c> scope){
        // process each batch of records
        List<litify_pm__Matter__c> matters = new List<litify_pm__Matter__c>();
        //List<litify_pm__Matter_Stage_Activity__c> stages = new List<litify_pm__Matter_Stage_Activity__c>();
        //List<litify_pm__Matter_Stage_Activity__c> discoveryStages = new List<litify_pm__Matter_Stage_Activity__c>();
        litify_pm__Matter_Stage_Activity__c WorkSettled;
        litify_pm__Matter_Stage_Activity__c settled;
        litify_pm__Matter_Stage_Activity__c discovery;
        
        for (litify_pm__Matter__c matter : scope){
            if (matter.RecordTypeId == '0126A000000NjDyQAK'){
                matter.RecordTypeId = '0123s000000ywXyAAI';
                matters.add(matter);
            }
            else{
                matter.RecordTypeId = '0123s000000ywXzAAI';
                matters.add(matter);
            }
                
                
              
              litify_pm__Matter_Stage_Activity__c LitPrep = New litify_pm__Matter_Stage_Activity__c();
              LitPrep.Name = 'Litigation Preparation';
                LitPrep.litify_pm__Matter__c = matter.Id;
                LitPrep.litify_pm__Order__c = 8;
                LitPrep.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU022QAD';
                 LitPrep.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(LitPrep);
              upsert(LitPrep);  
            
              litify_pm__Matter_Stage_Activity__c Filed = New litify_pm__Matter_Stage_Activity__c();
              Filed.Name = 'Filed';
                Filed.litify_pm__Matter__c = matter.Id;
                Filed.litify_pm__Order__c = 9;
                Filed.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02CQAT';
                 Filed.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(Filed);
              upsert(Filed);
            
              litify_pm__Matter_Stage_Activity__c Served = New litify_pm__Matter_Stage_Activity__c();
              Served.Name = 'Served';
                Served.litify_pm__Matter__c = matter.Id;
                Served.litify_pm__Order__c = 10;
                Served.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02HQAT';
                 Served.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(Served);
              upsert(Served);
              
              litify_pm__Matter_Stage_Activity__c WrittenDiscovery = New litify_pm__Matter_Stage_Activity__c();
              WrittenDiscovery.Name = 'Written Discovery';
                WrittenDiscovery.litify_pm__Matter__c = matter.Id;
                WrittenDiscovery.litify_pm__Order__c = 11;
                WrittenDiscovery.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02HQAT';
                 WrittenDiscovery.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(WrittenDiscovery);
              upsert(WrittenDiscovery);
            
              litify_pm__Matter_Stage_Activity__c DOP = New litify_pm__Matter_Stage_Activity__c();
              DOP.Name = 'Deposition of Parties';
                DOP.litify_pm__Matter__c = matter.Id;
                DOP.litify_pm__Order__c = 12;
                DOP.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02MQAT';
                 DOP.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(DOP);
              upsert(DOP);
              
              litify_pm__Matter_Stage_Activity__c ExpertDep = New litify_pm__Matter_Stage_Activity__c();
              ExpertDep.Name = 'Expert Deposition';
                ExpertDep.litify_pm__Matter__c = matter.Id;
                ExpertDep.litify_pm__Order__c = 13;
                ExpertDep.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02MQAT';
                 ExpertDep.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(ExpertDep);
              upsert(ExpertDep);
            
              litify_pm__Matter_Stage_Activity__c Mediation = New litify_pm__Matter_Stage_Activity__c();
              Mediation.Name = 'Mediation';
                Mediation.litify_pm__Matter__c = matter.Id;
                Mediation.litify_pm__Order__c = 14;
                Mediation.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02MQAT';
                 Mediation.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(Mediation);
              upsert(Mediation);
              
              litify_pm__Matter_Stage_Activity__c Trial = New litify_pm__Matter_Stage_Activity__c();
              Trial.Name = 'Trial';
                Trial.litify_pm__Matter__c = matter.Id;
                Trial.litify_pm__Order__c = 15;
                Trial.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02RQAT';
                 Trial.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(Trial);
              upsert(Trial);
            
              litify_pm__Matter_Stage_Activity__c TrialPrep = New litify_pm__Matter_Stage_Activity__c();
              TrialPrep.Name = 'Trail Preparation';
                TrialPrep.litify_pm__Matter__c = matter.Id;
                TrialPrep.litify_pm__Order__c = 16;
                TrialPrep.litify_pm__Original_Matter_Stage__c = 'a0k6A00000MU02RQAT';
                 TrialPrep.litify_pm__Stage_Status__c = 'Idle';
              //stages.add(TrialPrep);
              upsert(TrialPrep);
            
            
            
                WorkSettled = [SELECT ID FROM litify_pm__Matter_Stage_Activity__c 
                           Where Name = 'Working to Settle' AND litify_pm__Matter__c = :matter.Id];
              WorkSettled.litify_pm__Order__c = 17;
              //stages.add(settled);
              update(WorkSettled);
                
              settled = [SELECT ID FROM litify_pm__Matter_Stage_Activity__c 
                           Where Name = 'Settled' AND litify_pm__Matter__c = :matter.Id];
              settled.litify_pm__Order__c = 18;
              //stages.add(settled);
              update(settled);
            
              discovery = [SELECT ID FROM litify_pm__Matter_Stage_Activity__c 
                           Where Name = 'Discovery' AND litify_pm__Matter__c = :matter.Id];
              //discoveryStages.add(discovery);
              delete(discovery);
        }
        update matters;
        //upsert stages;
        //delete discoveryStages;
    }    
    global void finish(Database.BatchableContext bc){
        // execute any post-processing operations
    }    
}

Test class (please don't laugh)
 
@isTest
private class MyBatchClassTest {
   static testMethod void BatchProcessAccount_TestMethod (){
         Test.StartTest();
        List<litify_pm__Matter__c> matter = [SELECT ID, RecordTypeId FROM litify_pm__Matter__c Where litify_pm__Matter_Plan__c = 'a0h6A000002nWNrQAM' AND (RecordTypeId = '0126A000000NjDyQAK' OR RecordTypeId = '0126A000000xP0cQAE')];
     
         litify_pm__Matter__c mat = new litify_pm__Matter__c(litify_pm__Display_Name__c = 'Darth', Case_Red_Flags__c='flag',
               litify_pm__Client__c ='0016A00000ITd3QQAT');
                insert mat;
         
         litify_pm__Matter_Stage_Activity__c stage = new litify_pm__Matter_Stage_Activity__c(Name = 'Settled', litify_pm__Order__c  =1,
                  litify_pm__Matter__c= mat.Id, litify_pm__Stage_Status__c = 'Idle');
                insert stage;
         
         List<litify_pm__Matter_Stage_Activity__c> stages = new List<litify_pm__Matter_Stage_Activity__c>();
         
         for (litify_pm__Matter__c i : matter){
             litify_pm__Matter_Stage_Activity__c stage1 = new litify_pm__Matter_Stage_Activity__c(Name = 'Settled', litify_pm__Order__c  =1,
                  litify_pm__Matter__c= i.Id, litify_pm__Stage_Status__c = 'Idle');
             stages.add(stage1);
         }
        insert(stages);
   
   MyBatchClass objBatch = new MyBatchClass();
   ID batchprocessid = Database.executeBatch(objBatch);
   Test.StopTest();
  }
    
}

​​​​​​​
Hello, I am trying to unlock a "Matter" record when the record goes into an approval process. A trigger will see that it is locked and then unlock the record. This is working, but my test class is only covering 66%. How can I get it to 100%? Thanks!

Trigger
trigger UnlockMatter on litify_pm__Matter__c (after insert, after update) {
    for(litify_pm__Matter__c matter : trigger.New) {
        If(Approval.isLocked(matter.Id)) {
            Approval.unlock(matter.Id);
        }
    }
}

Test Class
@isTest
public class TestUnlockMatter {
     @isTest static void TestEditMatterInApproval() {
          // Test data setup
          
          // Create A Party to assign to the matter
          Account party = new Account(litify_pm__First_Name__c='Jim', litify_pm__Last_Name__c='Halpert');
          insert party;
          
          // Create A Matter that is locked and unlock and edit it
          litify_pm__Matter__c matter = new litify_pm__Matter__c(litify_pm__Display_Name__c='Jim Halpert vs. Dwight Schrute', litify_pm__Client__c= party.Id);
          insert matter;
          Approval.lock(matter.Id);
         
         //Perform Test
         Test.startTest();
         Approval.unlock(matter.Id);
         matter.litify_pm__Display_Name__c ='Jim Halpert vs. Micheal Scott';
         Test.stopTest();
     }
}

 
Can Anyone helps we I am trying to deploy below Task trigger from Sandbox to Production but getting error "the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage."

In the below trigger I am trying to create update lead status to "Intro call" when a task is create with Subject contain "Intro call" this code work fine in sandbox but gives code coverage error while deployment.

I am new to devolopment /Coding 

trigger changeLeadStatus on Task (before insert, before update) {
    String desiredNewLeadStatus = 'Intro Call';
    String myString;

    List<Id> leadIds=new List<Id>();
    for(Task t:trigger.new){
    mystring=t.subject.toUpperCase();
        if(t.Status=='Completed' && myString.contains('INTRO CALL')){
            if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){//check if the task is associated with a lead
                leadIds.add(t.whoId);
            }//if 2
        }//if 1
    }//for
    List<Lead> leadsToUpdate=[SELECT Id, Status FROM Lead WHERE Id IN :leadIds AND IsConverted=FALSE];
    For (Lead l:leadsToUpdate){
        l.Status=desiredNewLeadStatus;
    }//for
    
    try{
        update leadsToUpdate;
    }catch(DMLException e){
        system.debug('Leads were not all properly updated.  Error: '+e);
    }
}//trigger
I have a simple SOQL query that I can run using developer console or workbench and it runs fine. But when I copy/paste it into anonymous apex it complains the the field I'm requesting does not exist.  How can that be?  I am running this as a system admin and I *do* have authority to the field. 

Here's a screenshot showing the query in developer workbench side-by-side with anonymous apex and the results.

SOQL Query vs Apex soql query
 
Hello, I am trying to iterate over a list of SObjects, but I'm not sure how to get it to display.

Here is the controller
public with sharing class RandomRecordAudit {
    @AuraEnabled(cacheable=true)
    public static map<string, string> getAllObjects(){
        map<string, string> objectList = new map<string, string>();
        for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        {
            Schema.DescribeSObjectResult objResult = o.getDescribe();
            objectList.put(objResult.getName(), objResult.getLabel());
        }
        return objectList;
    } 
}

Here is the JS file
import { LightningElement, track } from 'lwc';
import getAllObjects from '@salesforce/apex/RandomRecordAudit.getAllObjects';
export default class SObjectList extends LightningElement {
    
        @track objects;
        @track error;
    
        handleLoad() {
            getAllObjects()
                .then(result => {
                    this.objects = result;
                })
                .catch(error => {
                    this.error = error;
                });
        
    }
}

and here is the HTML
<template>
    <lightning-card title="ApexImperativeMethod" icon-name="custom:custom63">
        <div class="slds-m-around_medium">
            <template if:true={objects}>
                <template for:each={objects} for:item="object">
                    <p key={object.Id}>{object.Name}</p>
                </template>
            </template>
            <template if:true={error}>
                <p>Error</p>
                <c-error-panel errors={error}></c-error-panel>
            </template>
        </div>
    </lightning-card>
</template>

Any help is greatly appreciated, thanks!​​​​​​​
Hello,

I have been a certified admin for almost a year now and want to take the next step and learn to be a Salesforce developer. I'm concerned though since I've never written a line of code in my life and have no dev. experience.

In reading some of the Developer 1 trailhead modules, it seems like they already expect you to have development experience before you take the trailheads. My question is this:

Can you learn to be an SF developer from nothing else but the trailhead modules or do you realistically need to learn to program before you start them to have any frame of reference? If the ladder is true, which programming language(s) do I need to learn? I'm kind of lost.

Please help.
Thanks.