• Zane Prater 15
  • NEWBIE
  • 30 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 16
    Replies
I have a template that pulls in related records from a vf component and want to hide when there are no records rather than showing an empty table.  
 
<!---adding table------->
     <table STYLE="{!IF(relatedto.Number_of_Lines__c == 0, 'display:none;','')}" type="text/css">
        table {
            
            border-width: 0px;
            border-spacing: 5px;
            <!--border-style: solid;
            border-color: #FF0000;-->
            background-color: #b0b7bc;
        }
 
        td {
            text-align: center;
            color: #FFFFFF;
            border-width: 0px;
            padding: 0px;
            <!--border-style: solid;
            border-color: #000000;-->
            background-color: #013b59;
        }
 
        th { 
            text-align: center;
            color: #FFFFFF;
            border-width: 0px ;
            padding: 4px ;
            border-style: none ;
            border-color: #000000;
            background-color: #013b59;
        }
        
     </table>
     <font face="arial" size="2">
     
     <table border="50">

    <td><c:ReturnCRItems cse_id="{!relatedTo.id}"></c:ReturnCRItems></td>
    </table></font>

 
//Can not get coverage for lines 9 and 18

public class C_R_Item_List {
    
    public String Case_Id {get; set;}
    public List<C_R_Item__c> items;
    public static Map<Id, Case> CaseMap = new Map<Id, Case>();
    
    public Case cse{
        get{
            cse = [SELECT Id From Case where id = : Case_Id];
            return cse;
        }
        set;
    }
    
    public List<C_R_Item__c> getitems(){
        
        if(String.isBlank(Case_Id) == false){
            Case caseid = [SELECT Id From Case where id = : Case_Id];
            CaseMap.put(caseid.id,caseid);
        }
        
        System.debug('@@@ Case Map : '+CaseMap);
        
        items = [SELECT Code__c, Manufacturer__c, Item_Number__c, Quantity__c, UOM__c, PO_Number__c, Reship__c, Invoice_Number__c, Ship_Date__c 
                 FROM C_R_Item__c WHERE Case__r.id IN : CaseMap.keyset() AND Case__r.id =:Case_Id];
        System.debug('@@@ items '+items);
        return items; 
        
    }
}

//excerpt from test class

        test.startTest(); 

        Map<Id, Case> CaseMap = new Map<Id, Case>();
        string csstring;

        For(Case cse:[Select id From Case Where id =:cse1.id]) {
            C_R_Item_List cs  = new C_R_Item_List();
            csstring = cse.Id;
            cs.Case_Id = csstring;
            cs.cse = cse;
            CaseMap.put(cse.Id,cse);
        
        }

        For(C_R_Item__c cs1: [Select id, Case__r.id from C_R_Item__c where Case__r.id IN : CaseMap.keyset() AND Case__r.id =: csstring]) {

            C_R_Item_List cr2 = new C_R_Item_List();
            cr2.getitems();

           system.debug('value of csstring'+csstring);
           system.debug('value of cr_item'+cs1.Case__r.id); 

      }    

 test.stopTest();

 
global with sharing class JunkQueueBatchJob implements Database.Batchable<sObject>
{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {   
        String query = 'select id from case where owner.Name = \'To Be Deleted\' AND createddate < LAST_N_MONTHS:5 ORDER BY Createddate DESC ';

        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext BC, List<Case> scope)
    {
        delete scope;
    }
    global void finish(Database.BatchableContext BC) {
    }
    
}

//excerpt from test method
list<Case> mktcses = new list<Case>();
        Id mktcse = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Marketing Component').getRecordTypeId();
        
        Case cse1 = new Case();
        cse1.RecordTypeId = mktcse;
        cse1.AccountId = acctObj.Id;
        cse1.ContactId = conObj.Id;
        cse1.Status = 'In Progress';
        cse1.Description = 'Test';
        cse1.Subject = 'Dental Equipment Broadcast';
        cse1.Materials_Due_Date__c = date.today().addDays(60);
        
        mktcses.add(cse1); 

Case cse2 = new Case();
        cse2.RecordTypeId = mktcse;
        cse2.AccountId = acctObj.Id;
        cse2.ContactId = conObj.Id;
        cse2.Status = 'In Progress';
        cse2.Description = 'Test';
        cse2.Subject = 'Dental Webinar';
        cse2.Materials_Due_Date__c = date.today().addDays(60);
        cse2.CreatedDate = date.today().addMonths(-6); 
        
        system.debug('createddate*****'+cse2.CreatedDate);
   
        mktcses.add(cse2);
        
        insert mktcses;
        
            test.startTest(); 
            
            id sysid;
            
            For(Group grp:[Select id, name, owner.name from Group where type ='Queue' AND Name = 'To Be Deleted']) {

                sysid = grp.id;
            }
             cse2.OwnerId = sysid;
            		update cse2;
            system.debug('cse2 owner name_____'+sysid);
            
 //JunkQueueBatchJob is chained with batch class called from scheduler
            Den_Marketing_Scheduler dms = new Den_Marketing_Scheduler();
            String sch = '0 0 23 * * ?'; 
            system.schedule('denmailer', sch, dms);
            
            system.debug('Cases after Deletion*****'+mktcses.size());
            //should return with 1 but is returning 2 (cse2 should have been deleted)

            test.stopTest();

    }

 //system.assertEquals(1, mktcses.size());

 
I am trying check if the suppliedemail field contains any of these domains but is not working.
If(CONTAINS("lincare.com:ndc-inc.com:preferredhomecare.com", SuppliedEmail),mod(value(CaseNumber),3)+1,0)
Need some assistance to handle when matcher.group()  does not find match for that group so system error, 'No Match Found' is not thrown. I have tried the try/catch block but is not working.  

 
Simple requirement: Button that checks a boolean field (synch__c) on all contacts.

APEX CLASS
______________________________________________________
public with sharing class AccountContactAddressChange 
{
    @AuraEnabled
    public static list<Contact> getRelatedList(Id recordId)
    {
        
        List<Contact> Conlist = [Select id,firstname,lastname,MailingCity,
                                 MailingState,MailingPostalCode,account.billingaddress, synch__c
                                 from Contact where AccountId =: recordId ];
        return Conlist;
        
    }
    
    @AuraEnabled
    public static void updateRelatedList(List<Contact> Conlist)
    {
        if(Conlist!= null && Conlist.size()>0)
        {
            update Conlist;
        }
    }
    
    @AuraEnabled
    public static void UpdateCheck(List<Contact> Conlist) {
        For(Contact c:Conlist) {
            c.Synch__c=true;
        }

        update Conlist;
        
    }

}
COMPONENT
_______________________________________________________
<aura:component controller = "AccountContactAddressChange" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="ContactList" type="Contact[]" />
    <aura:attribute name="columns" type="List"/>
    <aura:attribute name="UpdatedList" type="Contact[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.RetrieveData}" />
    <lightning:card iconName="standard:work_capacity_usage" title="Synch Address">
            <div class="slds-align_absolute-center" style="height:5rem"> 
        <button class="slds-button slds-button_brand " onclick="{!c.updateCheck11}">Synch</button></div>
        
            <aura:if isTrue="{!not(empty(v.ContactList))}">
                <lightning:datatable data="{!v.ContactList }" 
                                     columns="{!v.columns }" 
                                     keyField="Id"
                                     draftValues= "{!v.UpdatedList}"
                                     onsave="{!c.SaveUpdatedContacts}"       
                                     hideCheckboxColumn="true"/>
                <aura:set attribute="else">
                    <div Style="text-align : center"> " There are no related contacts "</div>
                </aura:set>
            </aura:if>
        </lightning:card>
    </aura:component>

JS CONTROLLER
_______________________________________________________
({
 RetrieveData : function(component, event, helper) 
    {
         component.set('v.columns', [
            {label: 'First Name', fieldName: 'FirstName', type: 'text'},
            {label: 'Last Name', fieldName: 'LastName', type: 'text'},            
            {label: 'City', fieldName: 'MailingCity', type: 'string'},
            {label: 'State', fieldName: 'MailingState', type: 'string'},
            {label: 'Zipcode', fieldName: 'MailingPostalCode', type: 'string'},
            {label: 'Synch', fieldName: 'Synch__c', type: 'boolean', editable: true} 

         ]);
        var ConList = component.get("c.getRelatedList");
        ConList.setParams
        ({
            recordId: component.get("v.recordId")
        });
        
        ConList.setCallback(this, function(data) 
                           {
                               component.set("v.ContactList", data.getReturnValue());
                           });
        $A.enqueueAction(ConList);
 },
    SaveUpdatedContacts : function(component,event,helper) 
    {
        var UpdatedList = event.getParam('draftValues');        
        var UpdateContacts = component.get("c.updateRelatedList");
        
        UpdateContacts.setParams
        ({
            Conlist : UpdatedList
        });
        UpdateContacts.setCallback(this, function(response) 
                           {
                                var state = response.getState();
                                if (state === 'SUCCESS')
                                {
                                     $A.enqueueAction(component.get('c.RetrieveData'));
      $A.get('e.force:refreshView').fire();
                                }
                                else{
                                     //error handling
                                }
                           });
        $A.enqueueAction(UpdateContacts);
    },

 updateCheck11 : function(component, event, helper)
 {
     helper.updateCheck11_helper(component,event,helper);

     }
 }
)

HELPER
_______________________________________________________

({
    updateCheck11_helper : function(component, event, helper) {
        alert('sdfsd');
        var save_action = c.get("c.updateCheck11");
        save_action.setParams({
        });
        $A.enqueueAction(save_action);
        
    }
})
I have a trigger that is checking if a long text field value contains a substring variable.  I am trying to update only that line but it's appending my update at the end of the last line.
 
//Can not get coverage for lines 9 and 18

public class C_R_Item_List {
    
    public String Case_Id {get; set;}
    public List<C_R_Item__c> items;
    public static Map<Id, Case> CaseMap = new Map<Id, Case>();
    
    public Case cse{
        get{
            cse = [SELECT Id From Case where id = : Case_Id];
            return cse;
        }
        set;
    }
    
    public List<C_R_Item__c> getitems(){
        
        if(String.isBlank(Case_Id) == false){
            Case caseid = [SELECT Id From Case where id = : Case_Id];
            CaseMap.put(caseid.id,caseid);
        }
        
        System.debug('@@@ Case Map : '+CaseMap);
        
        items = [SELECT Code__c, Manufacturer__c, Item_Number__c, Quantity__c, UOM__c, PO_Number__c, Reship__c, Invoice_Number__c, Ship_Date__c 
                 FROM C_R_Item__c WHERE Case__r.id IN : CaseMap.keyset() AND Case__r.id =:Case_Id];
        System.debug('@@@ items '+items);
        return items; 
        
    }
}

//excerpt from test class

        test.startTest(); 

        Map<Id, Case> CaseMap = new Map<Id, Case>();
        string csstring;

        For(Case cse:[Select id From Case Where id =:cse1.id]) {
            C_R_Item_List cs  = new C_R_Item_List();
            csstring = cse.Id;
            cs.Case_Id = csstring;
            cs.cse = cse;
            CaseMap.put(cse.Id,cse);
        
        }

        For(C_R_Item__c cs1: [Select id, Case__r.id from C_R_Item__c where Case__r.id IN : CaseMap.keyset() AND Case__r.id =: csstring]) {

            C_R_Item_List cr2 = new C_R_Item_List();
            cr2.getitems();

           system.debug('value of csstring'+csstring);
           system.debug('value of cr_item'+cs1.Case__r.id); 

      }    

 test.stopTest();

 
global with sharing class JunkQueueBatchJob implements Database.Batchable<sObject>
{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {   
        String query = 'select id from case where owner.Name = \'To Be Deleted\' AND createddate < LAST_N_MONTHS:5 ORDER BY Createddate DESC ';

        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext BC, List<Case> scope)
    {
        delete scope;
    }
    global void finish(Database.BatchableContext BC) {
    }
    
}

//excerpt from test method
list<Case> mktcses = new list<Case>();
        Id mktcse = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Marketing Component').getRecordTypeId();
        
        Case cse1 = new Case();
        cse1.RecordTypeId = mktcse;
        cse1.AccountId = acctObj.Id;
        cse1.ContactId = conObj.Id;
        cse1.Status = 'In Progress';
        cse1.Description = 'Test';
        cse1.Subject = 'Dental Equipment Broadcast';
        cse1.Materials_Due_Date__c = date.today().addDays(60);
        
        mktcses.add(cse1); 

Case cse2 = new Case();
        cse2.RecordTypeId = mktcse;
        cse2.AccountId = acctObj.Id;
        cse2.ContactId = conObj.Id;
        cse2.Status = 'In Progress';
        cse2.Description = 'Test';
        cse2.Subject = 'Dental Webinar';
        cse2.Materials_Due_Date__c = date.today().addDays(60);
        cse2.CreatedDate = date.today().addMonths(-6); 
        
        system.debug('createddate*****'+cse2.CreatedDate);
   
        mktcses.add(cse2);
        
        insert mktcses;
        
            test.startTest(); 
            
            id sysid;
            
            For(Group grp:[Select id, name, owner.name from Group where type ='Queue' AND Name = 'To Be Deleted']) {

                sysid = grp.id;
            }
             cse2.OwnerId = sysid;
            		update cse2;
            system.debug('cse2 owner name_____'+sysid);
            
 //JunkQueueBatchJob is chained with batch class called from scheduler
            Den_Marketing_Scheduler dms = new Den_Marketing_Scheduler();
            String sch = '0 0 23 * * ?'; 
            system.schedule('denmailer', sch, dms);
            
            system.debug('Cases after Deletion*****'+mktcses.size());
            //should return with 1 but is returning 2 (cse2 should have been deleted)

            test.stopTest();

    }

 //system.assertEquals(1, mktcses.size());

 
I am trying check if the suppliedemail field contains any of these domains but is not working.
If(CONTAINS("lincare.com:ndc-inc.com:preferredhomecare.com", SuppliedEmail),mod(value(CaseNumber),3)+1,0)
Need some assistance to handle when matcher.group()  does not find match for that group so system error, 'No Match Found' is not thrown. I have tried the try/catch block but is not working.  

 
Simple requirement: Button that checks a boolean field (synch__c) on all contacts.

APEX CLASS
______________________________________________________
public with sharing class AccountContactAddressChange 
{
    @AuraEnabled
    public static list<Contact> getRelatedList(Id recordId)
    {
        
        List<Contact> Conlist = [Select id,firstname,lastname,MailingCity,
                                 MailingState,MailingPostalCode,account.billingaddress, synch__c
                                 from Contact where AccountId =: recordId ];
        return Conlist;
        
    }
    
    @AuraEnabled
    public static void updateRelatedList(List<Contact> Conlist)
    {
        if(Conlist!= null && Conlist.size()>0)
        {
            update Conlist;
        }
    }
    
    @AuraEnabled
    public static void UpdateCheck(List<Contact> Conlist) {
        For(Contact c:Conlist) {
            c.Synch__c=true;
        }

        update Conlist;
        
    }

}
COMPONENT
_______________________________________________________
<aura:component controller = "AccountContactAddressChange" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="ContactList" type="Contact[]" />
    <aura:attribute name="columns" type="List"/>
    <aura:attribute name="UpdatedList" type="Contact[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.RetrieveData}" />
    <lightning:card iconName="standard:work_capacity_usage" title="Synch Address">
            <div class="slds-align_absolute-center" style="height:5rem"> 
        <button class="slds-button slds-button_brand " onclick="{!c.updateCheck11}">Synch</button></div>
        
            <aura:if isTrue="{!not(empty(v.ContactList))}">
                <lightning:datatable data="{!v.ContactList }" 
                                     columns="{!v.columns }" 
                                     keyField="Id"
                                     draftValues= "{!v.UpdatedList}"
                                     onsave="{!c.SaveUpdatedContacts}"       
                                     hideCheckboxColumn="true"/>
                <aura:set attribute="else">
                    <div Style="text-align : center"> " There are no related contacts "</div>
                </aura:set>
            </aura:if>
        </lightning:card>
    </aura:component>

JS CONTROLLER
_______________________________________________________
({
 RetrieveData : function(component, event, helper) 
    {
         component.set('v.columns', [
            {label: 'First Name', fieldName: 'FirstName', type: 'text'},
            {label: 'Last Name', fieldName: 'LastName', type: 'text'},            
            {label: 'City', fieldName: 'MailingCity', type: 'string'},
            {label: 'State', fieldName: 'MailingState', type: 'string'},
            {label: 'Zipcode', fieldName: 'MailingPostalCode', type: 'string'},
            {label: 'Synch', fieldName: 'Synch__c', type: 'boolean', editable: true} 

         ]);
        var ConList = component.get("c.getRelatedList");
        ConList.setParams
        ({
            recordId: component.get("v.recordId")
        });
        
        ConList.setCallback(this, function(data) 
                           {
                               component.set("v.ContactList", data.getReturnValue());
                           });
        $A.enqueueAction(ConList);
 },
    SaveUpdatedContacts : function(component,event,helper) 
    {
        var UpdatedList = event.getParam('draftValues');        
        var UpdateContacts = component.get("c.updateRelatedList");
        
        UpdateContacts.setParams
        ({
            Conlist : UpdatedList
        });
        UpdateContacts.setCallback(this, function(response) 
                           {
                                var state = response.getState();
                                if (state === 'SUCCESS')
                                {
                                     $A.enqueueAction(component.get('c.RetrieveData'));
      $A.get('e.force:refreshView').fire();
                                }
                                else{
                                     //error handling
                                }
                           });
        $A.enqueueAction(UpdateContacts);
    },

 updateCheck11 : function(component, event, helper)
 {
     helper.updateCheck11_helper(component,event,helper);

     }
 }
)

HELPER
_______________________________________________________

({
    updateCheck11_helper : function(component, event, helper) {
        alert('sdfsd');
        var save_action = c.get("c.updateCheck11");
        save_action.setParams({
        });
        $A.enqueueAction(save_action);
        
    }
})
I have a trigger that is checking if a long text field value contains a substring variable.  I am trying to update only that line but it's appending my update at the end of the last line.