• ScottB3
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 6
    Replies
Salesforce has a Matched Leads Component that can be placed on an account to show which leads match the account.

The problem is that the layout is not conducive to the work that my company needs to do and I need to create a custom component which uses the same matching logic but displays in a more traditional table format.

I cannot find any documentation on where to start on how to utilize the matching rules engine in Apex code to get a list of leads that I can then manipulate into our needed format.

User-added image
I have a set of leads for which I need to find the most recent campaign that they are a member of.

Since there may be more than 100 leads in the set, I am trying to write a single SOQL query that will return only the CampaignMember Id with the most recent CreatedDate for each lead, rather than put a query inside of a for-loop

I need something along the lines of this, but with the actual ID of the CampaignMember object instead of the count.
 
SELECT count(Id), LeadID, max(CreatedDate) FROM CampaignMember WHERE LeadID IN :setOfLeads GROUP BY LeadID

 
I am working with Lightning Web Components and have implemented the use of lightning-datatables in many places in the app which I am developing.
The requirements have just changed and I now need to change some of my fields to rich text.  As far as I can figure out, there is no way to do this.
I see in the documentation that there is the idea of Creating Custom Data Types, but can't figure it out.

Does anyone know how I can incorporate a rich text field in a lightning-datatable?  
 
I have a component that is calling a controller method which then returns a Map of object Ids and the object name back to the component.

The Map is successfully created in the controller as I can see the values in the debug logs.
However, when I call response.getReturnValue(), it just says that the value is [object Object] and I can't do anything with it.  I see no values, the response.getReturnValue().length is 0.

If I return a string instead of a map, it works as would be expected.

Component
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" 
                access="global" 
                controller="WFS_ObjectsIFollowController"
                >
    
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="targetFields" type="Object"/>
    <aura:attribute name="recordError" type="String"/>
    <aura:attribute name="followedObjectsCount" type="Integer" default="0"/>
    <aura:attribute name="parentObjects" type="Map"/>    
    
    <force:recordData aura:id="recordLoader"
                      recordId="{!v.recordId}" 
                      layoutType="FULL"
                      targetFields="{!v.targetFields}"
                      targetError="{!v.recordError}"
                      recordUpdated="{!c.recordUpdated}"
                      fields="Id"                  
                      mode="VIEW"/>   
    
    <article class="slds-card ">
            
            <div class="slds-card__body slds-card__body_inner">

                <aura:if isTrue="true">
                    <div class="slds-region_narrow">
                        Size = {! v.followedObjectsCount }
                </aura:if>
            </div>
        </div>
    </article>
</aura:component>

Controller
({
    recordUpdated : function(component, event, helper) {
        var changeType = event.getParams().changeType;
        
        if (changeType === "ERROR") { /* handle error; do this first! */ console.log("Error: ");}
    	else if (changeType === "LOADED") { /* handle record load */ 
            console.log("*** In the controller");
            helper.getData(component, event, changeType)
    	}
    	else if (changeType === "REMOVED") { /* handle record removal */ console.log("Removed: ");}
    	else if (changeType === "CHANGED") { /* handle record change */ 
            helper.getData(component, event, changeType)
        }

	}
})

Helper
({
    getData : function(component, event, cType) {
        
        console.log("In the WFS_Objects_I_FollowHelper.js function");
        
        var action = component.get('c.getObjectsIFollow');
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === "SUCCESS"){
                alert(response.getReturnValue());
                component.set('v.parentObjects', response.getReturnValue());
                component.set('v.followedObjectsCount', response.getReturnValue().length);
                console.log("Objects Returned: " + response.getReturnValue().length);
            }else {
                console.log("RESPONSE FAILURE");
            }
        });
        $A.enqueueAction(action);        
    }
})
Apex Controller
public class WFS_ObjectsIFollowController {
    @AuraEnabled
    public static Map<String, String> getObjectsIFollow(){
	
        List<Case> followedCases;
        
        Map<String, String> parentObjects = new Map<String, String>();
        String userId = UserInfo.getUserId();
        String soql = 'SELECT Id, Subject FROM Case WHERE Id IN (SELECT ParentId FROM EntitySubscription WHERE SubscriberId = :userId)';
        followedCases = Database.query( soql );
                
        for ( Case parent : followedCases ){
            String parentId = parent.Id;
            String caseSubject = parent.Subject;
            parentObjects.put(parentId, caseSubject);
            System.debug('*** OBJECTS I FOLLOW - ' + parentId + ' - ' + caseSubject);
        }
        System.debug('Parent Objects --- ' + parentObjects);
        //THIS LINE PRINTS WITH THE CORRECT INFO

        return parentObjects;
    }
}