• Clara Gaunt
  • NEWBIE
  • 10 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 3
    Replies
Hi
I have created an aura component which returns the records in a grid of tiles. However, I would like to set the title of the tile as a url to the returned record. I cant quite get this to work. My current code is below:

Apex Class:
public with sharing class getknowledgearticles {
    @AuraEnabled
    public static List<Knowledge__kav> getknowledge() {
        return [SELECT Id, ArticleTotalViewCount, ArticleCreatedDate,     Group__c,     Full_Description__c, IsLatestVersion,    PublishStatus,     Summary, Title FROM Knowledge__kav WHERE  PublishStatus='Online'AND Group__c includes ('General Information')];
    }
}

CMP:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" controller ="getknowledgearticles" access="global" >
    
    <aura:attribute name="mydataLst" type="Object"/>
     <aura:handler name="init" value="{! this }" action="{! c.init }"/>
  <lightning:layout multipleRows="true">  
    <aura:iteration items="{!v.mydataLst}" var="records" >
       
      <lightning:layoutItem padding="around-small" size="6">  
        <div id="Tilu" class="slds-box">
            <lightning:tile label="{!records.Title}">
                <div class="slds-media__figure">
      <span class="slds-avatar slds-avatar_circle slds-avatar_large">
        <img alt="" src="/resource/1652857196000/info?" title="General Information" />
                    </span></div>
                <dl class="slds-dl_horizontal">
                    <dt class="slds-dl_horizontal__label">
                        <p class="slds-wrap">{!records.Group__c}</p>
                    </dt>
                    <dd class="slds-dl_horizontal__detail slds-tile__meta">
                        <p class="slds-wrap">{!records.Summary}</p>
                    </dd>
               
                  
                </dl>
            </lightning:tile>
        </div> 
       </lightning:layoutItem>
    </aura:iteration>
 </lightning:layout>
</aura:component>

JS CONTROLLER:
({
    init: function (cmp, event, helper) {
         cmp.set('v.records', [
            {label: 'Title', fieldName: 'linkTitle', type: 'url', 
            typeAttributes: {label: { fieldName: 'Title' }, target: '_blank'}}   ]);
        var action=cmp.get('c.getknowledge');
        action.setCallback(this,$A.getCallback(function(response){
            var state=response.getState();
            if(state==="SUCCESS"){
                var oResponse=response.getReturnValue();
                oResponse.forEach(function(record){
                    record.linkTitle = '/'+record.Id;
                });
                cmp.set("v.mydataLst",oResponse);
            }else if(state==="ERROR"){
                var errors=response.getError();console.error(errors);
          }
        }
         ));
        $A.enqueueAction(action);
    },
})
Hi - Trying to write a successful test class for a class which reads a csv attachment as part of an email service and then creates record. I cannot seem to get my head around how to test the csv string part. Current code is below:
Class:
global class agentsummary implements Messaging.InboundEmailHandler {
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,Messaging.InboundEnvelope envelope){        
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult(); 
          Messaging.InboundEmail.TextAttachment[] tAttachments = email.textAttachments;
        Messaging.InboundEmail.BinaryAttachment[] bAttachments = email.BinaryAttachments; 
        String csvbody='';
        String[] csvFileLines = new List<String>();
        List<VCC_Reporting_Object__c> vcclist2= New List<VCC_Reporting_Object__c>();        
        system.debug('bAttachments'+ bAttachments);
        if(bAttachments !=null){
            for(Messaging.InboundEmail.BinaryAttachment btt :bAttachments){
                if(btt.filename.endsWith('.csv')){
                    csvbody = btt.body.toString();  
                    system.debug('csvbody'+ csvbody);                  
                                      
                    csvFileLines = csvbody.split('\n');
                    system.debug('csvFileLines'+ csvFileLines);                    
                    for(Integer i=1; i < csvFileLines.size(); i++){                        
                        String[] csvRecordData = csvFileLines[i].split(',');
                        VCC_Reporting_Object__c vccObj2 = new VCC_Reporting_Object__c() ;
                        system.debug('vccObj2'+ vccObj2);   
                        vccObj2.Agent_Id__c = csvRecordData[0] ;
                         vccObj2.Agent_Name1__c = csvRecordData[1];
                        vccObj2.Name = csvRecordData[1];
                        vccObj2.Inbound_Contacts__c = csvRecordData[3];  
                        vccObj2.Outbound_contacts__c = csvRecordData[4];  
                          vccObj2.Unavailable_Time__c = csvRecordData[9]; 
                        vccObj2.Available_Time__c = csvRecordData[10]; 
                        vccObj2.Refused__c = csvRecordData[12]; 
                      
                       // vccObj.body = Blob.valueOf(tAttachment.Body);                 
                        vcclist2.add(vccObj2);                        
                    }     
                }
            }           
            if(vcclist2.size()>0)                
                insert vcclist2;
            system.debug('vcclist2'+ vcclist2);
        }        
        result.success = true;
        return result;        
                                      }     

}

Test class (only covering the email handler part):
@isTest
public class testagentsummary  {
     static testMethod void TestinBoundEmail()
   {
       // create a new email and envelope object
       Messaging.InboundEmail email = new Messaging.InboundEmail() ;
       Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
       
       // setup the data for the email
      email.subject = 'Create Contact';
      email.fromAddress = 'someaddress@email.com';
      email.plainTextBody = 'email body\n2225256325\nTitle';
      
      // add an Binary attachment
      Messaging.InboundEmail.BinaryAttachment attachment = new Messaging.InboundEmail.BinaryAttachment();
      attachment.body = blob.valueOf('my attachment text');
      attachment.fileName = 'textfileone.txt';
      attachment.mimeTypeSubType = 'text/plain';
      email.binaryAttachments = new Messaging.inboundEmail.BinaryAttachment[] { attachment };
      
      
  
      // add an Text atatchment
  
      Messaging.InboundEmail.TextAttachment attachmenttext = new Messaging.InboundEmail.TextAttachment();
      attachmenttext.body = 'my attachment text';
      attachmenttext.fileName = 'textfiletwo3.txt';
      attachmenttext.mimeTypeSubType = 'texttwo/plain';
      email.textAttachments =   new Messaging.inboundEmail.TextAttachment[] { attachmenttext };
      
      
      // call the email service class and test it with the data in the testMethod
      agentsummary  agent=new agentsummary ();
      agent.handleInboundEmail(email, env);
    
     
   
   }}
  

Any help would be really appreciated
 
Tried what feels like everything and I'm totally stuck. Any help would be really appreciated:

My custom controller:

public class submitFormCustomObjectController {
 
    
    @AuraEnabled
    public static List<Robot_Tracking_Entry__c> getRobot(Robot_Tracking_Entry__c insertRobot){
        insert insertRobot;
        
        return [select Id, Performance_Month__c,NGM_AMR_Requests__c,TQ_TFM__c,dual_supplier_deappoint_process__c,Supplierless_auto_appoint_deappoint__c,market_sector_changes__c,TSEd2__c,JVOD_JNOC__c,TQ_TFM_Power_BI__c,TSE_R3__c,TSE_R_3__c,TSEd4__c, TSE_c_A__c, Finance_accruals__c,IMS__c, Aged_Debt__c,Gosp_import__c, AMR_Photos__c, Customer_Invoicing_Billing__c, DM_Reads__c, GPS_Job_Queue__c, GPS_line_Queue__c, AMR_Certificate_uploads__c, Meter_Pick_up__c, Site_Husbandry_Monitoring__c,AMR_Stop_Deap__c, Site_Husbandry_Remedials__c,NGM_Validation_report__c,NGM_TSE_SLG_1__c, Standard_Work__c,Comments__c,NGM_Report_Distribution__c,    NGM_TSE_Creation__c, NGM_meter_validations__c, Working_days__c, Adhoc_GPS_Checks_Pulsing_check__c from Robot_Tracking_Entry__c];
    }
    
}


My js controller:
( {
    submitrobotInfo : function(component, event, helper) {
        
        var isValidate = true;        
        var firstName = component.find('fName');        
        var firstNameVal = component.find('fName').get('v.value');        
        if($A.util.isUndefinedOrNull(firstNameVal) || $A.util.isUndefined(firstNameVal) || $A.util.isEmpty(firstNameVal)){
            firstName.set('v.errors',[{message:'Performance Month is Required'}]);
            isValidate = false;
        }else{
            firstName.set('v.errors',null);
        }        
        
        if(isValidate){
             var action = component.get('c.getRobot');
             var postData =  component.get('v.robotInfoAc');                
             action.setParams({'insertRobot': postData});
            
            action.setCallback(this, function(response) {            
            var state = response.getState();  
            if (state === 'SUCCESS') {                
                var stringItems = response.getReturnValue();
                component.set('v.robotItrt',stringItems);
                component.set('v.robotInfoAc', null);       
                
                //Show the success toast message
                var toastEvent = $A.get('e.force:showToast');
                toastEvent.setParams({
                    'title':'Success',
                    'type':'success',
                    'message':'Robot Entry submitted successfully.',                        
                });
                toastEvent.fire();   
                // Close the action panel
        var dismissActionPanel = $A.get('e.force:closeQuickAction');
        dismissActionPanel.fire();
            
            }
                
        }); 
        
        $A.enqueueAction(action);
            
        }
        
  

},

        })

My component:
<aura:component controller="submitFormCustomObjectController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:lightningQuickActionWithoutHeader,lightning:actionOverride,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="robotInfoAc" type="Robot_Tracking_Entry__c" default="{'sobjectType': 'Robot_Tracking_Entry__c'}"/>
     <aura:attribute name="robotItrt" type="Robot_Tracking_Entry__c[]"/>    
    <div class="slds">
      <h1 align="center" > Add New Robot Performance Record - Overview</h1>   
        <br></br>
      
            <div class="slds-grid slds-grid_align-center slds-gutters">
                
                    <div class="slds-col slds-size_6-of-12">
//Plus many more input fields
</div>
    </div>
        
        <div class="slds-text-align--center slds-m-top--medium">
            <button class="slds-button slds-button--brand" onclick="{!c.submitrobotInfo}">Submit</button>
        </div>
    
<br/><br/>

  

          
    </div>
    
          
</aura:component>

When I am writing the test class, I am running into bother. Have therefore only created the test data as follows, but whatever method I try just doesn't work

@isTest
public class testsubmitformcontroller {
public static void testsubmitFormCustomObjectController(){
       Robot_Tracking_Entry__c re = new Robot_Tracking_Entry__c();
        re.NGM_AMR_Requests__c = 20;
        re.Comments__c = 'Hello';
       
       Test.StartTest(); 
   submitFormCustomObjectController testsubmit = new submitFormCustomObjectController;
   testsubmit.getRobot(re insertRobot){
        insert insertRobot;
    }
 
}

Help!!!

 
Tried what feels like everything and I'm totally stuck. Any help would be really appreciated:

My custom controller:

public class submitFormCustomObjectController {
 
    
    @AuraEnabled
    public static List<Robot_Tracking_Entry__c> getRobot(Robot_Tracking_Entry__c insertRobot){
        insert insertRobot;
        
        return [select Id, Performance_Month__c,NGM_AMR_Requests__c,TQ_TFM__c,dual_supplier_deappoint_process__c,Supplierless_auto_appoint_deappoint__c,market_sector_changes__c,TSEd2__c,JVOD_JNOC__c,TQ_TFM_Power_BI__c,TSE_R3__c,TSE_R_3__c,TSEd4__c, TSE_c_A__c, Finance_accruals__c,IMS__c, Aged_Debt__c,Gosp_import__c, AMR_Photos__c, Customer_Invoicing_Billing__c, DM_Reads__c, GPS_Job_Queue__c, GPS_line_Queue__c, AMR_Certificate_uploads__c, Meter_Pick_up__c, Site_Husbandry_Monitoring__c,AMR_Stop_Deap__c, Site_Husbandry_Remedials__c,NGM_Validation_report__c,NGM_TSE_SLG_1__c, Standard_Work__c,Comments__c,NGM_Report_Distribution__c,    NGM_TSE_Creation__c, NGM_meter_validations__c, Working_days__c, Adhoc_GPS_Checks_Pulsing_check__c from Robot_Tracking_Entry__c];
    }
    
}


My js controller:
( {
    submitrobotInfo : function(component, event, helper) {
        
        var isValidate = true;        
        var firstName = component.find('fName');        
        var firstNameVal = component.find('fName').get('v.value');        
        if($A.util.isUndefinedOrNull(firstNameVal) || $A.util.isUndefined(firstNameVal) || $A.util.isEmpty(firstNameVal)){
            firstName.set('v.errors',[{message:'Performance Month is Required'}]);
            isValidate = false;
        }else{
            firstName.set('v.errors',null);
        }        
        
        if(isValidate){
             var action = component.get('c.getRobot');
             var postData =  component.get('v.robotInfoAc');                
             action.setParams({'insertRobot': postData});
            
            action.setCallback(this, function(response) {            
            var state = response.getState();  
            if (state === 'SUCCESS') {                
                var stringItems = response.getReturnValue();
                component.set('v.robotItrt',stringItems);
                component.set('v.robotInfoAc', null);       
                
                //Show the success toast message
                var toastEvent = $A.get('e.force:showToast');
                toastEvent.setParams({
                    'title':'Success',
                    'type':'success',
                    'message':'Robot Entry submitted successfully.',                        
                });
                toastEvent.fire();   
                // Close the action panel
        var dismissActionPanel = $A.get('e.force:closeQuickAction');
        dismissActionPanel.fire();
            
            }
                
        }); 
        
        $A.enqueueAction(action);
            
        }
        
  

},

        })

My component:
<aura:component controller="submitFormCustomObjectController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:lightningQuickActionWithoutHeader,lightning:actionOverride,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="robotInfoAc" type="Robot_Tracking_Entry__c" default="{'sobjectType': 'Robot_Tracking_Entry__c'}"/>
     <aura:attribute name="robotItrt" type="Robot_Tracking_Entry__c[]"/>    
    <div class="slds">
      <h1 align="center" > Add New Robot Performance Record - Overview</h1>   
        <br></br>
      
            <div class="slds-grid slds-grid_align-center slds-gutters">
                
                    <div class="slds-col slds-size_6-of-12">
//Plus many more input fields
</div>
    </div>
        
        <div class="slds-text-align--center slds-m-top--medium">
            <button class="slds-button slds-button--brand" onclick="{!c.submitrobotInfo}">Submit</button>
        </div>
    
<br/><br/>

  

          
    </div>
    
          
</aura:component>

When I am writing the test class, I am running into bother. Have therefore only created the test data as follows, but whatever method I try just doesn't work

@isTest
public class testsubmitformcontroller {
public static void testsubmitFormCustomObjectController(){
       Robot_Tracking_Entry__c re = new Robot_Tracking_Entry__c();
        re.NGM_AMR_Requests__c = 20;
        re.Comments__c = 'Hello';
       
       Test.StartTest(); 
   submitFormCustomObjectController testsubmit = new submitFormCustomObjectController;
   testsubmit.getRobot(re insertRobot){
        insert insertRobot;
    }
 
}

Help!!!

 
Hello,

I'm attempting to create an apex trigger which fires off when a LogoutEventStream is created. Currently it works when a user physically logs out of an environment but does not when they are forced to logout because of a session timeout. According to Salesforce documentation, when "Force logout on session timeout" is enabled, a LogoutEventStream is recorded when a user is automatically logged out. See the second paragraph of the linked Salesforce article:

https://help.salesforce.com/s/articleView?id=sf.security_auth_create_logout_event_trigger.htm&type=5 (https://help.salesforce.com/s/articleView?id=sf.security_auth_create_logout_event_trigger.htm&type=5)

I have also included the trigger code as it exists now. As I mentioned, the trigger does what it is suppose to when manually clicking the Log Out button but does not when forced to logout after the end of a session timer which defies the documentation provided in the article above. If someone could help me identify how to resolve this issue by either ensuring LogoutStreamEvents are being properly recorded for forced logouts or providing a recommendation on how to achieve the execution of a trigger when a user is timeout of their session, I would greatly appreciate it.
 
trigger LogoutTrigger on LogoutEventStream (after insert) {
    LogoutEventStream event = 
        Trigger.new[0];
    Date todayDate = 
        System.today();
    List<Time_Card__c> timeCards = 
        [SELECT Id, Time_In__c 
         FROM Time_Card__c 
         WHERE OwnerId = :event.UserId 
         AND Date__c = :todayDate 
         AND Time_In__c != null 
         AND Time_Out__c = null 
         LIMIT 1];
    if (!timeCards.isEmpty()) {
        timeCards[0].Time_Out__c = System.now();
        timeCards[0].System_Clocked_Out__c = TRUE;
        update timeCards[0];
    } 
}



Thank you!
Hello,

I'm attempting to create an apex trigger which fires off when a LogoutEventStream is created. Currently it works when a user physically logs out of an environment but does not when they are forced to logout because of a session timeout. According to Salesforce documentation, when "Force logout on session timeout" is enabled, a LogoutEventStream is recorded when a user is automatically logged out. See the second paragraph of the linked Salesforce article:

https://help.salesforce.com/s/articleView?id=sf.security_auth_create_logout_event_trigger.htm&type=5 (https://help.salesforce.com/s/articleView?id=sf.security_auth_create_logout_event_trigger.htm&type=5)

I have also included the trigger code as it exists now. As I mentioned, the trigger does what it is suppose to when manually clicking the Log Out button but does not when forced to logout after the end of a session timer which defies the documentation provided in the article above. If someone could help me identify how to resolve this issue by either ensuring LogoutStreamEvents are being properly recorded for forced logouts or providing a recommendation on how to achieve the execution of a trigger when a user is timeout of their session, I would greatly appreciate it.
 
trigger LogoutTrigger on LogoutEventStream (after insert) {
    LogoutEventStream event = 
        Trigger.new[0];
    Date todayDate = 
        System.today();
    List<Time_Card__c> timeCards = 
        [SELECT Id, Time_In__c 
         FROM Time_Card__c 
         WHERE OwnerId = :event.UserId 
         AND Date__c = :todayDate 
         AND Time_In__c != null 
         AND Time_Out__c = null 
         LIMIT 1];
    if (!timeCards.isEmpty()) {
        timeCards[0].Time_Out__c = System.now();
        timeCards[0].System_Clocked_Out__c = TRUE;
        update timeCards[0];
    } 
}



Thank you!