• SFDC_Richie
  • NEWBIE
  • 15 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hello folks,

I am trying to use an default email template for the case email publisher.
I found the QuickActionDefaultsHandler Interface which can also be used with Lightning and Lightning Email templates.

Here is my working code so far:
 
/// https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_QuickAction_QuickActionDefaultsHandler.htm

public class IS24_CaseEmailDefault implements QuickAction.QuickActionDefaultsHandler {

    public void onInitDefaults( QuickAction.QuickActionDefaults[] actionDefaults ) {

        for (QuickAction.QuickActionDefaults actionDefault : actionDefaults) {

            System.debug(actionDefault);

            if ( actionDefault instanceof QuickAction.SendEmailQuickActionDefaults ) {

                if ( actionDefault.getTargetSObject().getSObjectType() == EmailMessage.sObjectType ) {

                    QuickAction.SendEmailQuickActionDefaults sendEmailDefaults = (QuickAction.SendEmailQuickActionDefaults) actionDefault;

                    EmailMessage emailMessage = (EmailMessage) sendEmailDefaults.getTargetSObject();

                    // TODO update values on EmailMessage or call methods on sendEmailDefaults object

                    ID templateId = getTemplateId( 'Test_Template1 );

                    if ( String.isNotBlank( templateId ) ) {
                        sendEmailDefaults.setTemplateId( templateId );
                        sendEmailDefaults.setInsertTemplateBody( true ); // apply template above original email content
                        sendEmailDefaults.setIgnoreTemplateSubject( false ); // overwrite subject, use template subject
                    }
                }
            }
        }

    }

    private ID getTemplateId( String templateName ) {

        ID templateId = null;

        List<EmailTemplate> templates = new List<EmailTemplate>([SELECT id FROM EmailTemplate WHERE developerName = :templateName LIMIT 1
        ]);
        if ( templates.size() > 0 ) {
            templateId = templates[0].id;
        } else {
            System.debug( LoggingLevel.ERROR, 'Unable to locate email template using name "' + templateName + '"' );
        }
        return templateId;
    }

}

I am struggeling to get the test class to work. So far I have the following test class but I don't know how to configure it properly:
 
@isTest
private class IS24_CaseEmailDefaultTest{
        Static testMethod void onInitDefaults() {
        
        Case newCase = new Case();
        newCase.Subject = 'Test Case';
        newCase.Description = 'Test Case';    
        newCase.Type = 'CARE';
        insert newCase;
            
        QuickAction.SendEmailQuickActionDefaults sendEmailDefaults = 
		Test.newSendEmailQuickActionDefaults(newCase.Id, null);
    	Test.startTest();
        IS24_CaseEmailDefault cntl = new IS24_CaseEmailDefault();
        sendEmailDefaults.setTemplateId('Test_Template1');  
        //cntl.onInitDefaults(templateId);
    	Test.stopTest();
    	EmailMessage emailMessage = (EmailMessage) sendEmailDefaults.getTargetSObject();
    	System.assertNotEquals(null, emailMessage);
         
    }
}

Any help on how to get the right test class with the required coverage would be quite helpful. Thanks for your help!
Hi Community,

I am trying to customize the header size for my embedded service (Live Chat) deployment. I can insert the URL of an image but I don't know how to get the right size for the svg (prechat header, live chat header and so on).

So far I uploaded my chat header as static resource and I can also call the url, but I don't know how to get the right size of the svg.

It is also pssoible to call the header url programmatically like this:

"embedded_svc.settings.prechatBackgroundImgURL ='https://myDomain.visualforce.com/resource/1585827929000/CEmbeddedServiceLiveChatPreChatHeader?';"

How can I get the right size if I call the svg via static resource? It is required to call the url it seems, therfore its a bit tricky.

I hope some experts can help me!
Hello folks,

I would like to use a custom header for my flow screens but I have an issue in declaring the "icon-name" attribute of the "lightning-icon"-tag via flow. Here is my code:
<template>
    <div class="slds-m-top_medium slds-m-bottom_x-large">
        <h2 class="slds-text-heading_medium slds-m-bottom_medium">
            {header}
        </h2>

        <!-- With an icon -->
        <div class="slds-p-around_medium lgc-bg">
            <lightning-tile label="Lightning component team" type="media">
                <lightning-icon slot="media" icon-name={tileIcon}></lightning-icon>
                <p class="slds-truncate" title="7 Members">{subTitle}</p>
            </lightning-tile>
        </div>
    </div>
</template>
import { LightningElement, api, track} from 'lwc';

export default class lwcTileHeaderFlowScreen extends LightningElement {

@api header;
@api subTitle; 
@api tileIcon;

}
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>47.0</apiVersion>
    <isExposed>true</isExposed>

    <!-- Description -->
    <masterLabel>Custom Tile Header</masterLabel>
    <description>Custom Tile component for flow screens</description>

    <!-- Component Availability -->
    <targets>
        <target>lightning__FlowScreen</target>
    </targets>

    <!-- Configuring the design attributes -->
    <targetConfigs>
        <targetConfig targets="lightning__FlowScreen">
            <property   name="header" type="String" label="Header" description="Header text of tile"/>
            <property   name="subTitle" type="String" label="Sub Title" description="Sub title under header"/>
            <property   name="tileIcon" type="String" label="Tile Icon" description="Icon of the tile" default="standard:groups"/>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>
User-added image

The flow user should be able to insert a custom icon name as input variable but the debugger is not showing the icon.

It only works if I hard code the variable with @track tileIcon = 'standard:groups'.

I played around with get and set withou success. Any hints would be appreciated.
Hello folks,

i am not very experienced with coding, but I just want to create a very simple record creation functionality with the event "e.force:createRecord".
I have the following plan:

I want to create a button on the task layout to create a new task record that is partly based on the present task.
Its basically a follow up task were I just want to take over some field values like whoid and whatid to
save some time for users. If users click the button a record creation window is opening with some default values that
can be changed if needed.

Here is my code:
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId"
                access="global">
    
	<aura:attribute name="record" type="Object"/>
	<aura:attribute name="simpleRecord" type="Object"/>
	<aura:attribute name="recordError" type="String"/>
    
    <aura:attribute name="taskfields" type="Object"/>
    
    <force:recordData aura:id="recordLoader"
        recordId="{!v.recordId}"
        targetRecord="{!v.record}"
        layoutType="FULL"
        targetFields="{!v.simpleRecord}"
        targetError="{!v.recordError}"
        fields="Id, Name, WhoId, Description, WhatId"
        />
    
    <lightning:button label="Erstelle Folgeaufgabe" variant="brand" onclick="{!c.createFollowUpTask}"/>
    
</aura:component>
 
({
 createFollowUpTask: function (component) {
        var createRecordEvent = $A.get('e.force:createRecord');
     	var recordId = component.get("v.recordId");
     	var simpleRecord = component.get("v.simpleRecord");
        if ( createRecordEvent ) {
            createRecordEvent.setParams({
                'entityApiName': 'Task',
                'defaultFieldValues': {
                    'Subject' : 'tasksubject',
                	'WhoId' : simpleRecord.WhoId,
                }
            });
            createRecordEvent.fire();
        } else {
            /* Create Record Event is not supported */
            alert("Task creation not supported");
        }
    }
})

Now I have two problems:

- I get error messages if the who or whatid is not populated
- I sometimes get the same error messages​​​​​​ even if the who and whatid is populted
- I actually want to open the component with a quick action button instead of a lightning button (lightning:button and onclick), but I just get a "window in window"

User-added image

Quick Action Error - window in window

Can someone help me please with that probably simple issue? Thanks a lot in advance!
Hi Community,

I am trying to customize the header size for my embedded service (Live Chat) deployment. I can insert the URL of an image but I don't know how to get the right size for the svg (prechat header, live chat header and so on).

So far I uploaded my chat header as static resource and I can also call the url, but I don't know how to get the right size of the svg.

It is also pssoible to call the header url programmatically like this:

"embedded_svc.settings.prechatBackgroundImgURL ='https://myDomain.visualforce.com/resource/1585827929000/CEmbeddedServiceLiveChatPreChatHeader?';"

How can I get the right size if I call the svg via static resource? It is required to call the url it seems, therfore its a bit tricky.

I hope some experts can help me!
Hello folks,

I would like to use a custom header for my flow screens but I have an issue in declaring the "icon-name" attribute of the "lightning-icon"-tag via flow. Here is my code:
<template>
    <div class="slds-m-top_medium slds-m-bottom_x-large">
        <h2 class="slds-text-heading_medium slds-m-bottom_medium">
            {header}
        </h2>

        <!-- With an icon -->
        <div class="slds-p-around_medium lgc-bg">
            <lightning-tile label="Lightning component team" type="media">
                <lightning-icon slot="media" icon-name={tileIcon}></lightning-icon>
                <p class="slds-truncate" title="7 Members">{subTitle}</p>
            </lightning-tile>
        </div>
    </div>
</template>
import { LightningElement, api, track} from 'lwc';

export default class lwcTileHeaderFlowScreen extends LightningElement {

@api header;
@api subTitle; 
@api tileIcon;

}
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>47.0</apiVersion>
    <isExposed>true</isExposed>

    <!-- Description -->
    <masterLabel>Custom Tile Header</masterLabel>
    <description>Custom Tile component for flow screens</description>

    <!-- Component Availability -->
    <targets>
        <target>lightning__FlowScreen</target>
    </targets>

    <!-- Configuring the design attributes -->
    <targetConfigs>
        <targetConfig targets="lightning__FlowScreen">
            <property   name="header" type="String" label="Header" description="Header text of tile"/>
            <property   name="subTitle" type="String" label="Sub Title" description="Sub title under header"/>
            <property   name="tileIcon" type="String" label="Tile Icon" description="Icon of the tile" default="standard:groups"/>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>
User-added image

The flow user should be able to insert a custom icon name as input variable but the debugger is not showing the icon.

It only works if I hard code the variable with @track tileIcon = 'standard:groups'.

I played around with get and set withou success. Any hints would be appreciated.

I am on the Test Web Chat section of the Add Your Branding to Snap-In and cannot get the chat to work. It shows whether I am online or offline, but when I click "Chat with an Expert" it goes to Loading and then nothing.

I've made sure Visualforce.com is whitelisted. I've recreated the process several times, but this is where I get stuck every time.
User-added imageUser-added imageUser-added image

Here is my Code: 

<apex:page standardStylesheets="false" sidebar="false" showHeader="false"> <style type='text/css'> .embeddedServiceHelpButton .helpButton .uiButton { background-color: #565656; font-family: "Salesforce Sans", sans-serif; } .embeddedServiceHelpButton .helpButton .uiButton:focus { outline: 1px solid #565656; } @font-face { font-family: 'Salesforce Sans'; src: url('https://www.sfdcstatic.com/system/shared/common/assets/fonts/SalesforceSans/SalesforceSans-Regular.woff') format('woff'), url('https://www.sfdcstatic.com/system/shared/common/assets/fonts/SalesforceSans/SalesforceSans-Regular.ttf') format('truetype'); } </style> <script type='text/javascript' src='https://service.force.com/embeddedservice/5.0/esw.min.js'></script> <script type='text/javascript'> var initESW = function(gslbBaseURL) { embedded_svc.settings.displayHelpButton = true; //Or false embedded_svc.settings.language = ''; //For example, enter 'en' or 'en-US' //embedded_svc.settings.defaultMinimizedText = '...'; //(Defaults to Chat with an Expert) //embedded_svc.settings.disabledMinimizedText = '...'; //(Defaults to Agent Offline) //embedded_svc.settings.loadingText = ''; //(Defaults to Loading) //embedded_svc.settings.storageDomain = 'yourdomain.com'; //(Sets the domain for your deployment so that visitors can navigate subdomains during a chat session) // Settings for Live Agent //embedded_svc.settings.directToButtonRouting = function(prechatFormData) { // Dynamically changes the button ID based on what the visitor enters in the pre-chat form. // Returns a valid button ID. //}; //embedded_svc.settings.prepopulatedPrechatFields = {}; //Sets the auto-population of pre-chat form fields //embedded_svc.settings.fallbackRouting = []; //An array of button IDs, user IDs, or userId_buttonId //embedded_svc.settings.offlineSupportMinimizedText = '...'; //(Defaults to Contact Us) embedded_svc.settings.enabledFeatures = ['LiveAgent']; embedded_svc.settings.entryFeature = 'LiveAgent'; embedded_svc.init( 'https://playful-panda-wge3na-dev-ed.my.salesforce.com', 'https://abchat-developer-edition.na91.force.com/liveAgentSetupFlow', gslbBaseURL, '00D2E000000mVht', 'Chat_Agents', { baseLiveAgentContentURL: 'https://c.la1-c2-ia2.salesforceliveagent.com/content', deploymentId: '5722E0000004d22', buttonId: '5732E0000004dXK', baseLiveAgentURL: 'https://d.la1-c2-ia2.salesforceliveagent.com/chat', eswLiveAgentDevName: 'Chat_Agents', isOfflineSupportEnabled: false } ); }; if (!window.embedded_svc) { var s = document.createElement('script'); s.setAttribute('src', 'https://playful-panda-wge3na-dev-ed.my.salesforce.com/embeddedservice/5.0/esw.min.js'); s.onload = function() { initESW(null); }; document.body.appendChild(s); } else { initESW('https://service.force.com'); } </script> </apex:page>

Hello folks,

i am not very experienced with coding, but I just want to create a very simple record creation functionality with the event "e.force:createRecord".
I have the following plan:

I want to create a button on the task layout to create a new task record that is partly based on the present task.
Its basically a follow up task were I just want to take over some field values like whoid and whatid to
save some time for users. If users click the button a record creation window is opening with some default values that
can be changed if needed.

Here is my code:
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId"
                access="global">
    
	<aura:attribute name="record" type="Object"/>
	<aura:attribute name="simpleRecord" type="Object"/>
	<aura:attribute name="recordError" type="String"/>
    
    <aura:attribute name="taskfields" type="Object"/>
    
    <force:recordData aura:id="recordLoader"
        recordId="{!v.recordId}"
        targetRecord="{!v.record}"
        layoutType="FULL"
        targetFields="{!v.simpleRecord}"
        targetError="{!v.recordError}"
        fields="Id, Name, WhoId, Description, WhatId"
        />
    
    <lightning:button label="Erstelle Folgeaufgabe" variant="brand" onclick="{!c.createFollowUpTask}"/>
    
</aura:component>
 
({
 createFollowUpTask: function (component) {
        var createRecordEvent = $A.get('e.force:createRecord');
     	var recordId = component.get("v.recordId");
     	var simpleRecord = component.get("v.simpleRecord");
        if ( createRecordEvent ) {
            createRecordEvent.setParams({
                'entityApiName': 'Task',
                'defaultFieldValues': {
                    'Subject' : 'tasksubject',
                	'WhoId' : simpleRecord.WhoId,
                }
            });
            createRecordEvent.fire();
        } else {
            /* Create Record Event is not supported */
            alert("Task creation not supported");
        }
    }
})

Now I have two problems:

- I get error messages if the who or whatid is not populated
- I sometimes get the same error messages​​​​​​ even if the who and whatid is populted
- I actually want to open the component with a quick action button instead of a lightning button (lightning:button and onclick), but I just get a "window in window"

User-added image

Quick Action Error - window in window

Can someone help me please with that probably simple issue? Thanks a lot in advance!