• cyberdynebot
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 2
    Replies
I'm trying to use a Flow to create a completed Task when a Salesforce Engage Email is sent on an Opportunity. I see some Engage options in the list of objects available for the Flow but none can obtain the Id of the object for placing on the Task's WhatId. Can this be done using Flow or Apex?
I have a String value from a Long Text field that contains Name/Email values. I need to extract only the names separated by a semi colon when there are multiple entries (no semi colon in the text if only one name) using Apex/String methods into another variable. Essentially strip out anything that begins with the pipe delimiter ' | ' and ends with '.com' (will always end in '.com').

Single value scenario: 
John Test | jtest@none.com

Expected:
John Test

Multiple values:
Scott Rogers | srogers@none.com; Mike Smith | msmith@none.com; Matt White | mwhite@none.com

Expected:
Scott Rogers; Mike Smith; Matt White

I've tried using substring/left/right but my approach may not be correct as I'm getting a null value each time and I also believe I need an array/list to grab each entry if multiple matches.

Example of test:
s1 = 'Scott Rogers | srogers@none.com; Mike Smith | msmith@none.com; Matt White | mwhite@none.com';

String s2 = s1.right(1).substringBetween(' |','.com');
I'd like to add SLDS padding for a minimum width value of an input field. Have the padding set in my code, I just need it to only display when the width of the screen is larger than 760px

Cmp
<div class="minimumWidth">
      <lightning:input class=" slds-size_1-of-1 slds-medium-size--1-of-2 slds-large-size--1-of-2 "
       name="field1" label="field1" required="true" aura:id="field1" />
</div>

Css
.THIS .minimumWidth .slds-p-left_medium{min-width:760px;}

 
I have a Canvas app that is connected to an external system. A User will use the external app to request a record is created that can take several minutes. I'd like to be able to have the external system notify the user using Salesforce's notifications (bell icon alert or a banner) when the process is done. 

What is the best approach to accomplish using Apex or a declarative tool?
I'm trying to create a Lightning component that uses a button to make an API call. The response is in Content Disposition form that returns an Excel file. I'd like to be able to have the Excel file begin downloading automatically to a User's local machine when the User clicks the button.

Not sure how to handle the Http Response to pass to the Lightning component to initiate the download. Any help is appreciated.

Lightning Component
<aura:component controller="ExcelHandler " implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:appHostable" access="global">

    <aura:attribute name="recordId" type="String"/>
    <aura:attribute name="workbookOption" type="String"/>
    <aura:attribute name="downloadLink" type="String"/>
 
    <lightning:card title="Workbook Download">    
            <p class="slds-p-horizontal_large">
                <lightning:select name="selectItem" label="Select a Template" value="{!v.workbookOption}">
                    <option value="">None</option>
                    <option value="Option1">Agency Screening Workbook</option>
                    <option value="Option2">Fannie Mae</option>
 
                </lightning:select>
                <lightning:button variant="brand" label="Create" onclick="{!c.callOutCtrl}" />
                
            </p>      
    </lightning:card>
</aura:component>

Javascript Controller

({
    callOutCtrl : function(component, event, helper) {
        var action = component.get("c.getFile");
        action.setParams({
                strOppId : component.get("v.recordId"),
                workbookOption : component.get("v.workbookOption")
        });
        action.setCallback(this, function(response){
            //Need to get returned Excel file from the Controller after making API call
        });
        
        $A.enqueueAction(action);
    }
})

Apex Controller

public class ExcelHandler {  
    
    @AuraEnabled
    public static void getFile(String strOppId, String workbookOption) {
    
        HttpRequest request = new HttpRequest();
        //Make API call

        //Found this online (https://developer.salesforce.com/forums#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F0000000AY1qIAG)
        String base64value = EncodingUtil.base64Encode(response.getBodyasBlob());

        //Need to download Excel file on the Lightning Component
    }
}
 
Fairly new to Apex and I have a trigger that checks if a Task is on a Contact and pulls in 2 fields from the Contact record that will update the Task. 

It works fine for one record at a time but when trying to bulk if there are multiple tasks for the same Contact it will only fire for the last Activity in the Trigger.new list and not all that share the same WhoId.

Looks like the Map is only capturing the Contact Id once and then the SOQL query only returns one result. Just need help figuring out the solution so that each Task will get updated with the Contact fields.
 
trigger TaskTrigger on Task (before insert, before update) {

    Map<Id, List<Task>> conIdsMap = new Map<Id, List<Task>>();

    for (Task t : Trigger.new) {
            //Search for Contact on Task
        if (t.whoid != null && t.whoid.getsObjectType().getDescribe().getName() == 'Contact') {
                    List<Task> temp = new List<Task>();
                    temp.add(t);
                    conIdsMap.put(t.whoid, temp);
        }
    }

    if (conIdsMap.size() > 0) {
            for(Contact con : [Select Id, Name, Status__c, Corp_Lead_Score__c from Contact where Id in :conIdsMap.keySet()]) {
                for(Task t :conIdsMap.get(con.Id)){
                    t.Stage__c = con.Status__c;
                    t.Corp_Lead_Score__c = con.Corp_Lead_Score__c;
                }
            }  
        }
}

 
Fairly new to Apex and I have a trigger that checks if a Task is on a Contact and pulls in 2 fields from the Contact record that will update the Task. 

It works fine for one record at a time but when trying to bulk if there are multiple tasks for the same Contact it will only fire for the last Activity in the Trigger.new list and not all that share the same WhoId.

Looks like the Map is only capturing the Contact Id once and then the SOQL query only returns one result. Just need help figuring out the solution so that each Task will get updated with the Contact fields.
 
trigger TaskTrigger on Task (before insert, before update) {

    Map<Id, List<Task>> conIdsMap = new Map<Id, List<Task>>();

    for (Task t : Trigger.new) {
            //Search for Contact on Task
        if (t.whoid != null && t.whoid.getsObjectType().getDescribe().getName() == 'Contact') {
                    List<Task> temp = new List<Task>();
                    temp.add(t);
                    conIdsMap.put(t.whoid, temp);
        }
    }

    if (conIdsMap.size() > 0) {
            for(Contact con : [Select Id, Name, Status__c, Corp_Lead_Score__c from Contact where Id in :conIdsMap.keySet()]) {
                for(Task t :conIdsMap.get(con.Id)){
                    t.Stage__c = con.Status__c;
                    t.Corp_Lead_Score__c = con.Corp_Lead_Score__c;
                }
            }  
        }
}

 
I'd like to add SLDS padding for a minimum width value of an input field. Have the padding set in my code, I just need it to only display when the width of the screen is larger than 760px

Cmp
<div class="minimumWidth">
      <lightning:input class=" slds-size_1-of-1 slds-medium-size--1-of-2 slds-large-size--1-of-2 "
       name="field1" label="field1" required="true" aura:id="field1" />
</div>

Css
.THIS .minimumWidth .slds-p-left_medium{min-width:760px;}

 
Fairly new to Apex and I have a trigger that checks if a Task is on a Contact and pulls in 2 fields from the Contact record that will update the Task. 

It works fine for one record at a time but when trying to bulk if there are multiple tasks for the same Contact it will only fire for the last Activity in the Trigger.new list and not all that share the same WhoId.

Looks like the Map is only capturing the Contact Id once and then the SOQL query only returns one result. Just need help figuring out the solution so that each Task will get updated with the Contact fields.
 
trigger TaskTrigger on Task (before insert, before update) {

    Map<Id, List<Task>> conIdsMap = new Map<Id, List<Task>>();

    for (Task t : Trigger.new) {
            //Search for Contact on Task
        if (t.whoid != null && t.whoid.getsObjectType().getDescribe().getName() == 'Contact') {
                    List<Task> temp = new List<Task>();
                    temp.add(t);
                    conIdsMap.put(t.whoid, temp);
        }
    }

    if (conIdsMap.size() > 0) {
            for(Contact con : [Select Id, Name, Status__c, Corp_Lead_Score__c from Contact where Id in :conIdsMap.keySet()]) {
                for(Task t :conIdsMap.get(con.Id)){
                    t.Stage__c = con.Status__c;
                    t.Corp_Lead_Score__c = con.Corp_Lead_Score__c;
                }
            }  
        }
}