• sumit d
  • SMARTIE
  • 615 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 318
    Questions
  • 291
    Replies
Hi All, 
          I am getting this error in Class: LeadTrigger: execution of AfterInsert caused by: System.ListException: Duplicate id in list: 00Q8I000006zCO1UAM Class.LeadTriggerHelper.markPrimary: line 168, column 1 Trigger.LeadTrigger: line 14, column 1
My class is given below:- 

public class LeadTriggerHelper {
    
    public static List<Lead> newLeads = new List<Lead>();
    public static List<Lead> oldLeads = new List<Lead>();
    public static Map<Id, Lead> newMapLeads = new Map<Id, Lead>();
    public static Map<Id, Lead> oldMapLeads = new Map<Id, Lead>();
    public static Boolean runTrigger = true;
    private static Map<String, Schema.SObjectField> leadFieldsMap = Lead.SObjectType.getDescribe().fields.getMap();
    
    
    public static void markPrimary(){
        
        Map<String, List<Lead>> mapKeyToAssociatedLeads = new Map<String, List<Lead>>();
    List<String> fields = getFieldsString(); 
    List<Lead> applicableLeads = (Lead[]) Database.query('SELECT ' + String.join(fields, ',') +
                                                        ' FROM Lead WHERE Id IN :newLeads');

    Set<String> leadEmails = new Set<String>();
    Set<String> nameAndPhoneKeys = new Set<String>();
    Set<String> phones = new Set<String>();
    Set<String> names = new Set<String>();

    List<Lead> leadsToUpdate = new List<Lead>();
    for (Lead leadObj : applicableLeads) {
        if (leadObj.Email != null) {
            leadEmails.add(leadObj.Email);
        }
        names.add(leadObj.Name);
        phones.add(leadObj.Phone);
        nameAndPhoneKeys.add(leadObj.Name + leadObj.Phone);
    }

    String leadQuery = 'SELECT ' + String.join(fields, ',') +
                       ' FROM Lead WHERE (Email IN :leadEmails OR (Name IN :names AND Phone IN :phones))' +
                       ' AND Id NOT IN :applicableLeads AND IsConverted = False AND Lead_Type__c != \'Primary Converted\'' +
                       ' ORDER BY CreatedDate ASC';

    String personAccountQuery = 'SELECT Id, PersonEmail, PersonMobilePhone, Full_Name__pc ' +
                                ' FROM Account WHERE (PersonEmail IN :leadEmails OR ' +
                                ' (Full_Name__pc IN :names AND PersonMobilePhone IN :phones))';
        
        System.debug('personAccountQuery'+personAccountQuery);

    List<SObject> combinedResults = new List<SObject>();
    combinedResults.addAll(Database.query(leadQuery));
    combinedResults.addAll(Database.query(personAccountQuery));
        System.debug('combinedResults'+combinedResults);

    for (SObject existingRecord : combinedResults) {
        if (existingRecord.getSObjectType() == Lead.SObjectType) {
            Lead existingLead = (Lead) existingRecord;

            if (leadEmails.contains(existingLead.Email)) {
                if(mapKeyToAssociatedLeads.containsKey(existingLead.Email)) {
                List<Lead> associatedLeads = mapKeyToAssociatedLeads.get(existingLead.Email);
                associatedLeads.add(existingLead);
                mapKeyToAssociatedLeads.put(existingLead.Email, associatedLeads);
            }  
            else {
                mapKeyToAssociatedLeads.put(existingLead.Email, new List<Lead> {existingLead});
            }
            }

            if (nameAndPhoneKeys.contains(existingLead.Name + existingLead.Phone)) {
                if(mapKeyToAssociatedLeads.containsKey(existingLead.Name+existingLead.Phone)) {
                List<Lead> associatedLeads = mapKeyToAssociatedLeads.get(existingLead.Name+existingLead.Phone);
                associatedLeads.add(existingLead);
                mapKeyToAssociatedLeads.put(existingLead.Name+existingLead.Phone, associatedLeads);
            }  
            else {
                mapKeyToAssociatedLeads.put(existingLead.Name + existingLead.Phone, new List<Lead> {existingLead});
            }
            }

            // Check if it's a matching person account
         } else if (existingRecord.getSObjectType() == Account.SObjectType) {
             Account matchingPersonAccount = (Account) existingRecord;
               System.debug('matchingPersonAccount'+matchingPersonAccount);
            
         String personAccountKey = matchingPersonAccount.PersonEmail != null ? matchingPersonAccount.PersonEmail : (matchingPersonAccount.Full_Name__pc + matchingPersonAccount.PersonMobilePhone);
        if (!mapKeyToAssociatedLeads.containsKey(personAccountKey)) {
            mapKeyToAssociatedLeads.put(personAccountKey, new List<Lead>());
        }
             System.debug('mapKeyToAssociatedLeads'+mapKeyToAssociatedLeads);

        for (Lead leadObj : applicableLeads) {
            if (leadObj.Email != null && leadObj.Email == matchingPersonAccount.PersonEmail) {
                mapKeyToAssociatedLeads.get(personAccountKey).add(leadObj);
                
            } else if (leadObj.Name != null && leadObj.Phone != null && (leadObj.Name + leadObj.Phone) == (matchingPersonAccount.Full_Name__pc + matchingPersonAccount.PersonMobilePhone)) {
                mapKeyToAssociatedLeads.get(personAccountKey).add(leadObj);
            }
        }
            
            System.debug('mapKeyToAssociatedLeads Line 94'+mapKeyToAssociatedLeads);
            
             for (Lead leadObj : applicableLeads) {
                System.debug('mapKeyToAssociatedLeads'+mapKeyToAssociatedLeads);
                if (mapKeyToAssociatedLeads.containsKey(leadObj.Email) && mapKeyToAssociatedLeads.get(leadObj.Email).contains(leadObj)) {
                    leadObj.Person_Account__c = matchingPersonAccount.Id;
                    System.debug('leadObj.Person_Account__c'+leadObj.Person_Account__c);
                } else if (mapKeyToAssociatedLeads.containsKey(leadObj.Name + leadObj.Phone) && mapKeyToAssociatedLeads.get(leadObj.Name + leadObj.Phone).contains(leadObj)) {
                    leadObj.Person_Account__c = matchingPersonAccount.Id;
                    System.debug('leadObj.Person_Account__c'+leadObj.Person_Account__c);
                }
            }
        }
    }
        
        List<Lead> associatedLeads = new List<Lead>();
        Map<Id, Lead> mapNewLeadToAssociatedLead = new Map<Id, Lead>();
        for(Lead leadObj : applicableLeads){
            
            if(mapKeyToAssociatedLeads.containsKey(leadObj.Email)){
                associatedLeads = mapKeyToAssociatedLeads.get(leadObj.Email);
                mapNewLeadToAssociatedLead.put( leadObj.Id, associatedLeads.get(0) );
            }
            else if(mapKeyToAssociatedLeads.containsKey(leadObj.Name+leadObj.Phone)){
                associatedLeads = mapKeyToAssociatedLeads.get(leadObj.Name+leadObj.Phone);
                mapNewLeadToAssociatedLead.put( leadObj.Id, associatedLeads.get(0) );
            }
        }
        
        System.debug('mapNewLeadToAssociatedLead'+mapNewLeadToAssociatedLead);
        
        // loop over new inserted leads
        for(Lead leadObj : applicableLeads){
            
            Lead primaryLead;
            if( mapNewLeadToAssociatedLead.containsKey( leadObj.Id )) {
                primaryLead = mapNewLeadToAssociatedLead.get( leadObj.Id );
            }
            System.debug('primaryLead'+primaryLead);
            if( primaryLead != null ) {
                primaryLead.Lead_Type__c = 'Primary';
                // update new lead to existing type        
                leadObj.Lead_Type__c = 'Existing Lead';
                leadObj.Primary_Lead__c = primaryLead.Id;
                //leadObj.OwnerId = primaryLead.OwnerId;
                runTrigger = false;
                leadsToUpdate.add(leadObj);
                System.debug('leadsToUpdate'+leadsToUpdate);
                Schema.SObjectType leadType = leadObj.getSObjectType();
                
                for(String fieldName : leadFieldsMap.keySet()){
                    if(fieldName != 'Primary_Lead__c'){
                        if(leadFieldsMap.get(fieldName).getDescribe().isUpdateable()){
                            Object associatedLeadFieldValue = leadObj.get(fieldName);
                            Object primaryLeadFieldValue = primaryLead.get(fieldName);
                            
                            if (primaryLeadFieldValue == null && associatedLeadFieldValue != null) {
                                primaryLead.put(fieldName, associatedLeadFieldValue);
                            }    
                        }
                    }
                }
                leadsToUpdate.add(primaryLead); 
                 System.debug('primaryLead'+primaryLead);
            }
            else {
                leadObj.Lead_Type__c = 'Primary';
                leadsToUpdate.add(leadObj);
                System.debug('leadObj'+leadObj.Lead_Type__c);
            }
        }
        if(leadsToUpdate.size() > 0){
              System.debug('leadsToUpdate'+leadsToUpdate);
             update leadsToUpdate; // Getting error here
         }
    }
         }
Can anyone help me to remove this error from this class?
Hi All, 
          I have created a component in which I am getting this error:-This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read properties of undefined (reading 'config')] Failing descriptor: {force:record}

My component is given below:-

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="recordId" type="String" default="7012g00000ZoJ9aAAF"/>
    <aura:attribute name="record" type="Object"/>
    <aura:attribute name="simpleRecord" type="Object"/>
    <aura:attribute name="recordLoadError" type="String"/>
    <force:recordData aura:id="record"
    recordId="{!v.recordId}"
    fields="Name,Description,Street_Address__c,City__c,State__c,Country__c,Zip_Code__c"
    targetFields="{!v.simpleRecord}"
    targetError="{!v.recordLoadError}"
    />
     <!--aura:handler name="init" value="{!this}" action="{!c.doInit}"/-->
     
         
        <ltngMap:recordMap Name="{!v.simpleRecord.Name}"
                               Description="{!v.simpleRecord.Description}" 
                               Address="{!v.simpleRecord.Street_Address__c}" 
                               City="{!v.simpleRecord.City__c}"
                               State="{!v.simpleRecord.State__c}"
                               Country="{!v.simpleRecord.Country__c}"
                               ZipCode="{!v.simpleRecord.Zip_Code__c}"
                               />
    
</aura:component>

How to resolve this issue ?
Can anyone help me with this?
 
Hi All,
          I want to get a text variable value in another function and perform some operation and populate the value in another input variable but I ma not able to do that. 
Can anyone guide me with it ?
My LWC and Controller below:- 

<template>
    <lightning-card>
     
                <div class="c-container">
                    <lightning-layout>
                        <lightning-layout-item padding="around-small">
                            <div class="header-column">
                                <lightning-button class = "slds-p-around_large" variant="brand" onclick={addNewRow} name="Add" label="Add">
                                </lightning-button>
                            </div>
                        </lightning-layout-item>
                        <lightning-layout-item padding="around-small">
                            <div class="header-column">
                                <p class="field-title" title="Opportunity Amount">Opportunity Amount</p>
                                <p><lightning-formatted-number
                                    format-style="currency"
                                    value={amount}
                                    currency-code="USD">
                                    </lightning-formatted-number></p>
                            </div>
                        </lightning-layout-item>
                     
                    </lightning-layout>
                </div>
        <table class="slds-table slds-table_cell-buffer slds-table_bordered"
                aria-labelledby="element-with-table-label other-element-with-table-label">
                <thead>
                    <tr class="slds-line-height_reset">
                        <th class="" scope="col">
                            <div class="slds-truncate" title="Practice">Practice</div>
                        </th>
                        <th class="" scope="col">
                            <div class="slds-truncate" title="Product">Product</div>
                        </th>
                        <th class="" scope="col">
                            <div class="slds-truncate" title="Percentage">%</div>
                        </th>
                        <th class="" scope="col">
                            <div class="slds-truncate" title="Amount">$</div>
                        </th>
                        <th class="" scope="col">
                            <div class="slds-truncate" title="Support user">Support User</div>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <template for:each={listOfBookings} for:item="rec" for:index="index">
                        <tr class="slds-hint-parent" key={rec}>
                                  <td>
                                <lightning-input type="text" variant="label-hidden" label="" data-id={rec.index} name="Percentage__c" value={rec.Percentage__c} onchange={handleInputChange}></lightning-input>
                            </td>
             <td>
                                <lightning-input type="text" variant="label-hidden" label="" data-id={rec.index} name="Amount__c" value={rec.Amount__c} onchange={handleInputAmount}></lightning-input>
                            </td>
                            <td data-label="Support">
                                <c-custom-look-up obj-name="User" search-placeholder="Support"
                                    icon-name="standard:user" index={index} onlookupselected={handleLookupSelectionUser}>
                                </c-custom-look-up>
                            </td>  
                        </tr>
                    </template>
                </tbody>
            </table>
        </br>
        <lightning-layout>
            <div class="slds-align_absolute-center">
                <lightning-button variant="brand" onclick={createBookings} name="submit" label="Save">
                </lightning-button>
            </div>
        </lightning-layout>
    </lightning-card>
</template>
________________________
Controller- 
import { LightningElement, track, api, wire } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import AMOUNT_FIELD from '@salesforce/schema/Opportunity.Amount';
import insertBookings from '@salesforce/apex/PracticeBookingController.insertBookings'
const fields = [AMOUNT_FIELD];
export default class CreatePracticeBooking extends LightningElement {
    @track listOfBookings;
    @api recordId;
    @wire(getRecord, { recordId: '$recordId', fields })
    opp;
    get amount() {
        return getFieldValue(this.opp.data, AMOUNT_FIELD);
    }

    connectedCallback() {
        this.initData();
    }
    initData() {
        let listOfBookings = [];
        this.createRow(listOfBookings);
        this.listOfBookings = listOfBookings;
    }
    
    handleInputChange(event) {
        let index = event.target.dataset.id;
        let fieldName = event.target.name;
        let value = event.target.value;
        for (let i = 0; i < this.listOfBookings.length; i++) {
            if (this.listOfBookings[i].index === parseInt(index)) {
                this.listOfBookings[i][fieldName] = value;
            }
        }
        handleInputAmount(value);
    }
    handleInputAmount(val) {
          let bookingAmount = amount * (val / 100);
        console.log('bookingAmount', bookingAmount);
        for (let i = 0; i < this.listOfBookings.length; i++) {
            if (this.listOfBookings[i].index === parseInt(index)) {
                this.listOfBookings[i][fieldName] = bookingAmount;
            }
        }
    }
 
    createBookings() {
        insertBookings({
            jsonOfListOfBookings: JSON.stringify(this.listOfBookings)
        })
            .then(data => {
                this.initData();
                let event = new ShowToastEvent({
                    message: "Practice Bookings successfully created!",
                    variant: "success",
                    duration: 2000
                });
                this.dispatchEvent(event);
            })
            .catch(error => {
                console.log(error);
            });
    }
}
  • September 06, 2022
  • Like
  • 0
Hi All,
           I want to create a metric chart in LWC like below:-
User-added image
We can create line chart and bar chart in LWC using chart.js. is it possible to create metric chart also ?
or is there any other approach for it? Can anyone help me out with it?
Hi All,
I am trying to show the data only when the data is available in LWC. how can i do this ?

My Component and JS is given below:- 
<template>
    <lightning-card title='My Completed Tasks'>
      <!--template if:true={data}-->
        <div>
          <canvas class="donut" lwc:dom="manual"></canvas>
       </div>
       
      <!--template if:false={data}>
        <div class="slds-align_absolute-center slds-m-top_xx-large" style ="font-size: large;">No Data is available to show</div>
   </template-->
     
    </lightning-card>
</template>

JS File:- 
import { LightningElement, wire, track } from 'lwc';
//importing the Chart library from Static resources
import Chartjs from '@salesforce/resourceUrl/Chartjs';
import { loadScript } from 'lightning/platformResourceLoader';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
//importing the apex method.
import getAllTasksByType from '@salesforce/apex/TaskChartController.getAllTasksByType';
export default class DonutChart extends LightningElement {
    //isData = false;
    @wire(getAllTasksByType) task({ error, data }) {
        if (data) {
            console.log('get value', data)
            for (var key in data) {
                this.updateChart(data[key].count, data[key].label);
            }
            this.error = undefined;
        }
        else if (error) {
            console.log('get value', error);
            this.error = error;
            //this.task = undefined;
        }
    }
    chart;
    chartjsInitialized = false;
    config = {
        type: 'doughnut',
        data: {
            datasets: [
                {
                    data: [
                    ],
                    backgroundColor: [
                        'rgb(255,99,132)',
                        'rgb(255,159,64)',
                        'rgb(255,205,86)',
                        'rgb(75,192,192)',
                    ],
                    label: 'Dataset 1'
                }
            ],
            labels: []
        },
        options: {
            responsive: true,
            legend: {
                position: 'right'
            },
            animation: {
                animateScale: true,
                animateRotate: true
            }
        }
    };
    renderedCallback() {
        if (this.chartjsInitialized) {
            return;
        }
        this.chartjsInitialized = true;
        Promise.all([
            loadScript(this, Chartjs)
        ]).then(() => {
            const ctx = this.template.querySelector('canvas.donut')
                .getContext('2d');
            this.chart = new window.Chart(ctx, this.config);
        })
            .catch(error => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error loading ChartJS',
                        message: error.message,
                        variant: 'error',
                    }),
                );
            });
    }
    updateChart(count, label) {
        //isData = true;
        this.chart.data.labels.push(label);
        this.chart.data.datasets.forEach((dataset) => {
            dataset.data.push(count);
        });
        this.chart.update();
    }
}

Can anyone help me how to show data when data is available?

 
Hi All,
                 I have a requirement in which i want to to get the conversation entries on voice call and  find entries that include specific regular expression patterns. When an entry is found matching the pattern, use regular expression replacement to replace every number in the entry to the number sign (#).

How can i achieve this requirement?
Hi All,
             I have a requirement in which i want to give access to the contact which has a user in community I want that he can only see the project(Custom object) on which he is a member. i.e. - if he has a forecast entry on the project related to him then he can see that project in community and not able to see other project.
how can i achieve this ? with sharing rules or Apex sharing or any other method?
Hi All, 
          I have a custom link on account which shows a dynamic report when clicked. the report is showing in desktop but it does not show records in mobile. so i want to create a Component to show the report in mobile also.
   How can i achieve this? can anyone help me out?
Hi All,
   I have a requirement where i want to calculate total number of Campaign members on Campaign where lead Status = RAW.
I have created a trigger for it and its helper class is given below:- 

public class CampaignMemberTriggerHelper {
    
    public static List<CampaignMember> newCampaignMembers = new List<CampaignMember>();
    public static List<CampaignMember> oldCampaignMembers = new List<CampaignMember>();
    public static Map<Id, CampaignMember> newMapCampaignMembers = new Map<Id, CampaignMember>();
    public static Map<Id, CampaignMember> oldMapCampaignMembers = new Map<Id, CampaignMember>();
 
    public static void updateNewNetleads(){
        Set<Id> campaignsByIds = new Set<Id>();  
        Map<Id,Campaign> campaignMapToUpdate = new Map<Id,Campaign>(); 
        List<Campaign> updateCampaignList = New List<Campaign>();
        
        if(Trigger.isDelete){
            for(CampaignMember cm: oldCampaignMembers){ 
                if(cm.CampaignId != NULL){
                    campaignsByIds.add(cm.CampaignId); 
                }
            }
        }else{
            for(CampaignMember cm: newCampaignMembers){ 
                if(cm.CampaignId != NULL){
                    campaignsByIds.add(cm.CampaignId); 
                }
            }
        }
        
        if(campaignsByIds.size()>0){
            system.debug('test cam list'+campaignsByIds);
            List<AggregateResult> aggrList = new List<AggregateResult>([SELECT Count(Id)ids,CampaignId   
                                                                        FROM CampaignMember 
                                                                        WHERE CampaignId IN:campaignsByIds
                                                                        AND lead.Status ='RAW' 
                                                                        GROUP BY CampaignId]);
            if(!aggrList.isEmpty()){
                for(AggregateResult aggr:aggrList){ 
                          Campaign cmObj = new Campaign();  
                    cmObj.Net_New_Lead__c  = (Decimal)aggr.get('ids');
                        cmObj.Id = (Id)aggr.get('CampaignId');  
                    campaignMapToUpdate.put(cmObj.Id, cmObj);
                    
                }
            } 
        }
            if(campaignMapToUpdate.values().size() > 0 ){
            update campaignMapToUpdate.values();  
        }
    }
}
I have a number field on which the total number of campaign members display
Now when i change the status of lead it does not work. how can i modify it so that when i change the status of lead still it work correct. As of now only when i create or delete a campaign member it works.
How can i modify this so that when i change the status of lead it works at that time too?
 
Hi All, 
           I have a requirement in which Community Users should not see Feed Tracking Items within the community. For example, Case Owner is Feed Tracked fields. Additionally, they don't need to see any automated items - only actual case comments.
how can i hide or not show the feed tracking items to community users? 
 
Hi All,
          I want to close a popup window when i click on save. how can we do this? Can anyone help me with it?
my Component is given below:-
<template>
    <lightning-card title="Event Attendance" icon-name="custom:custom63">
        <div class="slds-m-around_medium">
            <template if:true={participation.data}>
                <lightning-datatable
                hide-checkbox-column="true"
                key-field="Id"
                data={participation.data}
                columns={columns}
                onsave={handleSave}
                  draft-values={draftValues}>
            </lightning-datatable>
            </template>
                </div>
    </lightning-card>
</template>
JS Controller:-
import { LightningElement, wire, api } from 'lwc';
import getParticipation from '@salesforce/apex/ParticipationController.getParticipation';
import { refreshApex } from '@salesforce/apex';
import { updateRecord } from 'lightning/uiRecordApi';
import updateParticipations from '@salesforce/apex/ParticipationController.updateParticipations';
import { getRecordNotifyChange } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
  const COLS = [
    {
        label: 'Participation Name',
        fieldName: 'Participation_Name__c'
    },
    { label: 'Participated?', fieldName: 'Participated__c', type: 'boolean', editable: true }
];
export default class DatatableUpdateExample extends LightningElement {
    @api recordId;
    columns = COLS;
    draftValues = [];
    @wire(getParticipation, { accId: '$recordId' })
    participation;
    async handleSave(event) {
        const updatedFields = event.detail.draftValues;
        // Prepare the record IDs for getRecordNotifyChange()
        const notifyChangeIds = updatedFields.map(row => { return { "recordId": row.Id } });
        try {
               const result = await updateParticipations({ data: updatedFields });
            console.log(JSON.stringify("Apex update result: " + result));
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Success',
                    message: 'Attendance marked',
                    variant: 'success'
                })
            );
            // Refresh LDS cache and wires
            getRecordNotifyChange(notifyChangeIds);
               refreshApex(this.participation).then(() => {
                    this.draftValues = [];
                     });
        } catch (error) {
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Error updating or refreshing records',
                    message: error.body.message,
                    variant: 'error'
                })
            );
        };
    }
}
User-added image
Hi All,
 I have created a test class which is giving me following error:-Malformed JSON: Expected '[' at the beginning of List/Set 
How to resolve it ?
My class and test class is given below:- 
public with sharing class ParticipationController {
   @AuraEnabled
public static string updateParticipations(Object data) {
    List<bre__BR_Participation__c> ParticipationsForUpdate = (List<bre__BR_Participation__c>) JSON.deserialize(
         JSON.serialize(data),
         List<bre__BR_Participation__c>.class
    );
    try {
        update ParticipationsForUpdate;
        return 'Success: Participation updated successfully';
    }
    catch (Exception e) {
        return 'The following exception has occurred: ' + e.getMessage();
    }
}
}

My test class is given below:-
@istest
public with sharing class ParticipationControllerTest {
        static testmethod void updateParticipationTest() {
        bre__BR_Event__c ev = new bre__BR_Event__c();
        ev.bre__Start_Date__c = System.today();
        insert ev;
        bre__BR_Participation__c data = new bre__BR_Participation__c();
        data.bre__BR_Event__c = ev.id;
        insert data;
        test.startTest();
        data.Participated__c = true;
        update data;
        ParticipationController.updateParticipations(data);
        test.stopTest();
    }
}
 
Hi All,
          I want to create a simple data table on account  to show its contacts in Edit view with Name and Checkbox field so that i can directly edit the checkbox and save the contacts from table itself.
I don't want to use data-table because we need to go to each record and edit it with inline editing, i want that  all the checkboxes for the checkbox field is in edit view 
How to achieve this?
Can anyone help with it? 
Hi All,
I have created a test class but its giving me error:- System.QueryException: List has no rows for assignment to SObject
Stack Trace: Class.CommEventsController.getZoneId: line 21, column 1 Class.CommEventsControllerTest.getZoneIdTest: line 10, column 1

Can someone help me with this ?

My class and test class is given below:- 
public without sharing class CommEventsController {
    @AuraEnabled(cacheable=true)
    public static String getZoneId(Id recordId) {
        
            String sobjectName;
            String zoneId;
            sobjectName = recordId.getSobjectType().getDescribe().getName();
            if(sobjectName == 'Forum__c'){
                List<Forum__c> listOfForum = New List<Forum__c>();
                listOfForum = [Select Id,Name from Forum__c where Id =: recordId];
                String forumName = listOfForum[0].Name;
                String query = 'SELECT Id, bre__Zone_Id__c FROM bre__BR_Events_Zone__c WHERE Name = :forumName';
                SObject objectRecod = Database.query(query);
                zoneId = (String)objectRecod.get('bre__Zone_Id__c');
                System.debug('zoneId'+zoneId);
            }else{
                List<CollaborationGroup> listOfChatterGroup = New List<CollaborationGroup>();
                listOfChatterGroup = [Select Id,Name from CollaborationGroup where Id =: recordId];
                String groupName = listOfChatterGroup[0].Name;
                String query = 'SELECT Id, bre__Zone_Id__c FROM bre__BR_Events_Zone__c WHERE Name =:groupName';
                SObject objectRecod = Database.query(query);

                zoneId = (String)objectRecod.get('bre__Zone_Id__c');
                System.debug('zoneId'+zoneId);
            }
            return zoneId;
            }
     }
Test class:- 
@istest
public class CommEventsControllerTest {
    public static testmethod void getZoneIdTest(){
        Forum__c f = new Forum__c();
        insert f;
        
        CollaborationGroup groupe = new CollaborationGroup(Name = 'Test 1', CollaborationType = 'Unlisted');
        insert groupe;
        Test.startTest();
        CommEventsController.getZoneId(groupe.id);
        CommEventsController.getZoneId(f.id);
        Test.stopTest();
    }
}
Hi All,
          I have an Aura component in which i have a child component i want to pass the value from Apex to this component. how can i do this?
my Aura and Apex controller is given below:-

 public class CommEventsController {
    @AuraEnabled(cacheable=true)
    public static String getZoneId() {
        Set<Id> contactIds = new Set<Id>();
        Map< Id, User> mapOfContactIdToUser = new Map<Id,User>();
        Map<Id, Forum_Members__c> mapOfForumIdToMembers = new Map<Id,Forum_Members__c>();
        
        for( User ur : [ SELECT Id, ContactId 
                        FROM User 
                        WHERE Id =: userinfo.getUserId() ] )
        {
            if( ur.ContactId != null ){
                mapOfContactIdToUser.put( ur.ContactId , ur );
            }
        }
        System.debug('mapOfContactIdToUser'+mapOfContactIdToUser);
        
        for( Forum_Members__c fm : [ SELECT Id, Member__c,Forum__c
                                    FROM Forum_Members__c 
                                    WHERE Member__c IN: mapOfContactIdToUser.KeySet() ] )
        {
            if( fm.Member__c != null ){
                mapOfForumIdToMembers.put(fm.Forum__c,fm);
            }
        }
        System.debug('mapOfForumIdToMembers'+mapOfForumIdToMembers);
        
        List<Forum__c> listOfForum = New List<Forum__c>();
        listOfForum = [Select AC_Events_Zone__c from Forum__c where Id IN: mapOfForumIdToMembers.keySet()];
        String zoneId = listOfForum.Size()>0?listOfForum[0].AC_Events_Zone__c:Null;
        System.debug('zoneId'+zoneId);
        return zoneId;
    } 
}
Aura component:- 
<aura:component controller="CommEventsController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="zoneId" type="String" />
    <bre:DatePicker zoneId="{!v.zoneId}"  />
</aura:component>
Controller:- 
({
    myAction : function(component, event, helper) {
        var action = component.get("c.getZoneId");
         
    }
})
I am getting the zoneId in Apex controller and i want to pass it to the component. how can i do it ?
Can anyone help?
Hi All,
          I have created a search component in which i want that when customer search something and after that all results should be open in new window after clicking enter key. can anyone help me with this?
My components is given below:- 

SearchComponent:-

<aura:component controller="CustomSearchController" implements="forceCommunity:searchInterface,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="searchText" type="String" default=""/>
    <aura:attribute type="list" name="recordList" />
    <aura:attribute name="Label" type="String"/>
    <aura:attribute name="required" type="Boolean" default="false"/>
     
        <div class="slds-form-element__control slds-input-has-icon slds-input-has-icon slds-input-has-icon_left-right"  role="none">
            <lightning:input required="{!v.required}" aura:id="userinput" label="{!v.Label}" name="searchText" onchange="{! c.handleClick }" value="{!v.searchText}" class="leftspace"/> 
            <span class="slds-icon_container slds-icon-utility-search slds-input__icon slds-input__icon_right iconheight">
                <lightning:icon class="slds-icon slds-icon slds-icon_small slds-icon-text-default slds-m-top_small" iconName="utility:search" size="x-small"   alternativeText="icon" />
            </span> 
        </div>
        <aura:if isTrue="{!and(v.recordList.length == 0 , v.searchText)}">
            No result found.
            <aura:set attribute="else">
                <c:customSearchResultsList recordList="{!v.recordList}"/>
            </aura:set>
        </aura:if>
</aura:component>
JSController:-
({
    handleClick : function(component, event, helper) {
      var searchText = component.get('v.searchText');
      var action = component.get('c.searchRecords');
      action.setParams({searchText: searchText});
      action.setCallback(this, function(response) {
        var state = response.getState();
          console.log('state',state);
        if (state === 'SUCCESS') {
            
          var recordList = response.getReturnValue();
            component.set('v.recordList',recordList);
            console.log('recordList',recordList);
        }
      });
      $A.enqueueAction(action);
    }
})
CustomSearchresultList:-
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global">
    <aura:attribute type="list" name="recordList" />
    <aura:if isTrue="{!v.recordList.length > 0}" >
        <h1>Search Results</h1>
        <lightning:accordion >
            <aura:iteration items="{!v.recordList}" var="id">
                <!--lightning:accordionSection name="{!id.objName}" label="{!id.objName}"-->
                <div class="slds-scrollable" style="height:10rem;">
                    <aura:iteration items="{!id.soList}" var="sOb"> 
                        <c:customSearchResultItem recordId="{!sOb.Id}" obName="{!id.objName}" title="{!sOb.Title}" fieldName="{!id.fieldName}"/>
                    </aura:iteration>
                </div>
                <!--/lightning:accordionSection-->
            </aura:iteration>
        </lightning:accordion>
    </aura:if>
</aura:component>

CustomSerchResultItem.cmp
<aura:component implements="force:hasRecordId" access="global">
    <aura:attribute name="obName" type="String" />
    <aura:attribute name="fieldName" type="String" />
    <aura:attribute name="record" type="Object"/>
    <aura:attribute name="simpleRecord" type="Object"/>
    <aura:attribute name="recordError" type="String"/>
    <aura:attribute name="pageReference" type="Object"/>
    <aura:attribute name="title" type="String"/>
    <lightning:navigation aura:id="navService"/> 
 <!-- Display a header with details about the record -->
      <!--aura:if isTrue="{!v.recordDataLoaded}"-->
         <div class="slds-page-header" role="banner">
        <tr>
            <td>
                <p class="slds-text-heading--label"><a onclick="{!c.redirectDetail}">
                    <lightning:formattedText linkify="true" value="{!v.title}" />
                    </a></p>
            </td>
                </tr>
    </div>
    <!--/aura:if--> </aura:component>
CustomSearchResultItem.Js
({
    doInit : function(component, event, helper) {
        var sobject = component.get('v.record');
        var fieldName = component.get('v.fieldName');
        var formatText = component.find('fielddata');
        console.log('----sobject-----------');
         console.log('sobject:',sobject);
        formatText.set("v.value",sobject[fieldName]);
    },
     
    /*recordUpdated : function(component, event, helper) {
        component.set('v.recordDataLoaded',true);
    },*/
    redirectDetail : function(component, event, helper) {
        //Redirect to detail page on success
        console.log(component.get("v.recordId"),component.get("v.obName"),component.find('navService'));
        var navService = component.find('navService');
        
            var pageReference = {
            type: 'standard__recordPage',
            attributes: {
                "recordId": component.get("v.recordId"),
                "objectApiName": component.get("v.obName"),
                "actionName": "view"
            }
        }
          
            navService.generateUrl(pageReference)
            .then($A.getCallback(function(url) {
                console.log('success: ' + url); //you can also set the url to an aura attribute if you wish
                window.open(url,'_blank'); //this opens your page in a seperate tab here
            }), 
                  $A.getCallback(function(error) {
                      console.log('error: ' + error);
                  }));
         //navService.navigate(pageReference);
        }
})
How can i navigate all the coming results in new tab. Can anyone help me with this?
 
Hi All,
           I have a schedulable class, I want ot call it from another class and make the second class invocable. how can i do this?
My class and invocable class is given below:-

global  class SendEmailToKnowledgeArticleFollower implements Schedulable {

    global void execute(SchedulableContext sc)
        {
            SendEmail();
        }
    public Static void SendEmail() {
        Set<Id> knowledgeArticleIdSet = new Set<Id>();
        Map<Id,Knowledge__kav> mapOfKnowledgeArticleVersion = new  Map<Id,Knowledge__kav>();
        List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
        
        EmailTemplate et = [SELECT Id,Subject, Body FROM EmailTemplate WHERE DeveloperName = 'KnowledgeArticlePublished'];
        List<Knowledge__kav> knowledgeArticlesPublishedToday =  [SELECT Id,LastPublishedDate,PublishStatus,KnowledgeArticleId,IsLatestVersion,Title  
                                                                FROM Knowledge__kav 
                                                                WHERE LastPublishedDate  = TODAY ];
        
        if (!knowledgeArticlesPublishedToday.isEmpty()) {
            
            for (Knowledge__kav kav : knowledgeArticlesPublishedToday) {
                knowledgeArticleIdSet.add(kav.KnowledgeArticleId);
                mapOfKnowledgeArticleVersion.put(kav.KnowledgeArticleId,kav);
            }

            List<EntitySubscription> knowledgeArticleFolower = [SELECT  ID, ParentId, SubscriberId,Subscriber.Name,Subscriber.Email   
                                                                FROM EntitySubscription 
                                                                WHERE ParentId 
                                                                IN :knowledgeArticleIdSet];
            if (!knowledgeArticleFolower.isEmpty()) {
                OrgWideEmailAddress orgWideAddress = [SELECT Id, Address, DisplayName 
                                                              FROM OrgWideEmailAddress 
                                                              WHERE Address='techsupport_test@on24.com' 
                                                              LIMIT 1 ];
                        
                        
                for (EntitySubscription follower : knowledgeArticleFolower) {
                    List<String> sendTo = new List<String>();
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    Messaging.SingleEmailMessage getEmailTempResponse = Messaging.renderStoredEmailTemplate(et.Id, follower.SubscriberId, mapOfKnowledgeArticleVersion.get(follower.ParentId).Id);
                    sendTo.add(follower.Subscriber.Email);
                    // Set email contents - you can use variables!
                    if ( orgWideAddress != null) {
                        mail.setOrgWideEmailAddressId( orgWideAddress.Id );
                        // mail.setSenderDisplayName(orgWideAddress.DisplayName);
                    }
                    mail.setToAddresses(sendTo);
                    mail.setSubject(getEmailTempResponse.getSubject());
                    mail.setHTMLBody(getEmailTempResponse.getHtmlBody());
                    mails.add(mail);
                }
                Messaging.sendEmail(mails);
            }
    }
    }
}

Invocable class is given below:- 
public class InvocableSendEmailToFollowers {
    @InvocableMethod
    public static void SendEmailToFollower( List<Id> articleIds ) {
     List<Knowledge__kav> knowledgeArticlesPublishedToday =  [SELECT Id,LastPublishedDate,PublishStatus,KnowledgeArticleId,IsLatestVersion,Title  
                                                                FROM Knowledge__kav 
                                                                WHERE LastPublishedDate  = TODAY AND Id IN: articleIds ];
        SendEmailToKnowledgeArticleFollower.SendEmail();
    }
        
}
here i want that when i will call a flow from button after clicking of button flow will call the invocable and do the rest thing.
Can anyone help me with this?
 
Hi All, 
   I have a class mentioned below:-
public without sharing class CreateBadgeController {
    @AuraEnabled 
    public static WorkBadge createBadge(Map<String, Object> callObject) {
     List<WorkBadgeDefinition> workBadges= [SELECT Id 
                                               FROM WorkBadgeDefinition 
                                               where Name = 'Thanks'];
        String workBadgeDefinationId= String.valueOf (workBadges.get(0).id);
        
        WorkThanks  wrkThanks  = new WorkThanks();
        wrkThanks.GiverId       = UserInfo.getUserId();
        wrkThanks.Message    = 'Thanks';
        wrkThanks.OwnerId     = UserInfo.getUserId();
        wrkThanks.how_did_person_help_you__c = String.valueOf(callObject.get('how_did_person_help_you__c'));
        wrkThanks.Describe_your_connection__c = String.valueOf(callObject.get('Describe_your_connection__c'));
        wrkThanks.How_has_this_connection_impacted_you__c = String.valueOf(callObject.get('How_has_this_connection_impacted_you__c'));
        wrkThanks.Notes__c = String.valueOf(callObject.get('Notes__c'));
        //wrkThanks.NetworkId = '0DB8c0000001peoGAA';
        wrkThanks.NetworkId = System.Label.CommunityId;
        Insert wrkThanks;
        
        WorkBadge  wrkBadge = new WorkBadge ();
        wrkBadge.DefinitionId = workBadgeDefinationId;
        //wrkBadge.RecipientId = '0058c000009g2waAAA';
        wrkBadge.RecipientId = String.valueOf(callObject.get('RecipientId'));
        wrkBadge.SourceId = wrkThanks.Id;
        wrkBadge.NetworkId =  System.Label.CommunityId;
        Insert wrkBadge;
        return wrkBadge;
    }
}
I am trying to create a test class for it which is giving me error my test class is given below:-
@istest
public class CreateBadgeControllerTest {
    Public Static testmethod void createWorkBadgeTest(){
   
        WorkThanks  wrkThanks  = new WorkThanks();
        wrkThanks.GiverId = UserInfo.getUserId();
        wrkThanks.Message = 'Thanks';
        wrkThanks.OwnerId = UserInfo.getUserId();
        wrkThanks.how_did_person_help_you__c = 'Provided me a connection';
        wrkThanks.Describe_your_connection__c =  'New Friend/ Colleague';
        wrkThanks.How_has_this_connection_impacted_you__c = 'Revenue Growth';
        wrkThanks.Notes__c =  'Thanks test';
        //wrkThanks.NetworkId = '0DB8c0000001peoGAA';
        wrkThanks.NetworkId = System.Label.CommunityId;
        Insert wrkThanks;
        WorkBadge  wrkBadge = new WorkBadge ();
        wrkBadge.DefinitionId = '0W18c000001Cm4pCAC';
        //wrkBadge.RecipientId = '0058c000009g2waAAA';
        wrkBadge.RecipientId =  userinfo.getUserId();
        wrkBadge.SourceId = wrkThanks.Id;
        wrkBadge.NetworkId =  System.Label.CommunityId;
        Insert wrkBadge;
        
        Map<String, WorkBadge> callObject = new Map<String, WorkBadge>();
        callObject.put(wrkBadge.id,wrkBadge);
           CreateBadgeController.createBadge(callObject);
        test.stopTest();
    }
}
its giving me error:- System.DmlException: Insert failed. First exception on row 0; first error: INVALID_ID_FIELD, Invalid input badge definition id.: []
Can anyone help me out how to create test class for it?
Hi All,
          I want to show users like below image. how can i do this in LWC? any suggestions?
 User-added image
Hi All,

 I have a lightning component in which i am trying to show fields value from record of custom metadata. the metadata has 4 records so i am trying to show the value of fields. I have four metadata records and i want to show the Button_Label__c field values for each record in component.
What am i missing on it?
my component is given below:- 

<aura:component controller="PortalHomeController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="buttonList" type="Button_Configuration__mdt[]"  default=""/>
    <aura:attribute name="buttons" type="List" />
         <aura:handler name="init" value="{!this}" action="{!c.fetchCodes}"/>

 <strong>{!v.buttons[0].Button_Label__c} </strong>
 <strong>{!v.buttons[1].Button_Label__c} </strong>
 <strong>{!v.buttons[2].Button_Label__c} </strong>
 <strong>{!v.buttons[3].Button_Label__c} </strong>
</aura:component>
JS Controller:-
({
    fetchCodes : function(component, event, helper) {
         component.set('v.mycolumns', [
            {label: 'Button Label', fieldName: 'Button_Label__c', type: 'text'},
                {label: 'Description', fieldName: 'Description__c', type: 'text'}
            ]);
        var action = component.get("c.getButtonMetaData");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.buttons", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    }
})
Apex controller:- 

public class PortalHomeController {
    @AuraEnabled
    public static List<Button_Configuration__mdt> getButtonMetaData(){
        List<Button_Configuration__mdt> buttonList = [Select Id, MasterLabel, Button_Label__c, Description__c 
                                                      From Button_Configuration__mdt
                                                      ORDER BY MasterLabel
                                                     ];
         //List<Button_Configuration__mdt> listButton = List<Button_Configuration__mdt>();
        Button_Configuration__mdt button1;
        Button_Configuration__mdt button2;
        Button_Configuration__mdt button3;
        Button_Configuration__mdt button4;
       
        for(Button_Configuration__mdt bt :buttonList){
            if(bt.Label =='Button 1'){
                button1 = bt;
                  
            }else 
                if(bt.Label =='Button 2'){
                button2 = bt;
                     
                }else 
                    if(bt.Label =='Button 3'){
                    button3 = bt;
                         
                    }else if(bt.Label =='Button 4'){
                       button4 = bt;  
                   }
        }
        system.debug('custCredentialList ' + buttonList);
        return buttonList;    
    }
}
 
Hi All,
          I want to show users like below image. how can i do this in LWC? any suggestions?
 User-added image
Hi All,
        I have a LWC in which i have picklist fields. I want to change the Picklist to Multiselect Picklist as the field is multiselect picklist on the activity object. How to change the picklist to multiselect picklist in LWC?
My Component is as below:- 
<template>
    <lightning-card if:true={record} title={record.name} icon-name="standard:account">
        <lightning-spinner if:true={showSpinner} variant="brand" alternative-text="Loading..."></lightning-spinner>
        <div class="slds-m-horizontal_medium">
            <!-- Account Details -->
            <div if:true={isAccount} class="slds-grid slds-wrap slds-border_bottom slds-p-bottom_small">
                <div class="slds-col slds-size_1-of-1">
                    <lightning-icon icon-name="standard:location" size="x-small"></lightning-icon>
                    <span class="slds-p-left_small">{record.account.BillingStreet}, {record.account.BillingCity}, {record.account.BillingState}</span>
                </div>
                <div class="slds-col slds-size_1-of-1">
                    <lightning-icon icon-name="standard:call" size="x-small"></lightning-icon>
                    <span class="slds-p-left_small">{record.account.Phone}</span>
                </div>
            </div>
            <!-- Physician Details -->
            <div if:true={isPhysician} class="slds-grid slds-wrap slds-border_bottom slds-p-bottom_small">
                <div class="slds-col slds-size_1-of-1">
                    <lightning-icon icon-name="standard:location" size="x-small"></lightning-icon>
                    <span class="slds-p-left_small">{record.contact.Account.BillingStreet}, {record.contact.Account.BillingCity}, {record.contact.Account.BillingState}</span>
                </div>
                <div class="slds-col slds-size_1-of-1">
                    <lightning-icon icon-name="standard:call" size="x-small"></lightning-icon>
                    <span class="slds-p-left_small">{record.contact.Phone}</span>
                </div>
            </div>
            <!-- Call Details -->
            <div class="slds-grid slds-wrap slds-gutters_small">
                <div class="slds-col slds-size_1-of-1 slds-large-size_1-of-2">
                    <lightning-input label="Date of Visit" value={newTask.Date_of_Visit__c} type="date" date-style="short" onchange={valueChanged}></lightning-input>
                </div>
                <div class="slds-col slds-size_1-of-1 slds-large-size_1-of-2">
                    <lightning-combobox label="Clinical Question Selection" options={clinicalDecisionOptions} value={newTask.Clinical_Decision__c} onchange={valueChanged}></lightning-combobox>
                </div>
                <div class="slds-col slds-size_1-of-1 slds-large-size_1-of-2">
                    <lightning-combobox label="Event" options={eventOptions} value={newTask.Event__c} onchange={valueChanged}></lightning-combobox>
                </div>
                <div class="slds-col slds-size_1-of-1 slds-large-size_1-of-2">
                    <lightning-combobox label="Competition" options={competitionOptions} value={newTask.Competition__c} onchange={valueChanged}></lightning-combobox>
                </div>
                <div if:true={isAccount} class="slds-col slds-size_1-of-1 slds-p-top_small">
                    Physicians:
               
                    <ui class="list-group">
                        <template for:each={contactList} for:item="c">
                            <li key={c.value} onclick={updateContactSelection} data-value={c.value} class={c.class}>
                                {c.label}
                            </li>
                        </template>
                    </ui>
                </div>
                <div if:true={newTask.Clinical_Decision__c} class="slds-col slds-size_1-of-1 slds-p-top_small">
                    Meeting Notes:
                   
                    <ui class="list-group">
                        <template for:each={notesOptions} for:item="opt">
                            <li key={opt.label} onclick={updateNote} data-value={opt.label} class={opt.class}>
                                {opt.label}
                            </li>
                        </template>
                    </ui>
                </div>
            </div>            
        </div>
        <div class="slds-align_absolute-center slds-p-top_small">
            <lightning-button variant="brand" label="Save" onclick={saveCall}></lightning-button>
        </div>
    </lightning-card>
</template>
Controller is as below:- 
import { LightningElement, api, track, wire } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
import { fireEvent } from 'c/pubsub';
// import getAccount from '@salesforce/apex/CustomerIntelligenceController.getAccount';
import getRecord from '@salesforce/apex/CustomerIntelligenceController.getRecord';
import saveCallDetails from '@salesforce/apex/CustomerIntelligenceController.saveCallDetails';
export default class LogCall extends LightningElement
{
    @api recordId;
    @api formFactor;
    @track isLoaded = false;
    @track showSpinner = true;
    @track record;
    @track contactList = [];
    @track newTask = {};
    @wire(CurrentPageReference) pageRef;
    renderedCallback()
    {
        if(this.isLoaded)
        {
            return;
        }
        this.isLoaded = true;
        getRecord({recordId: this.recordId})
        .then(result => {
            console.log(result);
            this.record = result;
            if(this.isAccount)
            {
                this.newTask.WhatId = this.recordId;
                this.newTask.Contacts = [];
                for(let i = 0; i < this.record.contacts.length; i++)
                {
                    this.contactList.push({label: this.record.contacts[i].Name, value: this.record.contacts[i].Id, class: 'list-group-item'});
                }
            }
            else // physician
            {
                this.newTask.WhoId = this.recordId;
            }
            if(this.record.mostRecentCall)
            {
                this.newTask.Competition__c = this.record.mostRecentCall.Competition__c;
            }
            if(this.formFactor === 'PHONE') //mobile date fields need a different default setting than desktop (because salesforce is ridiculous)
            {
                this.newTask.Date_of_Visit__c = new Date().toISOString();
            }
            else
            {
                let date = new Date();
                let dateString = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                this.newTask.Date_of_Visit__c = dateString; //default date of visit to today
            }
            this.showSpinner = false;
        })
        .catch(error => {
            console.log(error);
            this.showSpinner = false;
        });
    }
    get isAccount()
    {
        return this.record.account;
    }
    get isPhysician()
    {
        return this.record.contact;
    }
    get clinicalDecisionOptions()
    {
        return [
            {label: 'Active Surveillance', value: 'Active Surveillance'},
            {label: 'Definitive Therapy-RT', value: 'Definitive Therapy-RT'},
            {label: 'Surgery/Treatment Planning', value: 'Surgery/Treatment Planning'},
            {label: 'Post RP-RT Timing', value: 'Post RP-RT Timing'},
            {label: 'BCR', value: 'BCR'}
        ];
    }
    get eventOptions()
    {
        return [
            {label: 'Drop In', value: 'Drop In'},
            {label: 'Text', value: 'Text'},
            {label: 'Email', value: 'Email'},
            {label: 'Phone Call', value: 'Phone Call'},
            {label: 'Coffee/Snack', value: 'Coffee/Snack'},
            {label: 'Breakfast', value: 'Breakfast'},
            {label: 'Virtual Breakfast', value: 'Virtual Breakfast'},
            {label: 'Lunch', value: 'Lunch'},
            {label:'Virtual Lunch', value:'Virtual Lunch'},
            {label: 'Dinner', value: 'Dinner'},
            {label: 'Virtual Dinner', value: 'Virtual Dinner'}
        ]
    }
    get competitionOptions()
    {
        return [
            {label: 'Oncotype', value: 'Oncotype'},
            {label: 'Prolaris', value: 'Prolaris'},
            {label: 'Nomogram', value: 'Nomogram'},
            {label: 'Clinical Feature', value: 'Clinical Feature'},
        ]
    }
    get notesOptions()
    {
        var options = [];
        switch(this.newTask.Clinical_Decision__c)
        {
            case 'Active Surveillance':
                options = [
                    {label: 'Physician is focused on competition. Continue competitive messaging.', class: 'list-group-item'},
                    {label: 'Physician sees no value with genomic testing with Active Surveillance. Focus on other clinical decisions.', class: 'list-group-item'},
                    {label: 'Not utilizing genomics in this patient type yet. May require additional meetings. Continue with Active Surveillance focus.', class: 'list-group-item'},
                    {label: 'Genomic fatigue. Previous use of genomics didn\'t change treatment decision.', class: 'list-group-item'},
                    {label: 'Utilizes Decipher test for this patient type. Follow up to capture all patients and discuss other opportunities.',  class: 'list-group-item'}
                ];
                break;
            case 'Definitive Therapy-RT':
                options = [
                    {label: 'Physician sees value in de-intensifying therapy-shortening hormones based on Decipher result.', class: 'list-group-item'},
                    {label: 'Physician sees value in intensifying therapy-including/extending hormones based on Decipher result.', class: 'list-group-item'},
                    {label: 'Rad Onc/Med Onc states that the referring urologist initiates hormone decision, but might intensify/de-intensify hormones based on Decipher result.', class: 'list-group-item'},
                    {label: 'Physician supports Decipher but would like the test result before radiation therapy appointment.', class: 'list-group-item'},
                    {label: 'Physician sees no value in utilizing Decipher for hormone decisions.',  class: 'list-group-item'}
                ];
                break;
            case 'Surgery/Treatment Planning':
                options = [
                    {label: 'RP surgeon sees value with pre-surgery treatment conversation. eg. High risk Decipher patients need surgery first so RT is still an option.', class: 'list-group-item'},
                    {label: 'RP surgeon sees no value for surgery/treatment planning and would only utilize testing for AS patients or Post RP-radiation timing.', class: 'list-group-item'},
                    {label: 'RP surgeon sees value for surgical planning based on Decipher result.', class: 'list-group-item'},
                    {label: 'Physician is utilizing testing for focal therapy versus radiation or RP treatment decisions.', class: 'list-group-item'},
                    {label: 'Physician utilizes the test result to support decision for patient to come off of Active Surveillance.',  class: 'list-group-item'}
                ];
                break;
            case 'Post RP-RT Timing':
                options = [
                    {label: 'Physician believes in early radiation and uses Decipher in clinically high risk patients.', class: 'list-group-item'},
                    {label: 'Physician believes in Decipher Post-Op test but ordering logistics is main obstacle.', class: 'list-group-item'},
                    {label: 'Physician does not believe in early radiation so move to BCR/other clinical decision.', class: 'list-group-item'},
                    {label: 'Physician utilizes ultra-sensitive PSA. Focus on Decipher message to help confirm usPSA rise.', class: 'list-group-item'},
                    {label: 'Physician orders Decipher for radiation timing. Discuss other clinical decisions.', class: 'list-group-item'}
                ];
                break;
            case 'BCR':
                options = [
                    {label: 'Physician sees no value for Decipher test. Will treat with RT + ADT.', class: 'list-group-item'},
                    {label: 'Physician sees value with ordering Decipher to help with the addition of hormone therapy.', class: 'list-group-item'},
                    {label: 'Physician gave buy-in for ordering. Needs support with logistics to identify appropriate patient for testing.', class: 'list-group-item'},
                    {label: 'Physician sees value of GRID with disease progression.', class: 'list-group-item'}
                ];
                break;
            default:
                options = [];
        }  
        for(let i = 0; i < options.length; i++)
        {
            if(options[i].label === this.newTask.Notes__c)
            {
                options[i].class = options[i].class + ' selected';
            }
        }
        return options;
    }
    valueChanged(event)
    {
        var newValue = event.target.value;
        switch(event.target.label)
        {
            case 'Date of Visit':
                this.newTask.Date_of_Visit__c = newValue;
                break;
            case 'Clinical Decision':
                this.newTask.Clinical_Decision__c = newValue;
                break;
            case 'Event':
                this.newTask.Event__c = newValue;
                break;
            case 'Competition':
                this.newTask.Competition__c = newValue;
                break;
            default:
        }
    }
    updateNote(event)
    {
        this.newTask.Notes__c = event.target.dataset.value;
    }
    updateContactSelection(event)
    {
        var selectedContact = event.target.dataset.value;
        if(this.newTask.Contacts.indexOf(selectedContact) !== -1)
        {
            let updatedSelection = [];
            for(let i = 0; i < this.newTask.Contacts.length; i++)
            {
                if(this.newTask.Contacts[i] !== selectedContact)
                {
                    updatedSelection.push(this.newTask.Contacts[i]);
                }
            }
            this.newTask.Contacts = updatedSelection;
            for(let i = 0; i < this.contactList.length; i++)
            {
                if(this.contactList[i].value === selectedContact)
                {
                    this.contactList[i].class = 'list-group-item';
                }
            }
        }
        else
        {
            this.newTask.Contacts.push(selectedContact);
            for(let i = 0; i < this.contactList.length; i++)
            {
                if(this.contactList[i].value === selectedContact)
                {
                    this.contactList[i].class = this.contactList[i].class + ' selected';
                }
            }
        }
    }
    saveCall()
    {
        this.showSpinner = false;
        saveCallDetails({callObject: this.newTask})
        .then(result => {
            console.log(result);
            this.showSpinner = false;
            fireEvent(this.pageRef, 'decipher__callLogged');
            const taskSavedEvent = new CustomEvent('success');
            this.dispatchEvent(taskSavedEvent);
        })
        .catch(error => {
            console.log(error);
            this.showSpinner = false;
        })
    }
}
Hi All, 
          I am getting this error in Class: LeadTrigger: execution of AfterInsert caused by: System.ListException: Duplicate id in list: 00Q8I000006zCO1UAM Class.LeadTriggerHelper.markPrimary: line 168, column 1 Trigger.LeadTrigger: line 14, column 1
My class is given below:- 

public class LeadTriggerHelper {
    
    public static List<Lead> newLeads = new List<Lead>();
    public static List<Lead> oldLeads = new List<Lead>();
    public static Map<Id, Lead> newMapLeads = new Map<Id, Lead>();
    public static Map<Id, Lead> oldMapLeads = new Map<Id, Lead>();
    public static Boolean runTrigger = true;
    private static Map<String, Schema.SObjectField> leadFieldsMap = Lead.SObjectType.getDescribe().fields.getMap();
    
    
    public static void markPrimary(){
        
        Map<String, List<Lead>> mapKeyToAssociatedLeads = new Map<String, List<Lead>>();
    List<String> fields = getFieldsString(); 
    List<Lead> applicableLeads = (Lead[]) Database.query('SELECT ' + String.join(fields, ',') +
                                                        ' FROM Lead WHERE Id IN :newLeads');

    Set<String> leadEmails = new Set<String>();
    Set<String> nameAndPhoneKeys = new Set<String>();
    Set<String> phones = new Set<String>();
    Set<String> names = new Set<String>();

    List<Lead> leadsToUpdate = new List<Lead>();
    for (Lead leadObj : applicableLeads) {
        if (leadObj.Email != null) {
            leadEmails.add(leadObj.Email);
        }
        names.add(leadObj.Name);
        phones.add(leadObj.Phone);
        nameAndPhoneKeys.add(leadObj.Name + leadObj.Phone);
    }

    String leadQuery = 'SELECT ' + String.join(fields, ',') +
                       ' FROM Lead WHERE (Email IN :leadEmails OR (Name IN :names AND Phone IN :phones))' +
                       ' AND Id NOT IN :applicableLeads AND IsConverted = False AND Lead_Type__c != \'Primary Converted\'' +
                       ' ORDER BY CreatedDate ASC';

    String personAccountQuery = 'SELECT Id, PersonEmail, PersonMobilePhone, Full_Name__pc ' +
                                ' FROM Account WHERE (PersonEmail IN :leadEmails OR ' +
                                ' (Full_Name__pc IN :names AND PersonMobilePhone IN :phones))';
        
        System.debug('personAccountQuery'+personAccountQuery);

    List<SObject> combinedResults = new List<SObject>();
    combinedResults.addAll(Database.query(leadQuery));
    combinedResults.addAll(Database.query(personAccountQuery));
        System.debug('combinedResults'+combinedResults);

    for (SObject existingRecord : combinedResults) {
        if (existingRecord.getSObjectType() == Lead.SObjectType) {
            Lead existingLead = (Lead) existingRecord;

            if (leadEmails.contains(existingLead.Email)) {
                if(mapKeyToAssociatedLeads.containsKey(existingLead.Email)) {
                List<Lead> associatedLeads = mapKeyToAssociatedLeads.get(existingLead.Email);
                associatedLeads.add(existingLead);
                mapKeyToAssociatedLeads.put(existingLead.Email, associatedLeads);
            }  
            else {
                mapKeyToAssociatedLeads.put(existingLead.Email, new List<Lead> {existingLead});
            }
            }

            if (nameAndPhoneKeys.contains(existingLead.Name + existingLead.Phone)) {
                if(mapKeyToAssociatedLeads.containsKey(existingLead.Name+existingLead.Phone)) {
                List<Lead> associatedLeads = mapKeyToAssociatedLeads.get(existingLead.Name+existingLead.Phone);
                associatedLeads.add(existingLead);
                mapKeyToAssociatedLeads.put(existingLead.Name+existingLead.Phone, associatedLeads);
            }  
            else {
                mapKeyToAssociatedLeads.put(existingLead.Name + existingLead.Phone, new List<Lead> {existingLead});
            }
            }

            // Check if it's a matching person account
         } else if (existingRecord.getSObjectType() == Account.SObjectType) {
             Account matchingPersonAccount = (Account) existingRecord;
               System.debug('matchingPersonAccount'+matchingPersonAccount);
            
         String personAccountKey = matchingPersonAccount.PersonEmail != null ? matchingPersonAccount.PersonEmail : (matchingPersonAccount.Full_Name__pc + matchingPersonAccount.PersonMobilePhone);
        if (!mapKeyToAssociatedLeads.containsKey(personAccountKey)) {
            mapKeyToAssociatedLeads.put(personAccountKey, new List<Lead>());
        }
             System.debug('mapKeyToAssociatedLeads'+mapKeyToAssociatedLeads);

        for (Lead leadObj : applicableLeads) {
            if (leadObj.Email != null && leadObj.Email == matchingPersonAccount.PersonEmail) {
                mapKeyToAssociatedLeads.get(personAccountKey).add(leadObj);
                
            } else if (leadObj.Name != null && leadObj.Phone != null && (leadObj.Name + leadObj.Phone) == (matchingPersonAccount.Full_Name__pc + matchingPersonAccount.PersonMobilePhone)) {
                mapKeyToAssociatedLeads.get(personAccountKey).add(leadObj);
            }
        }
            
            System.debug('mapKeyToAssociatedLeads Line 94'+mapKeyToAssociatedLeads);
            
             for (Lead leadObj : applicableLeads) {
                System.debug('mapKeyToAssociatedLeads'+mapKeyToAssociatedLeads);
                if (mapKeyToAssociatedLeads.containsKey(leadObj.Email) && mapKeyToAssociatedLeads.get(leadObj.Email).contains(leadObj)) {
                    leadObj.Person_Account__c = matchingPersonAccount.Id;
                    System.debug('leadObj.Person_Account__c'+leadObj.Person_Account__c);
                } else if (mapKeyToAssociatedLeads.containsKey(leadObj.Name + leadObj.Phone) && mapKeyToAssociatedLeads.get(leadObj.Name + leadObj.Phone).contains(leadObj)) {
                    leadObj.Person_Account__c = matchingPersonAccount.Id;
                    System.debug('leadObj.Person_Account__c'+leadObj.Person_Account__c);
                }
            }
        }
    }
        
        List<Lead> associatedLeads = new List<Lead>();
        Map<Id, Lead> mapNewLeadToAssociatedLead = new Map<Id, Lead>();
        for(Lead leadObj : applicableLeads){
            
            if(mapKeyToAssociatedLeads.containsKey(leadObj.Email)){
                associatedLeads = mapKeyToAssociatedLeads.get(leadObj.Email);
                mapNewLeadToAssociatedLead.put( leadObj.Id, associatedLeads.get(0) );
            }
            else if(mapKeyToAssociatedLeads.containsKey(leadObj.Name+leadObj.Phone)){
                associatedLeads = mapKeyToAssociatedLeads.get(leadObj.Name+leadObj.Phone);
                mapNewLeadToAssociatedLead.put( leadObj.Id, associatedLeads.get(0) );
            }
        }
        
        System.debug('mapNewLeadToAssociatedLead'+mapNewLeadToAssociatedLead);
        
        // loop over new inserted leads
        for(Lead leadObj : applicableLeads){
            
            Lead primaryLead;
            if( mapNewLeadToAssociatedLead.containsKey( leadObj.Id )) {
                primaryLead = mapNewLeadToAssociatedLead.get( leadObj.Id );
            }
            System.debug('primaryLead'+primaryLead);
            if( primaryLead != null ) {
                primaryLead.Lead_Type__c = 'Primary';
                // update new lead to existing type        
                leadObj.Lead_Type__c = 'Existing Lead';
                leadObj.Primary_Lead__c = primaryLead.Id;
                //leadObj.OwnerId = primaryLead.OwnerId;
                runTrigger = false;
                leadsToUpdate.add(leadObj);
                System.debug('leadsToUpdate'+leadsToUpdate);
                Schema.SObjectType leadType = leadObj.getSObjectType();
                
                for(String fieldName : leadFieldsMap.keySet()){
                    if(fieldName != 'Primary_Lead__c'){
                        if(leadFieldsMap.get(fieldName).getDescribe().isUpdateable()){
                            Object associatedLeadFieldValue = leadObj.get(fieldName);
                            Object primaryLeadFieldValue = primaryLead.get(fieldName);
                            
                            if (primaryLeadFieldValue == null && associatedLeadFieldValue != null) {
                                primaryLead.put(fieldName, associatedLeadFieldValue);
                            }    
                        }
                    }
                }
                leadsToUpdate.add(primaryLead); 
                 System.debug('primaryLead'+primaryLead);
            }
            else {
                leadObj.Lead_Type__c = 'Primary';
                leadsToUpdate.add(leadObj);
                System.debug('leadObj'+leadObj.Lead_Type__c);
            }
        }
        if(leadsToUpdate.size() > 0){
              System.debug('leadsToUpdate'+leadsToUpdate);
             update leadsToUpdate; // Getting error here
         }
    }
         }
Can anyone help me to remove this error from this class?
Hi All, 
          I have created a component in which I am getting this error:-This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read properties of undefined (reading 'config')] Failing descriptor: {force:record}

My component is given below:-

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="recordId" type="String" default="7012g00000ZoJ9aAAF"/>
    <aura:attribute name="record" type="Object"/>
    <aura:attribute name="simpleRecord" type="Object"/>
    <aura:attribute name="recordLoadError" type="String"/>
    <force:recordData aura:id="record"
    recordId="{!v.recordId}"
    fields="Name,Description,Street_Address__c,City__c,State__c,Country__c,Zip_Code__c"
    targetFields="{!v.simpleRecord}"
    targetError="{!v.recordLoadError}"
    />
     <!--aura:handler name="init" value="{!this}" action="{!c.doInit}"/-->
     
         
        <ltngMap:recordMap Name="{!v.simpleRecord.Name}"
                               Description="{!v.simpleRecord.Description}" 
                               Address="{!v.simpleRecord.Street_Address__c}" 
                               City="{!v.simpleRecord.City__c}"
                               State="{!v.simpleRecord.State__c}"
                               Country="{!v.simpleRecord.Country__c}"
                               ZipCode="{!v.simpleRecord.Zip_Code__c}"
                               />
    
</aura:component>

How to resolve this issue ?
Can anyone help me with this?
 
Hi All,
           I want to create a metric chart in LWC like below:-
User-added image
We can create line chart and bar chart in LWC using chart.js. is it possible to create metric chart also ?
or is there any other approach for it? Can anyone help me out with it?
Hi All,
I am trying to show the data only when the data is available in LWC. how can i do this ?

My Component and JS is given below:- 
<template>
    <lightning-card title='My Completed Tasks'>
      <!--template if:true={data}-->
        <div>
          <canvas class="donut" lwc:dom="manual"></canvas>
       </div>
       
      <!--template if:false={data}>
        <div class="slds-align_absolute-center slds-m-top_xx-large" style ="font-size: large;">No Data is available to show</div>
   </template-->
     
    </lightning-card>
</template>

JS File:- 
import { LightningElement, wire, track } from 'lwc';
//importing the Chart library from Static resources
import Chartjs from '@salesforce/resourceUrl/Chartjs';
import { loadScript } from 'lightning/platformResourceLoader';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
//importing the apex method.
import getAllTasksByType from '@salesforce/apex/TaskChartController.getAllTasksByType';
export default class DonutChart extends LightningElement {
    //isData = false;
    @wire(getAllTasksByType) task({ error, data }) {
        if (data) {
            console.log('get value', data)
            for (var key in data) {
                this.updateChart(data[key].count, data[key].label);
            }
            this.error = undefined;
        }
        else if (error) {
            console.log('get value', error);
            this.error = error;
            //this.task = undefined;
        }
    }
    chart;
    chartjsInitialized = false;
    config = {
        type: 'doughnut',
        data: {
            datasets: [
                {
                    data: [
                    ],
                    backgroundColor: [
                        'rgb(255,99,132)',
                        'rgb(255,159,64)',
                        'rgb(255,205,86)',
                        'rgb(75,192,192)',
                    ],
                    label: 'Dataset 1'
                }
            ],
            labels: []
        },
        options: {
            responsive: true,
            legend: {
                position: 'right'
            },
            animation: {
                animateScale: true,
                animateRotate: true
            }
        }
    };
    renderedCallback() {
        if (this.chartjsInitialized) {
            return;
        }
        this.chartjsInitialized = true;
        Promise.all([
            loadScript(this, Chartjs)
        ]).then(() => {
            const ctx = this.template.querySelector('canvas.donut')
                .getContext('2d');
            this.chart = new window.Chart(ctx, this.config);
        })
            .catch(error => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error loading ChartJS',
                        message: error.message,
                        variant: 'error',
                    }),
                );
            });
    }
    updateChart(count, label) {
        //isData = true;
        this.chart.data.labels.push(label);
        this.chart.data.datasets.forEach((dataset) => {
            dataset.data.push(count);
        });
        this.chart.update();
    }
}

Can anyone help me how to show data when data is available?

 
Hi All, 
          I have a custom link on account which shows a dynamic report when clicked. the report is showing in desktop but it does not show records in mobile. so i want to create a Component to show the report in mobile also.
   How can i achieve this? can anyone help me out?
Hi All,
   I have a requirement where i want to calculate total number of Campaign members on Campaign where lead Status = RAW.
I have created a trigger for it and its helper class is given below:- 

public class CampaignMemberTriggerHelper {
    
    public static List<CampaignMember> newCampaignMembers = new List<CampaignMember>();
    public static List<CampaignMember> oldCampaignMembers = new List<CampaignMember>();
    public static Map<Id, CampaignMember> newMapCampaignMembers = new Map<Id, CampaignMember>();
    public static Map<Id, CampaignMember> oldMapCampaignMembers = new Map<Id, CampaignMember>();
 
    public static void updateNewNetleads(){
        Set<Id> campaignsByIds = new Set<Id>();  
        Map<Id,Campaign> campaignMapToUpdate = new Map<Id,Campaign>(); 
        List<Campaign> updateCampaignList = New List<Campaign>();
        
        if(Trigger.isDelete){
            for(CampaignMember cm: oldCampaignMembers){ 
                if(cm.CampaignId != NULL){
                    campaignsByIds.add(cm.CampaignId); 
                }
            }
        }else{
            for(CampaignMember cm: newCampaignMembers){ 
                if(cm.CampaignId != NULL){
                    campaignsByIds.add(cm.CampaignId); 
                }
            }
        }
        
        if(campaignsByIds.size()>0){
            system.debug('test cam list'+campaignsByIds);
            List<AggregateResult> aggrList = new List<AggregateResult>([SELECT Count(Id)ids,CampaignId   
                                                                        FROM CampaignMember 
                                                                        WHERE CampaignId IN:campaignsByIds
                                                                        AND lead.Status ='RAW' 
                                                                        GROUP BY CampaignId]);
            if(!aggrList.isEmpty()){
                for(AggregateResult aggr:aggrList){ 
                          Campaign cmObj = new Campaign();  
                    cmObj.Net_New_Lead__c  = (Decimal)aggr.get('ids');
                        cmObj.Id = (Id)aggr.get('CampaignId');  
                    campaignMapToUpdate.put(cmObj.Id, cmObj);
                    
                }
            } 
        }
            if(campaignMapToUpdate.values().size() > 0 ){
            update campaignMapToUpdate.values();  
        }
    }
}
I have a number field on which the total number of campaign members display
Now when i change the status of lead it does not work. how can i modify it so that when i change the status of lead still it work correct. As of now only when i create or delete a campaign member it works.
How can i modify this so that when i change the status of lead it works at that time too?
 
Hi All, 
           I have a requirement in which Community Users should not see Feed Tracking Items within the community. For example, Case Owner is Feed Tracked fields. Additionally, they don't need to see any automated items - only actual case comments.
how can i hide or not show the feed tracking items to community users? 
 
Hi All,
          I want to close a popup window when i click on save. how can we do this? Can anyone help me with it?
my Component is given below:-
<template>
    <lightning-card title="Event Attendance" icon-name="custom:custom63">
        <div class="slds-m-around_medium">
            <template if:true={participation.data}>
                <lightning-datatable
                hide-checkbox-column="true"
                key-field="Id"
                data={participation.data}
                columns={columns}
                onsave={handleSave}
                  draft-values={draftValues}>
            </lightning-datatable>
            </template>
                </div>
    </lightning-card>
</template>
JS Controller:-
import { LightningElement, wire, api } from 'lwc';
import getParticipation from '@salesforce/apex/ParticipationController.getParticipation';
import { refreshApex } from '@salesforce/apex';
import { updateRecord } from 'lightning/uiRecordApi';
import updateParticipations from '@salesforce/apex/ParticipationController.updateParticipations';
import { getRecordNotifyChange } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
  const COLS = [
    {
        label: 'Participation Name',
        fieldName: 'Participation_Name__c'
    },
    { label: 'Participated?', fieldName: 'Participated__c', type: 'boolean', editable: true }
];
export default class DatatableUpdateExample extends LightningElement {
    @api recordId;
    columns = COLS;
    draftValues = [];
    @wire(getParticipation, { accId: '$recordId' })
    participation;
    async handleSave(event) {
        const updatedFields = event.detail.draftValues;
        // Prepare the record IDs for getRecordNotifyChange()
        const notifyChangeIds = updatedFields.map(row => { return { "recordId": row.Id } });
        try {
               const result = await updateParticipations({ data: updatedFields });
            console.log(JSON.stringify("Apex update result: " + result));
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Success',
                    message: 'Attendance marked',
                    variant: 'success'
                })
            );
            // Refresh LDS cache and wires
            getRecordNotifyChange(notifyChangeIds);
               refreshApex(this.participation).then(() => {
                    this.draftValues = [];
                     });
        } catch (error) {
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Error updating or refreshing records',
                    message: error.body.message,
                    variant: 'error'
                })
            );
        };
    }
}
User-added image
Hi All, 
   I have a class mentioned below:-
public without sharing class CreateBadgeController {
    @AuraEnabled 
    public static WorkBadge createBadge(Map<String, Object> callObject) {
     List<WorkBadgeDefinition> workBadges= [SELECT Id 
                                               FROM WorkBadgeDefinition 
                                               where Name = 'Thanks'];
        String workBadgeDefinationId= String.valueOf (workBadges.get(0).id);
        
        WorkThanks  wrkThanks  = new WorkThanks();
        wrkThanks.GiverId       = UserInfo.getUserId();
        wrkThanks.Message    = 'Thanks';
        wrkThanks.OwnerId     = UserInfo.getUserId();
        wrkThanks.how_did_person_help_you__c = String.valueOf(callObject.get('how_did_person_help_you__c'));
        wrkThanks.Describe_your_connection__c = String.valueOf(callObject.get('Describe_your_connection__c'));
        wrkThanks.How_has_this_connection_impacted_you__c = String.valueOf(callObject.get('How_has_this_connection_impacted_you__c'));
        wrkThanks.Notes__c = String.valueOf(callObject.get('Notes__c'));
        //wrkThanks.NetworkId = '0DB8c0000001peoGAA';
        wrkThanks.NetworkId = System.Label.CommunityId;
        Insert wrkThanks;
        
        WorkBadge  wrkBadge = new WorkBadge ();
        wrkBadge.DefinitionId = workBadgeDefinationId;
        //wrkBadge.RecipientId = '0058c000009g2waAAA';
        wrkBadge.RecipientId = String.valueOf(callObject.get('RecipientId'));
        wrkBadge.SourceId = wrkThanks.Id;
        wrkBadge.NetworkId =  System.Label.CommunityId;
        Insert wrkBadge;
        return wrkBadge;
    }
}
I am trying to create a test class for it which is giving me error my test class is given below:-
@istest
public class CreateBadgeControllerTest {
    Public Static testmethod void createWorkBadgeTest(){
   
        WorkThanks  wrkThanks  = new WorkThanks();
        wrkThanks.GiverId = UserInfo.getUserId();
        wrkThanks.Message = 'Thanks';
        wrkThanks.OwnerId = UserInfo.getUserId();
        wrkThanks.how_did_person_help_you__c = 'Provided me a connection';
        wrkThanks.Describe_your_connection__c =  'New Friend/ Colleague';
        wrkThanks.How_has_this_connection_impacted_you__c = 'Revenue Growth';
        wrkThanks.Notes__c =  'Thanks test';
        //wrkThanks.NetworkId = '0DB8c0000001peoGAA';
        wrkThanks.NetworkId = System.Label.CommunityId;
        Insert wrkThanks;
        WorkBadge  wrkBadge = new WorkBadge ();
        wrkBadge.DefinitionId = '0W18c000001Cm4pCAC';
        //wrkBadge.RecipientId = '0058c000009g2waAAA';
        wrkBadge.RecipientId =  userinfo.getUserId();
        wrkBadge.SourceId = wrkThanks.Id;
        wrkBadge.NetworkId =  System.Label.CommunityId;
        Insert wrkBadge;
        
        Map<String, WorkBadge> callObject = new Map<String, WorkBadge>();
        callObject.put(wrkBadge.id,wrkBadge);
           CreateBadgeController.createBadge(callObject);
        test.stopTest();
    }
}
its giving me error:- System.DmlException: Insert failed. First exception on row 0; first error: INVALID_ID_FIELD, Invalid input badge definition id.: []
Can anyone help me out how to create test class for it?
Hi All,
          I want to show users like below image. how can i do this in LWC? any suggestions?
 User-added image
Hi All,
           When i am trying to deploy a flow from changset its giving me error :-  Error parsing file: Element {http://soap.sforce.com/2006/04/metadata}conditionLogic invalid at this location in type FlowCollectionProcessor  when i am validating it on production and the flow got removed from changeset after validation failed.
Can anyone tell me what could be the reason?
Thanks in advance
 
Hi All,
          I have created a visualforce page but when i am trying to use it in quick action this VFP is not visible in the VFP after selecting action type as Custom Visualforce Page.
 my VFP is as below:
<apex:page standardcontroller="Case" recordSetVar="cases" showQuickActionVfHeader = "false" extensions="CaseAcceptOwnership" action="{!updateCases}">
</apex:page>eptOwnership

Can anyone help me why i am not able to see this in quick action?
Thanks
Hi All,

My requirement is to transfer the case to the user invoking the action. For example, I click "Transfer Case" and the case is now assigned to me.
 Is it possible to do elegant transfer using a visualforce override or some other architecture that is seamless when the user presses the action?
Can anyone help me with this?
Thanks
Hi All,
          I have a checkbox on User Called Delete_Records__c. if this checkbox is true then i should be able to delete record for a  Custom object named as Cycle info else an error should be thrown.
How Can i create a trigger for it?
Any help
Hi therem
I would like to create a simple Aura cmponent that has 2 buttons in the middle that are square and have a big ison in the middle. 
I have attached a screenshot for the same.
How can this be done?
Thank you!User-added image
Trying to design a rich text (lightning component that can be used in community builder) that allows to @mention other users. Is this behaviour available out of the box or if there some reference that I can follow.