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

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 305
    Questions
  • 283
    Replies
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 have a Aura component in which i want to redirect it to the record in another window. but its not working
My component is given below:- 

<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"/>
    <lightning:navigation aura:id="navService"/>
    
    <force:recordData aura:id="recordLoader"
                      recordId="{!v.recordId}"
                      layoutType="COMPACT"
                      targetRecord="{!v.record}"
                      targetFields="{!v.simpleRecord}"
                      targetError="{!v.recordError}"  />
    <!-- Display a header with details about the record -->
    <div class="slds-page-header" role="banner">
        <tr>
            <td>
                <p class="slds-text-heading--label"><a onclick="{!c.redirectDetail}">
                    <lightning:formattedText value="{!v.simpleRecord.Name}" />

                    </a></p>
            </td>
            
        </tr>
    </div>
    
</aura:component>
****************************************************************
Js File
({
    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);
        formatText.set("v.value",sobject[fieldName]);
    },
    
    redirectDetail : function(component, event, helper) {
        //Redirect to detail page on success
        var navService = component.find('navService');
    
        var pageReference = {
            type: 'standard__recordPage',
            attributes: {
                "recordId": component.get("v.recordId"),
                "objectApiName": component.get("v.obName"),
                "actionName": "view"
            }
        }
        //event.preventDefault();
        navService.navigate(pageReference);
    }
})
 
Hi All,
         I have created a trigger to provide Apex sharing to the forum members but when i am inserting members i am getting following error:- Trigger_ForumMember: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: unknown (invalid user or group: 0056u000001AjNo): [unknown] Class.ForumMemberTriggerHelper.shareForumWithUser: line 42, column 1 Trigger.Trigger_ForumMember: line 15, column 1
My trigger and helper class given below:- 

trigger Trigger_ForumMember on Forum_Members__c (before insert, before update, before delete,
                                                    after insert, after update, after delete) {
                                                     
    ForumMemberTriggerHelper.newForumMembers = Trigger.new;
    ForumMemberTriggerHelper.oldForumMembers = Trigger.old;
    ForumMemberTriggerHelper.newMapForumMembers = Trigger.newMap;
    ForumMemberTriggerHelper.oldMapForumMembers = Trigger.oldMap; 
                                                     
        if(!ForumMemberTriggerHelper.runTrigger) {
        return;
    }                                           
    
    if( Trigger.isAfter) {
        if( Trigger.isInsert ){
            ForumMemberTriggerHelper.shareForumWithUser();   
        }
    
    }                                     
}
Helper Class:- 
public class ForumMemberTriggerHelper {
            
    public static List<Forum_Members__c> newForumMembers = new List<Forum_Members__c>();
    public static List<Forum_Members__c> oldForumMembers = new List<Forum_Members__c>();
    public static Map<Id, Forum_Members__c> newMapForumMembers = new Map<Id, Forum_Members__c>();
    public static Map<Id, Forum_Members__c> oldMapForumMembers = new Map<Id, Forum_Members__c>();
    
     public static boolean runTrigger = TRUE;
     public static void shareForumWithUser(){
         Set<Id> contactIds = new Set<Id>();
        Map< Id, User> mapOfContactIdToUser = new Map<Id,User>();
        List< Forum__Share > lstForumShare = new List< Forum__Share >();
        for( Forum_Members__c fm : newForumMembers ){
            if( fm.Member__c != null ){
                contactIds.add( fm.Member__c );
            }
        }
        System.debug('contactIds'+contactIds);
        for( User ur : [ SELECT Id, ContactId 
                        FROM User 
                        WHERE ContactId IN : contactIds ] )
        {
            mapOfContactIdToUser.put( ur.ContactId , ur );
        }
        System.debug('mapOfContactIdToUser'+mapOfContactIdToUser);
        for( Forum_Members__c fm :  newForumMembers ){
            
            if( fm.Forum__c != null  ){
                if( mapOfContactIdToUser.containsKey( fm.Member__c )
                   && mapOfContactIdToUser.get( fm.Member__c ) != null ){
                       System.debug('Inside log');
                       Forum__Share sharing = new Forum__Share();
                       sharing.ParentId = fm.Forum__c;
                       sharing.AccessLevel = 'Edit';
                       sharing.RowCause = 'Manual';
                       sharing.UserOrGroupId = mapOfContactIdToUser.get( fm.Member__c ).Id;
                       lstForumShare.add( sharing );
                   }
            }
        }
        if( lstForumShare.size() > 0 ){
            insert lstForumShare;
            System.debug('lstForumShare'+lstForumShare);
        }
         System.debug('SharedObj'+lstForumShare);
    }
}
Can anyone help me with this error?
Hi All,

The problem I am running into is that I am trying to create a single dashboard with a filter that each user can toggle to their name rather than create a new dashboard for every rep.
With the first four reports, this is easy to accomplish as they are all opportunities reports and a simple “opportunity owner” filter will suffice. The last report is a lead with converted leads report, but I’ve built a workaround by creating a checkbox field so that it will only show leads where the matched account owner = the name of the user. However, when I add this lead to the dashboard, the ‘opportunity owner' filter automatically gets applied to the report when I would prefer no filter to be applied
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 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 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 All, 
          When i enter any word in the lookup in the component i ma getting this error: Uncaught Action failed: c:CustomLookup$controller$keyPressController [Cannot read properties of undefined (reading 'length')]

My Component and controller is as follow:- 
<aura:component controller="Lookup_Controller">
    <!--declare attributes--> 
    <aura:attribute name="selectedRecord" type="sObject" default="{}" description="Use,for store SELECTED sObject Record"/>
    <aura:attribute name="listOfSearchRecords" type="List" description="Use,for store the list of search records which returns from apex class"/>
    <aura:attribute name="SearchKeyWord" type="string"/>
    <aura:attribute name="objectAPIName" type="string" default=""/>
    <aura:attribute name="IconName" type="string" default=""/>
    <aura:attribute name="label" type="string" default=""/>
    <aura:attribute name="Message" type="String" default=""/>
    
    <!--declare events hendlers-->  
    <aura:handler name="oSelectedRecordEvent" event="c:SelectedSObjectRecordEvent" action="{!c.handleComponentEvent}"/>
    
    <div onmouseleave="{!c.onblur}" aura:id="searchRes" class="slds-form-element slds-lookup slds-is-close" data-select="single">
        <label class="slds-form-element__label" for="lookup-348">{!v.label}</label>
        <div class="slds-form-element__control">
            
            <div class="slds-input-has-icon slds-input-has-icon--right">
                <div aura:id="lookup-pill" class="slds-pill-container slds-hide">
                     <lightning:pill class="pillSize" label="{!v.selectedRecord.Name}" name="{!v.selectedRecord.Name}" onremove="{! c.clear }">
                          <aura:set attribute="media">
                             <lightning:icon iconName="{!v.IconName}" size="x-small" alternativeText="{!v.IconName}"/>
                          </aura:set>
                      </lightning:pill>
                </div>
                <div aura:id="lookupField" class="slds-show" >
                    <lightning:icon class="slds-input__icon slds-show" iconName="utility:search" size="x-small" alternativeText="search"/>
                    <span class="slds-icon_container  slds-combobox__input-entity-icon" title="record">
                        <lightning:icon class="slds-icon slds-icon slds-icon_small slds-icon-text-default" iconName="{!v.IconName}" size="x-small" alternativeText="icon"/>
                        <span class="slds-assistive-text"></span>
                    </span>
                    <div onkeypress="{!c.keyPressController}" > 
                        <lightning:input aria-invalid="true" style="margin:0px !important" onclick="{!c.onfocus}"  class="slds-lookup__search-input slds-input leftPaddingClass" value="{!v.SearchKeyWord}" placeholder="search.."/>
                    </div>
                </div>   
            </div>
        </div>  
        <ul style="min-height:40px;margin-top:0px !important" class="slds-listbox slds-listbox_vertical slds-dropdown slds-dropdown_fluid slds-lookup__menu slds" role="listbox">
            <lightning:spinner class="slds-hide" variant="brand" size="small" aura:id="mySpinner"/>
            <center> {!v.Message}</center>
            <aura:iteration items="{!v.listOfSearchRecords}" var="singleRec">
                <c:CustomLookupResult oRecord="{!singleRec}" IconName="{!v.IconName}"/>
            </aura:iteration>
        </ul>
    </div>
</aura:component>

Controller:-
({
   onfocus : function(component,event,helper){
       $A.util.addClass(component.find("mySpinner"), "slds-show");
        var forOpen = component.find("searchRes");
            $A.util.addClass(forOpen, 'slds-is-open');
            $A.util.removeClass(forOpen, 'slds-is-close');
        // Get Default 5 Records order by createdDate DESC  
         var getInputkeyWord = '';
         helper.searchHelper(component,event,getInputkeyWord);
    },
    onblur : function(component,event,helper){       
        component.set("v.listOfSearchRecords", null );
        var forclose = component.find("searchRes");
        $A.util.addClass(forclose, 'slds-is-close');
        $A.util.removeClass(forclose, 'slds-is-open');
    },
    keyPressController : function(component, event, helper) {
       // get the search Input keyword   
         var getInputkeyWord = component.get("v.SearchKeyWord");
       // check if getInputKeyWord size id more then 0 then open the lookup result List  
       // else close the lookup result List part.   
        if( getInputkeyWord.length > 0 ){

             var forOpen = component.find("searchRes");
               $A.util.addClass(forOpen, 'slds-is-open');
               $A.util.removeClass(forOpen, 'slds-is-close');
            helper.searchHelper(component,event,getInputkeyWord);
        }
        else{  
             component.set("v.listOfSearchRecords", null ); 
             var forclose = component.find("searchRes");
               $A.util.addClass(forclose, 'slds-is-close');
               $A.util.removeClass(forclose, 'slds-is-open');
          }
    },
    
  // function for clear the Record Selaction 
    clear :function(component,event,heplper){
         var pillTarget = component.find("lookup-pill");
         var lookUpTarget = component.find("lookupField"); 
        
         $A.util.addClass(pillTarget, 'slds-hide');
         $A.util.removeClass(pillTarget, 'slds-show');
        
         $A.util.addClass(lookUpTarget, 'slds-show');
         $A.util.removeClass(lookUpTarget, 'slds-hide');
      
         component.set("v.SearchKeyWord",null);
         component.set("v.listOfSearchRecords", null );
         component.set("v.selectedRecord", {} );   
    },
    
  // This function call when the end User Select any record from the result list.   
    handleComponentEvent : function(component, event, helper) {
    // get the selected Account record from the COMPONETN event      
       var selectedAccountGetFromEvent = event.getParam("recordByEvent");
       component.set("v.selectedRecord" , selectedAccountGetFromEvent); 
       
        var forclose = component.find("lookup-pill");
           $A.util.addClass(forclose, 'slds-show');
           $A.util.removeClass(forclose, 'slds-hide');
  
        var forclose = component.find("searchRes");
           $A.util.addClass(forclose, 'slds-is-close');
           $A.util.removeClass(forclose, 'slds-is-open');
        
        var lookUpTarget = component.find("lookupField");
            $A.util.addClass(lookUpTarget, 'slds-hide');
            $A.util.removeClass(lookUpTarget, 'slds-show');  
      
    },
})
Can anyone help me with this error? I am getting this error from Bold lines.

Thanks
Hi All,
        I have a process builder in which it creates a campaign on contact when contact status is changed from Nurture to SAL. I am  getting error:- DUPLICATE_VALUE: Already a campaign member..  when i change status from nurture to SAL and contact has that Campaign added already.
Can anyone help me how can i avoid this situation ?

Thanks
Hi All, 
          My helper class is given below:-
 public with sharing class OpportunityTriggerHandler {
  public static Boolean run = true;
  public static void associateProducts(List<Opportunity> opps) {
   if (!run) {
            return;
        }

        Set<String> classValues = new Set<String>();
        for (Opportunity o : opps) {    
      System.assert(false,o.Pricebook2Id);
            if (!String.isBlank(o.Product_Class__c)) {
                classValues.add(o.Product_Class__c);
            }
        }

        if (classValues.size() > 0) {
       List<Product_Class_Association__c> assocs = [SELECT
                    Id,
                    Fulfillment_Type__c,
                    Product__c,
                    Product_Class__c,
                    Quantity__c,
                    Sales_Price__c
                FROM Product_Class_Association__c
                WHERE Product_Class__c IN :classValues];
             System.debug('assocs'+assocs);
            if (assocs.size() > 0) {

                Map<Id, Id> productPricebooks = new Map<Id, Id>();
                for (Product_Class_Association__c assoc : assocs) {
                    productPricebooks.put(assoc.Product__c, null);
                }
                 System.debug('productPricebooks'+productPricebooks);
                if (productPricebooks.size() > 0) {
                    List<PricebookEntry> entries = [SELECT Id, Product2Id FROM PricebookEntry WHERE Product2Id IN :productPricebooks.keySet()];
                    if (entries.size() > 0) {
                        for (PricebookEntry e : entries) {
                            productPricebooks.put(e.Product2Id, e.Id);
                        }
                    }
                }
                System.debug('productPricebooks'+productPricebooks); //here i am getting only one pricebook entry for products whereas one or more pricebook are active for products.
                List<OpportunityLineItem> ops = new List<OpportunityLineItem>();
                for (Opportunity o : opps) {
                    if (!String.isBlank(o.Product_Class__c)) {
                        for (Product_Class_Association__c assoc : assocs) {
                            if (assoc.Product_Class__c == o.Product_Class__c) {

                                // STEP 2: Associated new field to the Opportunity Product
                                OpportunityLineItem op = new OpportunityLineItem();
                                op.OpportunityId = o.Id;
                                op.PricebookEntryId = productPricebooks.get(assoc.Product__c);
                                op.Quantity = assoc.Quantity__c;
                                op.UnitPrice = assoc.Sales_Price__c;
                                op.Fulfillment_Type__c = assoc.Fulfillment_Type__c;
                                op.Commitment_Date__c = o.CloseDate;
                                ops.add(op);

                            }
                        }
                    }
                }
                      System.debug('ops'+ops);
                if (ops.size() > 0) {
                    insert ops;
                }
 System.debug('ops'+ops);
            }
    }
  }
 }
When i am trying to create an opportunity i am getting error:- execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 2; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: unknown (pricebook entry is in a different pricebook than the one assigned to the opportunity): [unknown] ()
the product related to the product class has 3 products and in those products i have more than one pricebook active but in the map productPricebooks, I am getting only one pricebook entry for the products which has currency diffrent from opportunity. how to resolve this. can anyone help me with it?
Hi All,
I am updating a user record by changing role of user, while changing role of user I ma getting Error:- The value of a parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit.
  this error is only coming while i am changing only role, if i change anything else in user record, It gets saved but while updating role its giving me this error. I have tried inactive trigger/Flow etc on user record but i am still getting this error.
Can anyone help me with this?
Thanks in advance
Hi All, 
         I Have created a  test class for  the class below:-

public class MilestoneUtils {
    
    // Method Description : This method is use to Complete Case MileStone And Update Case fields when Email to Customer and Others
     
    public static void completeMilestone(Set<Id> caseIds,DateTime complDate){
        Set<Id> lstOfcaseId =caseIds;
        Map<Id,CaseMilestone> mapofCaseIdToMilestone = new Map<Id,CaseMilestone>();
        List<Case> casetoUpdate = new List<Case>();
        List<CaseMilestone> cmsToUpdate = [select Id,CaseId, completionDate
                                           from CaseMilestone cm
                                           where caseId in :caseIds and IsCompleted = false
                                           and completionDate = null AND MilestoneType.Name !='Full Resolution' limit 1];
        if (cmsToUpdate.isEmpty() == false){
            for (CaseMilestone cm : cmsToUpdate){
                cm.completionDate = complDate;
            }
            try{
                Database.SaveResult[] srList =Database.update(cmsToUpdate, True);
                CommonUtility.saveResults(srList);
            }catch(Exception e){
                ExceptionLogUtil.logException('MilestoneUtils','completeMilestone',e.getMessage(),e.getStackTraceString());

            }
            CaseMilestone mil= [SELECT caseId,MilestoneType.Name,ActualElapsedTimeInMins from CaseMilestone Where id=:cmsToUpdate order by createdDate DESC];
            mapofCaseIdToMilestone.put(mil.caseId,mil);
        }
        for(Case c : [Select status,Time_To_First_response__c,Last_Time_Waiting_Status__c,Is_Next_Reply__c,
                      count_of_outbound_emails__c,Last_Outbound_Email__c from Case where id In : caseIds]){
                          //c.status ='Waiting on Customer';
                          c.Last_Time_Waiting_Status__c = system.now();
                          if(mapofCaseIdToMilestone != null && mapofCaseIdToMilestone.containsKey(c.id)){
                              if(mapofCaseIdToMilestone.get(c.id).MilestoneType.Name == 'Next Reply'){
                                  c.Time_To_Next_Reply_Minutes__c = mapofCaseIdToMilestone.get(c.id).ActualElapsedTimeInMins;
                              }
                              if(mapofCaseIdToMilestone.get(c.id).MilestoneType.Name == 'First Reply'){
                                  c.Time_To_First_response__c = mapofCaseIdToMilestone.get(c.id).ActualElapsedTimeInMins;  
                              }
                          }
                          if(c.count_of_outbound_emails__c == NULL){
                              c.count_of_outbound_emails__c = 0;
                          }
                          c.count_of_outbound_emails__c++;
                          c.Last_Outbound_Email__c = System.now();
                          c.Is_Next_Reply__c = false;
                          casetoUpdate.add(c);
                          
                      } 
        if(casetoUpdate.size()>0){
            try{
                Database.SaveResult[] srList = Database.update(casetoUpdate, true);
                CommonUtility.saveResults(srList);
            }catch(Exception e){
                ExceptionLogUtil.logException('MilestoneUtils','completeMilestone',e.getMessage(),e.getStackTraceString()); 
            }
        }
    }
    
    
    public static void closedCaseMileStone(List<Case> list_cases, Map<Id,Case> applicableCase){
        Map<Id,Integer> maofCaseIdToEmail = new Map<Id,Integer>();
        Map<Id,CaseMilestone> mapofCaseIdToMilestone = new Map<Id,CaseMilestone>();
        for(AggregateResult aggr : [SELECT ParentId, COUNT_DISTINCT(CreatedById)usercount FROM EmailMessage 
                                    WHERE ParentId IN :applicableCase.keySet()
                                    AND Status != '5' AND Incoming = false 
                                    group by ParentId ])
        {
            maofCaseIdToEmail.put(String.valueOf(aggr.get('ParentId')), Integer.valueOf(aggr.get('usercount')));        
        }
        List<CaseMilestone> milestonesToUpdate = new List<CaseMilestone>();
        List<CaseMilestone> cms = [select Id,caseId,completionDate,ActualElapsedTimeInMins
                                   from CaseMilestone 
                                   where caseId in :applicableCase.keySet() and IsCompleted = false
                                   and completionDate = null];
        if(cms.size()>0){
            for(CaseMilestone cm : cms){
                if(applicableCase.containsKey(cm.CaseId)){
                    if(applicableCase.get(cm.CaseId).autoSolved__c){
                        cm.completionDate = applicableCase.get(cm.CaseId).Last_Outbound_Email__c;
                    }
                    else
                        cm.completionDate = applicableCase.get(cm.CaseId).Last_Set_Solved__c; 
                }
                
                mapofCaseIdToMilestone.put(cm.caseId,cm);
                milestonesToUpdate.add(cm);
            }
            if(milestonesToUpdate.size()>0){
                try{
                    Database.SaveResult[] srList = Database.update(milestonesToUpdate, false);
                    CommonUtility.saveResults(srList);
                }catch(Exception e){
                    ExceptionLogUtil.logException('MilestoneUtils','closedCaseMileStone',e.getMessage(),e.getStackTraceString()); 
                }
                CaseMilestone mil= [SELECT caseId,ActualElapsedTimeInMins from CaseMilestone Where caseId IN : applicableCase.keySet()  
                                    AND MilestoneType.Name ='Full Resolution' limit 1];
                mapofCaseIdToMilestone.put(mil.caseId,mil);

            }
        }
        for(Case c : list_cases){
            if(maofCaseIdToEmail != null && maofCaseIdToEmail.containsKey(c.id)){
                c.count_of_unique_CSAs__c = maofCaseIdToEmail.get(c.id);
            }
            if(mapofCaseIdToMilestone != NULL && mapofCaseIdToMilestone.containsKey(c.id)){
                // removing this as when we case opened from solved then this is updating to last time solved.
                //if(c.Time_To_First_Solved__c == NULL){
                //    c.Time_To_First_Solved__c = mapofCaseIdToMilestone.get(c.id).ActualElapsedTimeInMins;
                //}
                if(c.Time_To_First_Response__c == NULL){
                    c.Time_To_First_Response__c = mapofCaseIdToMilestone.get(c.id).ActualElapsedTimeInMins;
                }
                c.Time_To_Resolution__c = mapofCaseIdToMilestone.get(c.id).ActualElapsedTimeInMins;
            }
        }
    }
    } 
My test class is given below:-
@isTest 
private class Test_MilestoneUtils {
    
    @isTest
    public static void completeMilestone_Test(){
        //Set<Id> caseids = new Set<Id>();
        List<Case> cases = new List<Case>{};
            Account acc = new Account(Name = 'Entitlement Account DO NOT DELETE');
        insert acc;
        Entitlement en = TestFactory.createEntitlement(acc, 'Enterprise');
        insert en;
        HB_User__c h = TestFactory.createAirtableUser(100,'Enterprise');
        insert h;
        Case c = TestFactory.createCase(h);
        c.Priority = 'Business Critical';
        c.EntitlementId = en.id;
        c.Company_Number_of_employees__c = 1100;
        cases.add(c);
         
        if (cases.isEmpty()==false){
            insert cases;
             Set<Id> caseIds = new Set<Id>();
            Map<id,Case> mapCases= new Map<id,Case>();
            for (Case cl : cases){
                caseIds.add(cl.Id);
                mapCases.put(cl.id,cl);
             }
             milestoneUtils.completeMilestone(caseIds,System.now());
             milestoneUtils.closedCaseMileStone(cases,mapCases);
        }
    }
 }
I am getting less code coverage. Bold lines in my class is not covering. Can anyone help me to cover the lines.
Thanks
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 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 All, 
          When i enter any word in the lookup in the component i ma getting this error: Uncaught Action failed: c:CustomLookup$controller$keyPressController [Cannot read properties of undefined (reading 'length')]

My Component and controller is as follow:- 
<aura:component controller="Lookup_Controller">
    <!--declare attributes--> 
    <aura:attribute name="selectedRecord" type="sObject" default="{}" description="Use,for store SELECTED sObject Record"/>
    <aura:attribute name="listOfSearchRecords" type="List" description="Use,for store the list of search records which returns from apex class"/>
    <aura:attribute name="SearchKeyWord" type="string"/>
    <aura:attribute name="objectAPIName" type="string" default=""/>
    <aura:attribute name="IconName" type="string" default=""/>
    <aura:attribute name="label" type="string" default=""/>
    <aura:attribute name="Message" type="String" default=""/>
    
    <!--declare events hendlers-->  
    <aura:handler name="oSelectedRecordEvent" event="c:SelectedSObjectRecordEvent" action="{!c.handleComponentEvent}"/>
    
    <div onmouseleave="{!c.onblur}" aura:id="searchRes" class="slds-form-element slds-lookup slds-is-close" data-select="single">
        <label class="slds-form-element__label" for="lookup-348">{!v.label}</label>
        <div class="slds-form-element__control">
            
            <div class="slds-input-has-icon slds-input-has-icon--right">
                <div aura:id="lookup-pill" class="slds-pill-container slds-hide">
                     <lightning:pill class="pillSize" label="{!v.selectedRecord.Name}" name="{!v.selectedRecord.Name}" onremove="{! c.clear }">
                          <aura:set attribute="media">
                             <lightning:icon iconName="{!v.IconName}" size="x-small" alternativeText="{!v.IconName}"/>
                          </aura:set>
                      </lightning:pill>
                </div>
                <div aura:id="lookupField" class="slds-show" >
                    <lightning:icon class="slds-input__icon slds-show" iconName="utility:search" size="x-small" alternativeText="search"/>
                    <span class="slds-icon_container  slds-combobox__input-entity-icon" title="record">
                        <lightning:icon class="slds-icon slds-icon slds-icon_small slds-icon-text-default" iconName="{!v.IconName}" size="x-small" alternativeText="icon"/>
                        <span class="slds-assistive-text"></span>
                    </span>
                    <div onkeypress="{!c.keyPressController}" > 
                        <lightning:input aria-invalid="true" style="margin:0px !important" onclick="{!c.onfocus}"  class="slds-lookup__search-input slds-input leftPaddingClass" value="{!v.SearchKeyWord}" placeholder="search.."/>
                    </div>
                </div>   
            </div>
        </div>  
        <ul style="min-height:40px;margin-top:0px !important" class="slds-listbox slds-listbox_vertical slds-dropdown slds-dropdown_fluid slds-lookup__menu slds" role="listbox">
            <lightning:spinner class="slds-hide" variant="brand" size="small" aura:id="mySpinner"/>
            <center> {!v.Message}</center>
            <aura:iteration items="{!v.listOfSearchRecords}" var="singleRec">
                <c:CustomLookupResult oRecord="{!singleRec}" IconName="{!v.IconName}"/>
            </aura:iteration>
        </ul>
    </div>
</aura:component>

Controller:-
({
   onfocus : function(component,event,helper){
       $A.util.addClass(component.find("mySpinner"), "slds-show");
        var forOpen = component.find("searchRes");
            $A.util.addClass(forOpen, 'slds-is-open');
            $A.util.removeClass(forOpen, 'slds-is-close');
        // Get Default 5 Records order by createdDate DESC  
         var getInputkeyWord = '';
         helper.searchHelper(component,event,getInputkeyWord);
    },
    onblur : function(component,event,helper){       
        component.set("v.listOfSearchRecords", null );
        var forclose = component.find("searchRes");
        $A.util.addClass(forclose, 'slds-is-close');
        $A.util.removeClass(forclose, 'slds-is-open');
    },
    keyPressController : function(component, event, helper) {
       // get the search Input keyword   
         var getInputkeyWord = component.get("v.SearchKeyWord");
       // check if getInputKeyWord size id more then 0 then open the lookup result List  
       // else close the lookup result List part.   
        if( getInputkeyWord.length > 0 ){

             var forOpen = component.find("searchRes");
               $A.util.addClass(forOpen, 'slds-is-open');
               $A.util.removeClass(forOpen, 'slds-is-close');
            helper.searchHelper(component,event,getInputkeyWord);
        }
        else{  
             component.set("v.listOfSearchRecords", null ); 
             var forclose = component.find("searchRes");
               $A.util.addClass(forclose, 'slds-is-close');
               $A.util.removeClass(forclose, 'slds-is-open');
          }
    },
    
  // function for clear the Record Selaction 
    clear :function(component,event,heplper){
         var pillTarget = component.find("lookup-pill");
         var lookUpTarget = component.find("lookupField"); 
        
         $A.util.addClass(pillTarget, 'slds-hide');
         $A.util.removeClass(pillTarget, 'slds-show');
        
         $A.util.addClass(lookUpTarget, 'slds-show');
         $A.util.removeClass(lookUpTarget, 'slds-hide');
      
         component.set("v.SearchKeyWord",null);
         component.set("v.listOfSearchRecords", null );
         component.set("v.selectedRecord", {} );   
    },
    
  // This function call when the end User Select any record from the result list.   
    handleComponentEvent : function(component, event, helper) {
    // get the selected Account record from the COMPONETN event      
       var selectedAccountGetFromEvent = event.getParam("recordByEvent");
       component.set("v.selectedRecord" , selectedAccountGetFromEvent); 
       
        var forclose = component.find("lookup-pill");
           $A.util.addClass(forclose, 'slds-show');
           $A.util.removeClass(forclose, 'slds-hide');
  
        var forclose = component.find("searchRes");
           $A.util.addClass(forclose, 'slds-is-close');
           $A.util.removeClass(forclose, 'slds-is-open');
        
        var lookUpTarget = component.find("lookupField");
            $A.util.addClass(lookUpTarget, 'slds-hide');
            $A.util.removeClass(lookUpTarget, 'slds-show');  
      
    },
})
Can anyone help me with this error? I am getting this error from Bold lines.

Thanks
Hi All, 
          My helper class is given below:-
 public with sharing class OpportunityTriggerHandler {
  public static Boolean run = true;
  public static void associateProducts(List<Opportunity> opps) {
   if (!run) {
            return;
        }

        Set<String> classValues = new Set<String>();
        for (Opportunity o : opps) {    
      System.assert(false,o.Pricebook2Id);
            if (!String.isBlank(o.Product_Class__c)) {
                classValues.add(o.Product_Class__c);
            }
        }

        if (classValues.size() > 0) {
       List<Product_Class_Association__c> assocs = [SELECT
                    Id,
                    Fulfillment_Type__c,
                    Product__c,
                    Product_Class__c,
                    Quantity__c,
                    Sales_Price__c
                FROM Product_Class_Association__c
                WHERE Product_Class__c IN :classValues];
             System.debug('assocs'+assocs);
            if (assocs.size() > 0) {

                Map<Id, Id> productPricebooks = new Map<Id, Id>();
                for (Product_Class_Association__c assoc : assocs) {
                    productPricebooks.put(assoc.Product__c, null);
                }
                 System.debug('productPricebooks'+productPricebooks);
                if (productPricebooks.size() > 0) {
                    List<PricebookEntry> entries = [SELECT Id, Product2Id FROM PricebookEntry WHERE Product2Id IN :productPricebooks.keySet()];
                    if (entries.size() > 0) {
                        for (PricebookEntry e : entries) {
                            productPricebooks.put(e.Product2Id, e.Id);
                        }
                    }
                }
                System.debug('productPricebooks'+productPricebooks); //here i am getting only one pricebook entry for products whereas one or more pricebook are active for products.
                List<OpportunityLineItem> ops = new List<OpportunityLineItem>();
                for (Opportunity o : opps) {
                    if (!String.isBlank(o.Product_Class__c)) {
                        for (Product_Class_Association__c assoc : assocs) {
                            if (assoc.Product_Class__c == o.Product_Class__c) {

                                // STEP 2: Associated new field to the Opportunity Product
                                OpportunityLineItem op = new OpportunityLineItem();
                                op.OpportunityId = o.Id;
                                op.PricebookEntryId = productPricebooks.get(assoc.Product__c);
                                op.Quantity = assoc.Quantity__c;
                                op.UnitPrice = assoc.Sales_Price__c;
                                op.Fulfillment_Type__c = assoc.Fulfillment_Type__c;
                                op.Commitment_Date__c = o.CloseDate;
                                ops.add(op);

                            }
                        }
                    }
                }
                      System.debug('ops'+ops);
                if (ops.size() > 0) {
                    insert ops;
                }
 System.debug('ops'+ops);
            }
    }
  }
 }
When i am trying to create an opportunity i am getting error:- execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 2; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: unknown (pricebook entry is in a different pricebook than the one assigned to the opportunity): [unknown] ()
the product related to the product class has 3 products and in those products i have more than one pricebook active but in the map productPricebooks, I am getting only one pricebook entry for the products which has currency diffrent from opportunity. how to resolve this. can anyone help me with it?
Hi All,
I am updating a user record by changing role of user, while changing role of user I ma getting Error:- The value of a parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit.
  this error is only coming while i am changing only role, if i change anything else in user record, It gets saved but while updating role its giving me this error. I have tried inactive trigger/Flow etc on user record but i am still getting this error.
Can anyone help me with this?
Thanks in advance
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
Hi All,
          I have a controller and I wrote its test class. it's not covering some part.
My controller is given below:-
 
public without sharing class MatchMakingController {
    private ApexPages.StandardController sctrl;
    rie__Registration__c regObj;
    public Map<String, List<SelectOption>> questionsMap {get;set;}
    private Map<String, String> questionAnswerMap;
    public Map<String, rie__Question__c> questionsSet {get;set;}
    public String Selectedvalues {get;set;}
    public String answeredQuestion{get; set;}
    
    public MatchMakingController(ApexPages.StandardController st){
        this.sctrl = st;
        this.regObj = (rie__Registration__c) st.getRecord();
        questionAnswerMap = new Map<String, String>();
        
    }
  
     public void populateAnswers()
    {
        questionAnswerMap.put(answeredQuestion.trim(), Selectedvalues.trim());
        System.debug('***'+questionAnswerMap);
        Selectedvalues=Null;
    }
    
    public pageReference submitAnswers(){
        List<rie__Registrant_Answer__c> existingRegAnswersList = new List<rie__Registrant_Answer__c>([Select id, rie__Question__c,
                                                                                                     rie__Answer__c, rie__Registration__c
                                                                                                     from rie__Registrant_Answer__c
                                                                                                     where rie__Registration__c =: regObj.Id]);
        Map<String, rie__Registrant_Answer__c> existingRegAnswersMap = new Map<String, rie__Registrant_Answer__c>();
        if(existingRegAnswersList != Null && existingRegAnswersList.size() > 0){
            for(rie__Registrant_Answer__c regAnswers : existingRegAnswersList){
                existingRegAnswersMap.put(regAnswers.rie__Question__c, regAnswers);
            }
        }
        system.debug('questionAnswerMap---->'+questionAnswerMap);
        List<rie__Registrant_Answer__c> regAnswerList = new List<rie__Registrant_Answer__c>();
        if(questionAnswerMap != Null && questionAnswerMap.size() > 0){
            for(String question : questionAnswerMap.keySet()){
                if(question != Null && question != 'None' &&
                   questionAnswerMap.get(question) != Null && 
                   questionAnswerMap.get(question) != 'None'){
                       if(existingRegAnswersMap != Null && 
                          existingRegAnswersMap.size() > 0 && 
                          existingRegAnswersMap.containsKey(question)){
                              rie__Registrant_Answer__c regAnswer = new rie__Registrant_Answer__c(Id = existingRegAnswersMap.get(question).Id);
                              regAnswer.rie__Question__c = questionsSet.get(question).Id;
                              regAnswer.rie__Answer__c = questionAnswerMap.get(question);
                              regAnswer.rie__Registration__c = regObj.Id;
                              regAnswerList.add(regAnswer); 
                          }else{
                              rie__Registrant_Answer__c regAnswer = new rie__Registrant_Answer__c();
                              regAnswer.rie__Question__c = questionsSet.get(question).Id;
                              regAnswer.rie__Answer__c = questionAnswerMap.get(question);
                              regAnswer.rie__Registration__c = regObj.Id;
                              regAnswerList.add(regAnswer);  
                          }
                       
                       
                   }
            }
        }
        if(regAnswerList != Null && regAnswerList.size() > 0){
            insert regAnswerList;
        }
        Selectedvalues=Null;
        PageReference cancel = sctrl.cancel(); 
        return cancel;
    }
    
    public pageReference cancel(){
       PageReference cancel = sctrl.cancel(); 
       return cancel; 
    }
}

Test class is given below:-
@istest
private class MatchMakingControllerTest {
   
    Static testmethod void MatchMakingMethod(){
           String txt = 'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG';
         rie__Event__c evt = new rie__Event__c();
        evt.rie__Event_Time_Zone__c = '(GMT-07:00) Pacific Daylight Time (America/Los_Angeles)';
        insert evt;
        
        rie__Registration__c attendee = new rie__Registration__c();
        attendee.rie__BatchProcessedForMatchMaking__c = false;
        attendee.rie__Event__c = evt.id;
        insert attendee;
        
        rie__Question__c qus = new rie__Question__c();
        qus.rie__Question__c  = 'Are you looking for a Solution?';
        qus.rie__Answers__c = 'ans,yes';
        insert qus;
        
        rie__Registrant_Answer__c regAns =  new rie__Registrant_Answer__c();
        regAns.rie__Question__c = qus.id;
        regAns.rie__Registration__c =  attendee.id;
        regAns.rie__Answer__c = 'yes';
        insert regAns;
        
        test.startTest();
        PageReference pageRef  = Page.MatchMakingQuestions; 
        pageRef.getParameters().put('Id', regAns.id);
        Test.setCurrentPage(pageRef);
        Registration__c reg = new Registration__c();
        Apexpages.StandardController sc = new Apexpages.standardController(reg);
        
        // Instantiate the extension
        MatchMakingController ext = new MatchMakingController(sc);
        ext.answeredQuestion = txt;
        //ext.populateAnswers();
        PageReference testPageResults = ext.cancel();
        PageReference testPageResult = ext.getQuestionsList();
        PageReference testPageRe = ext.submitAnswers();
        test.stoptest();
        
    }
}
how can I cover bold lines in my test class?
Can anyone help me with this?
​​​​​​​
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.