• Soyab Hussain
  • NEWBIE
  • 425 Points
  • Member since 2019


  • Chatter
    Feed
  • 14
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 2
    Questions
  • 51
    Replies
trigger CaseHandlerCountAlert on Case (after insert) {
 	
    //Case trigger that will send email alert when 8 cases are created within 7 days.
    
    String messageToSend;
    List <String> ListOfMessages = new List <String>();
    Set <Id> AcctIds = new Set <Id>();
    String messageBody;

    List < AggregateResult > AggregateResultList = [SELECT AccountId, Account.Name name, COUNT(Id) co
        FROM Case
        WHERE CreatedDate = LAST_N_DAYS:7 AND Id IN :Trigger.New
        GROUP BY AccountId, Account.Name
        HAVING COUNT(Id) >= 8
    ];

    Map < Id, String > accountIdEmailmessageMap = new Map < Id, String > ();

    for (AggregateResult aggr: AggregateResultList) {
        String messageToSend = 'Account name: ' + aggr.get('name') +
            ' has ' + (Integer) aggr.get('co') +
            ' cases opened in the last 8 days.';
        Id accId = (Id) aggr.get('AccountId');
        accountIdEmailmessageMap.put(accId, messageToSend);
        AcctIds.add(accId);
    }


    List < Case > caseList = [SELECT Id, AccountId, Account.Name, Parent_Project_if_applicable__r.Implementation_status__c,
        Parent_Project_if_applicable__r.PM_Implementation_Status__c,
        Parent_Project_if_applicable__r.RCM_Implementation_Status__c,
        Parent_Project_if_applicable__r.Resource_Coordinator_Email__c,
        Parent_Project_if_applicable__r.Client_Advisor_Email__c                      
        FROM Case
        WHERE AccountId IN: AcctIds];
    
	List<Messaging.SingleEmailMessage> lstASingleEmailMessage = new List<Messaging.SingleEmailMessage>();
    List<Messaging.SingleEmailMessage> lstBSingleEmailMessage = new List<Messaging.SingleEmailMessage>();

    for (Case cl: caseList) {

        if (cl.Parent_Project_if_applicable__r.Implementation_status__c == 'Live - Closed Project' ||
            cl.Parent_Project_if_applicable__r.PM_Implementation_Status__c == 'Live - Closed Project' ||
            cl.Parent_Project_If_Applicable__r.RCM_Implementation_Status__c == 'Live - Closed Project') {
         
            String messageBody = accountIdEmailmessageMap.get(cl.AccountId);
                
                List<String> emailaddr = new List<String>();
                emailaddr.add('CustomerSuccessManagers@test.com');
                
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setSenderDisplayName('Support');
            mail.setToAddresses(emailaddr);   
            mail.Subject = 'Multiple cases created alert message';
            mail.setPlainTextBody(messageBody);
			lstASingleEmailMessage.add(mail);
                
       }     

    }
           Messaging.SendEmailResult[] r = Messaging.sendEmail(lstASingleEmailMessage);


    else{
            String messageBody = accountIdEmailmessageMap.get(cl.AccountId);		
            
			List<String> emailAdds = new List<String>();
            emailAdds.add(cl.Parent_Project_if_applicable__r.Resource_Coordinator_Email__c);
            emailAdds.add(cl.Parent_Project_if_applicable__r.Client_Advisor_Email__c);
            
            Messaging.SingleEmailMessage amail = new Messaging.SingleEmailMessage();
            amail.SetSenderDisplayName('Support');
            amail.setToAddresses(emailAdds);
            amail.Subject = 'Multiple cases created alert message';
            amail.setPlainTextBody(messageBody);
			lstBSingleEmailMessage.add(amail);

        }		
           
                Messaging.SendEmailResult[] r = Messaging.sendEmail(lstBSingleEmailMessage);
     
}

In an effort to keep both email SendEmail methods out side of a `For-Loop`, I have mixed up my {}.  Any help is appreciated.

 
Hello,
Contacts are created by users which has a multi select picklist to capture candidates skillset. 
Job records are created by users which has a multi select picklist to capture what skill set is needed. 
Requirement: Whenever a job record is created, based on what skill set is needed the system needs to find the corresponding contacts (candidates) matching atleast 1 skillset and email them job record. 
trigger JobTrigger on Job__c (after insert) {
    
    Set<String> SkillCode = new Set<String>();
    
    // when a new job is posted, based on Skill_Code__c on job record, get matching contact records based on Candi_Skill_Codes__c
    for (Job__c J : Trigger.new) {
        
        // Skill_Code__c is a multi select picklist value
        if (J.Skill_Code__c != null) {
            
            List<String> JobOrderSkillCode = J.Skill_Code__c.split(';');
            SkillCode.addAll(JobOrderSkillCode);

        }
    }

    //Candi_Skill_Codes__c is a multi select picklist value
    for (Contact C : [SELECT Id, Alert__c, Candi_Skill_Codes__c FROM Contact WHERE Candi_Skill_Codes__c INCLUDES (:SkillCode) AND Alert__c = 'Yes']) {
        // Above query returning 0 results
        // If i change the query to something like, 
        // SELECT Id, Alert__c, Candi_Skill_Codes__c FROM Contact WHERE Candi_Skill_Codes__c INCLUDES ('sfdc', 'developer') AND Alert__c = 'Yes'
        // This query returned 2 results
        // I understand bind variables cannot be used with INCLUDES but i also don't know how to proceed in this scenario, please help
        
    }
    
    //Send an email to matched contacts

}
Hi guys,

I want to send an email notification to users based on two field criterias. These are:
1. the payment method = Barter 
2. the payment amount field has been updated

I have created a custom field to capture the previous amount value when that field has been changed and I have built a workflow rule with a field update for this.

AND(
              ISCHANGED( Payment_Amount__c ),

              NOT(ISBLANK(TEXT(Payment_Amount__c)))
             )
Lightning Component  - 
<aura:component implements="flexipage:availableForAllPageTypes, force:hasRecordId" access="global" controller="addBooks">
    <aura:attribute name="bookToAdd" type="Books__c" />
    <aura:attribute name="authId" type="String" />
    
    <div class="Styling">
        <lightning:card title="Quick register Books">
            
            <lightning:input label = "Book Name : " value="{!v.bookToAdd.Name}" required="true" />
            <lightning:input label = "Book Price : " value="{!v.bookToAdd.Price__c}" required="true" />
            <lightning:button variant="brand" label="Add books" title="Add books" onclick="{! c.addBooks }"/>
        </lightning:card>
    </div>
</aura:component>

JS - 
({
    addBooks : function(component, event, helper) {
        var action = component.get('c.addbooks');
        component.set('v.authId',v.recordId);
        console.log('v.recordId***',v.recordId);
        action.setParams({
            b : component.get('v.bookToAdd'),
            authId : component.get('v.authId')
        });
        action.setCallback(this, function(response){
            
        },'ALL');
        $A.enqueueAction(action);
    }
})

Controller - 
public class addBooks {
    @AuraEnabled
    public static void addbooks(Books__c b, Id authId){
        if((b.Name != NULL ||b.Name !='') && (b.Price__c >0)){
            b.Author__c=authId;
            insert b;
        }
    }
}

I get the following error when I try to enter input -

Error
Hi,
User-added imageI want an action that, when i will click ine of those link then my input box with that name.


im giving my codes..
Component:
<aura:attribute name="String" type="String[]"/>
    
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<lightning:card title="Filtered Values">
<div class="search-field">
<lightning:input aura:id="nameFilter" label="Filter names" onchange="{!c.handleNameFilterChange}" />
</div>
    <!--
<div class="results">
<aura:if isTrue="{!v.contacts.length > 0}">
<p class="has-results">
Showing {!v.contacts.length} contact(s):
</p>
<ol class="slds-list_dotted">
-->
   
    <ol>
        
<aura:iteration items="{!v.String}" var="s">
<li>
<a id="getId" onclick="{!c.handleClick}">
{!s}
</a> 
</li>
       
</aura:iteration>
                                       
    </ol></lightning:card></aura:component>


controller
({
init: function(component, event, helper) {
helper.loadList(component);
},

handleNameFilterChange: function (component, event, helper) {
helper.loadList(component);
},

})

helper
 
({
loadList: function(component) {
var action = component.get("c.allContacts");
var nameFilterString = component.find("nameFilter").get("v.value");
action.setParams({
nameFilterString: nameFilterString
});
action.setCallback(this, function(a) {
component.set("v.String", a.getReturnValue());
});
$A.enqueueAction(action); 
}
})
thanks,
​​​​​​​
HI, 
I am trying to call my method in the anonymous window but it is showing me (Line: 1, Column: 24 Unexpected token '('.) this error. The class is static so it is not necessary to make an object or instance of that class..
AccountContact.onBefore(Account Name='asdf');
This is my code i am inserting an account with the account name
Suppose there is an inputfield/picklist field.........i want to populate an output textbox with the value of input field or value selected in picklist.
how to do this?
as im not a coder, can someone help me writing a test class for this class :
public class NumberTOWordConvertion {

    // Call this method with Number to convert
    public String getNumberTOWordConvertion(Decimal num) {

        Decimal junkVal = num;
        Decimal junkValFiles = junkVal - Math.floor(junkVal);
        junkVal = Math.floor(junkVal);

        String obStr = junkVal.toPlainString();
        String[] numReversed = obStr.split('');
        String[] actnumber = reverse(numReversed);
        String firstHalf = convertInWords(numReversed, actnumber);

        Integer tmp = Math.round(junkValFiles * 100);
        junkValFiles = (Decimal)tmp / 100; System.debug('jj :' + junkValFiles);
        String paisaStr = junkValFiles.toPlainString();
        String secondHalf;
        if (paisaStr == '0') {
            secondHalf = '';
        } else if (paisaStr.length() != 4) {
            paisaStr = paisaStr + '0';
            paisaStr = paisaStr.substring(2);
            String [] numReversedFiles = paisaStr.split('');
            String[] actnumberFiles = reverse(numReversedFiles);
            secondHalf = convertInWords(numReversedFiles, actnumberFiles);
        } else {
            paisaStr = paisaStr.substring(2);
            String [] numReversedFiles = paisaStr.split('');
            String[] actnumberFiles = reverse(numReversedFiles);
            secondHalf = convertInWords(numReversedFiles, actnumberFiles);
        }

        String SumOFHalves = '';

        if (secondHalf.length() > 4) {
            firstHalf = firstHalf.replace('Only', 'JDs And ');
            secondHalf = secondHalf.replace('Only', 'Files Only');
            SumOFHalves = firstHalf + secondHalf;
        } else {
            firstHalf = firstHalf.replace('Only', 'JDs Only');
            SumOFHalves = firstHalf;
        }

        // IF amount has any value
        if (SumOFHalves.length() > 5) {
            return SumOFHalves;
        } else {
            return '';
        }
    }
    // Method reverse the number
    public List<String> reverse(List<String> strToRev) {
        List<String> revList = new List<String>();
        for (Integer i = strToRev.size() - 1; i >= 0; i--) {
            revList.add(strToRev.get(i));
        }
        revList.add('');
        return revList;
    }

    public String convertInWords(String[] numRev, String[] actnum) {
        List<String> iWords = new List<String> {'Zero', ' One', ' Two', ' Three', ' Four', ' Five', ' Six', ' Seven', ' Eight', ' Nine'};
        List<String> ePlace = new List<String> {' Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', ' Nineteen'};
        List<String> tensPlace = new List<String> {'dummy', ' Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety' };

        Integer iWordsLength = numRev.size();
        String totalWords = '';
        List<String> inWords = new List<String>();
        for (Integer k = 0; k < iWordsLength; k++) {
            inWords.add('');
        }
        String finalWord = '';
        Integer j = 0;

        // Main For loop
        for (Integer i = 0; i < iWordsLength; i++) {

            if (i == 0) {
                if (actnum[i] == '0' || actnum[i + 1] == '1') {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                inWords[j] = inWords[j] + ' Only';
            } else if (i == 1) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }
            } else if (i == 2) {
                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i - 1] != '0' && actnum[i - 2] != '0') {
                    inWords[j] = iWords[Integer.valueof(actnum[i])] + ' Hundred and';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])] + ' Hundred';
                }
            } else if (i == 3) {
                if (actnum[i] == '0' || actnum[i + 1] == '1') {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                if (actnum[i + 1] != '0' || Integer.valueof(actnum[i]) > 0) {
                    inWords[j] = inWords[j] + ' Thousand';
                }
            } else if (i == 4) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }

            } else if (i == 5) {
                if (actnum[i] == '0' || actnum[i + 1] == '1') {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                if (actnum[i + 1] != '0' || Integer.valueof(actnum[i]) > 0) {
                    inWords[j] = inWords[j] + ' Lakh';
                }
            } else if (i == 6) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }

            } else if (i == 7) {
                if (actnum[i] == '0' || actnum[i + 1] == '1' ) {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                inWords[j] = inWords[j] + ' Crore';
            } else if (i == 8) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }

            }

            j++;
        }
        // End of For loop

        // Reverse the List
        inWords = reverse(inWords);

        for (Integer i = 0; i < inWords.size(); i++) {
            finalWord += inWords[i];
        }

        return finalWord;
    }


}

thnx in advance
Hi. Can you please keep below trigger into helper class.
 
trigger InvoiceSum on Invoice_Items__c (after insert, after delete, after undelete, after update) {
    set<Id> invIdSet = new set<Id>();
    
    if(trigger.isinsert || trigger.isUpdate || trigger.Isundelete){
        for(Invoice_Items__c invItem: Trigger.new){
			if(Trigger.isInsert || Trigger.isUndelete || (invItem.Amount__c != Trigger.oldMap.get(invItem.Id).Amount__c || invItem.InvoiceFK__c != Trigger.oldMap.get(invItem.Id).InvoiceFK__c))
				invIdSet.add(invItem.InvoiceFK__c);            
        }
    }    
    if(trigger.isUpdate || trigger.isDelete) {
        for(Invoice_Items__c invItem: Trigger.old){
            if(Trigger.isDelete || (invItem.Amount__c != Trigger.newMap.get(invItem.Id).Amount__c || invItem.InvoiceFK__c != Trigger.newMap.get(invItem.Id).InvoiceFK__c))
				invIdSet.add(invItem.InvoiceFK__c);
        }
    }       
    List<Invoice__c> invList = [select id, Ammount__c, (Select Id, Amount__c from Invoice_Items__r) from Invoice__c Where ID IN: invIdSet];    
    for(Invoice__c inv : invList){
        
        inv.Ammount__c = 0;
        for(Invoice_Items__c invItem : inv.Invoice_Items__r) {
			inv.Ammount__c += invItem.Amount__c;
        }
    }
    update invList;
}

​​​​​​​
public class testclass5 {
 public list<wrapperclass> wrapclass{get;set;}
   public  testclass5(){
    wrapclass = new list<wrapperclass>();
    string  teststring= ' { "sucess":1,"data": [ {"stateName": "Andrapradesh",  "value": "apx" }, { "stateName": "Telangana",  "value":"tsx"}, {"stateName": "Banglore",  "value": "bngx"} , {"stateName": "Maharastra",  "value":"mhx" }  ] } ';

     Map<String, Object> maptest =   (Map<String, Object>) JSON.deserializeUntyped(teststring);
     
     system.debug(maptest); 
     
      Object ob = (Object)maptest.get('data');    
        System.debug(ob);
          
         String srlze  = System.JSON.serialize(ob); 
      system.debug(srlze);
       
   wrapclass  = (list<wrapperclass>)System.JSON.deserialize(srlze,list<wrapperclass>.class);
   system.debug(wrapclass);
  
  }
  
 public string selectedValue{get;set;}
 
   public pageReference testmethod1(){
    
     system.debug('for Datatable functionality:'+ selectedValue);
     return null;
   
   }
 
 public pageReference testmethod2(){
    
     system.debug('for repeat functionality:'+ selectedValue);
     return null;
   
   }
 

   public class wrapperclass{
   
    public string stateName{get;set;}
    
     public string  value{get;set;}
    
   }
   
   
 
}


Visualforce page:
 
<apex:page controller="testclass5">
 
  <apex:form >
    <apex:dataTable value="{!wrapclass}" var="a" cellpadding="6px">
    
    <apex:column > 
         <apex:actionsupport action="{!testmethod1}" event="onclick">
         {!a.stateName}<apex:param name="selectedValue" value="{!a.value}" assignTo="{!selectedValue}">
          </apex:param>
          </apex:actionsupport>
       </apex:column>
     
    </apex:dataTable>
    
    <br/>
    
      <apex:actionsupport action="{!testmethod2}" event="onclick">
    <apex:repeat value="{!wrapclass}" var="a" >
      <li style="padding:5px;"> 
    
         {!a.stateName}<apex:param name="selectedValue" value="{!a.value}" assignTo="{!selectedValue}">
          </apex:param>
          
      </li>
    </apex:repeat>
    
  </apex:actionsupport>
     
  
  
  </apex:form>
  
</apex:page>


after debugging iam getting the selectedvalue,as  null.., can anybody help to solve the issue. thank you... 
Hi All,
I am getting following error in javascript. Please help me with this error.
 
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}   
 
var newRecords = [];   
 
var coapp = new sforce.SObject("Lead");  
coapp.id ="{!Lead.Id}"; 
coapp.Name="{!Lead.Name}" 
coapp.Rating="Hot";             
 
newRecords.push(coapp); 
result = sforce.connection.update(newRecords); 
window.location.reload();

Error: The Name field is required.

Thanks in Advance
I am new to LWC and cant seem to figure out how to open the source code for LWC. Aura can be opened in the dev console but from what i understand this is not possible with LWC.

Is it possible to open a LWC source code from within the org? I have a LWC that was developed by someone else that needs editing. How can I access the source code?
Hi All

I'm trying to access field values from an object related to the initial one in the call. Our relationship is as follows:

Contact --> Post Fulfillment --> Post

I am trying to use an iteration to get values from Post when the initial call is to Contact. See code below:

Apex:
@AuraEnabled
    public static List<Contact> getHSList(){
        List<Contact> myHSList = new List<Contact>();
        myHSList = [Select Id, 
                    Name, 
                    Fire_Warden__c,
                    Phone,
                    (SELECT id, Post__c,Post__r.Area__c, Post__r.Floor__c, Post__r.Section__c
                     FROM Contact.Post_Fulfillments__r)
                    From Contact
                    Where Fire_Warden__c = true];
        return myHSList;
    }
Controller
({
    onInit : function(component, event, helper) {
        
        console.log('onInit');
        
        var action = component.get("c.getHSList");
        
        action.setCallback(this, function(a) {
            
            var HandSData = a.getReturnValue();
            console.log(HandSData);
            component.set("v.contactList",HandSData);
            console.log(HandSData.length);
            
        });
        $A.enqueueAction(action);
    }
    
})
Component
<aura:Iteration items="{!v.contactList}" var="con" >
                <tr class="slds-hint-parent">
                    <th data-label="Name" scope="row">
                        <div class="slds-truncate" title="Cloudhub">{!con.Name}</div>
                    </th>
                    <td data-label="Phone">
                        <div class="slds-truncate" title="Cloudhub">{!con.Phone}</div>
                    </td>
                    <td data-label="Close Date">
                        <div class="slds-truncate" title="4/14/2015">{!con.Post_Fulfillments__r.Post__r.Floor__c} place</div>
                    </td>
                </tr>
            </aura:Iteration>

I am able to access both Name and Phone from the contact. I can also see from the Chrome inspector that the field values for Location are coming through, I just cannot access them. 

As you can see i have tried 
{!con.Post_Fulfillments__r.Post__r.Floor__c}
But it doesnt seem to work.

Any help would be great.

Thanks

Tom 


 
I am trying to write a trigger for acount field update when coresponding contact field in updated. Please help me here the code is not saving 

Trigger FieldupdateOnAccount on Contact(after insert, after update){
set<id> conset = new set<id>();
for(Contact c: trigger.new){
conset.add(c.id);
}
list<Account> Lstacc = [select Name, Phone(select Name, Phone from Contacts) from Account where Contactid in: conset];
List<Account> Acclist = new List<Account>();
if(Lstacc.size()>0 && Trigger.newMap.get(Id).Phone != Trigger.oldMap.get(Id).Phone){
for(Account acc :Lstacc){
for(Contact c: acc.Contacts){

acc.Phone = c.Phone;
Acclist.add(acc);
}
}
Update Acclist;
}
}
I have one external Id auto number field in opportunity object.
I am able to perform a global search in a sandbox on this field but the global search functionality is not working in production for this field only.
And I have system administer rights.
where salesforce store lightning web components. like we have apexclass object for all sobject and auradefinationbundle for aura components.
I need help in writing a trigger, I have two objects

1) Opportunity
2) Opportunity_ Program__c

both are having lookup relationship, Opportunity is Parent and Opportunity Program is child.

Opportunity program has Status field.

I need to write a trigger on Opportunity Program object, for a given Opportunity if any of the child records contains status as "MATR" then Opportunity.StageName = 'Closed Won', if any of the child record for a given opportunity does not contain "MATR" then Opportunity.StageName = 'Closed Lost'

Can anyone helps me out in this issue please.
Hi,

I am apex controller with the following method whose return type is again a different class. Below is my code:

@AuraEnabled
public static AccountPagerWrapper getData (Decimal pageNumber ,Integer recordToDisply)
    {
        Integer pageSize = recordToDisply;
        Integer offset = ((Integer)pageNumber - 1) * pageSize;
        
        String queryCount = 'SELECT count() FROM Account';
        
        String finalQuery = 'dynamic query';
        List<Account> returnList = new List<Account>();
        returnList = database.query(finalQuery);       
        
        AccountPagerWrapper obj =  new AccountPagerWrapper();
        obj.pageSize = pageSize;
        obj.page = (Integer) pageNumber;
        
        obj.total =  database.countQuery(queryCount);  
        obj.accounts = returnList;
        return obj;
    }

public class AccountPagerWrapper {
    @AuraEnabled public Integer pageSize {get;set;}
    @AuraEnabled public Integer page {get;set;}
    @AuraEnabled public Integer total {get;set;}
    @AuraEnabled public List<Account> accounts {get;set;}
   }

Can anyone tell how to assign the dynamic query results in accounts property of the AccountPagerWrapper. Line is marked with bold.

I am simply assigning the dynamic query results in the property but it is throwing an error while binding it with the table.
trigger CaseHandlerCountAlert on Case (after insert) {
 	
    //Case trigger that will send email alert when 8 cases are created within 7 days.
    
    String messageToSend;
    List <String> ListOfMessages = new List <String>();
    Set <Id> AcctIds = new Set <Id>();
    String messageBody;

    List < AggregateResult > AggregateResultList = [SELECT AccountId, Account.Name name, COUNT(Id) co
        FROM Case
        WHERE CreatedDate = LAST_N_DAYS:7 AND Id IN :Trigger.New
        GROUP BY AccountId, Account.Name
        HAVING COUNT(Id) >= 8
    ];

    Map < Id, String > accountIdEmailmessageMap = new Map < Id, String > ();

    for (AggregateResult aggr: AggregateResultList) {
        String messageToSend = 'Account name: ' + aggr.get('name') +
            ' has ' + (Integer) aggr.get('co') +
            ' cases opened in the last 8 days.';
        Id accId = (Id) aggr.get('AccountId');
        accountIdEmailmessageMap.put(accId, messageToSend);
        AcctIds.add(accId);
    }


    List < Case > caseList = [SELECT Id, AccountId, Account.Name, Parent_Project_if_applicable__r.Implementation_status__c,
        Parent_Project_if_applicable__r.PM_Implementation_Status__c,
        Parent_Project_if_applicable__r.RCM_Implementation_Status__c,
        Parent_Project_if_applicable__r.Resource_Coordinator_Email__c,
        Parent_Project_if_applicable__r.Client_Advisor_Email__c                      
        FROM Case
        WHERE AccountId IN: AcctIds];
    
	List<Messaging.SingleEmailMessage> lstASingleEmailMessage = new List<Messaging.SingleEmailMessage>();
    List<Messaging.SingleEmailMessage> lstBSingleEmailMessage = new List<Messaging.SingleEmailMessage>();

    for (Case cl: caseList) {

        if (cl.Parent_Project_if_applicable__r.Implementation_status__c == 'Live - Closed Project' ||
            cl.Parent_Project_if_applicable__r.PM_Implementation_Status__c == 'Live - Closed Project' ||
            cl.Parent_Project_If_Applicable__r.RCM_Implementation_Status__c == 'Live - Closed Project') {
         
            String messageBody = accountIdEmailmessageMap.get(cl.AccountId);
                
                List<String> emailaddr = new List<String>();
                emailaddr.add('CustomerSuccessManagers@test.com');
                
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setSenderDisplayName('Support');
            mail.setToAddresses(emailaddr);   
            mail.Subject = 'Multiple cases created alert message';
            mail.setPlainTextBody(messageBody);
			lstASingleEmailMessage.add(mail);
                
       }     

    }
           Messaging.SendEmailResult[] r = Messaging.sendEmail(lstASingleEmailMessage);


    else{
            String messageBody = accountIdEmailmessageMap.get(cl.AccountId);		
            
			List<String> emailAdds = new List<String>();
            emailAdds.add(cl.Parent_Project_if_applicable__r.Resource_Coordinator_Email__c);
            emailAdds.add(cl.Parent_Project_if_applicable__r.Client_Advisor_Email__c);
            
            Messaging.SingleEmailMessage amail = new Messaging.SingleEmailMessage();
            amail.SetSenderDisplayName('Support');
            amail.setToAddresses(emailAdds);
            amail.Subject = 'Multiple cases created alert message';
            amail.setPlainTextBody(messageBody);
			lstBSingleEmailMessage.add(amail);

        }		
           
                Messaging.SendEmailResult[] r = Messaging.sendEmail(lstBSingleEmailMessage);
     
}

In an effort to keep both email SendEmail methods out side of a `For-Loop`, I have mixed up my {}.  Any help is appreciated.

 
When i execute this code getting below error , pls check and let me know if i did anything wrong in my code below  :
Error Occurred: An Apex error occurred: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]
I verified, Email address already exists for 'Approver_email__c' ...But not sure , why this error coming ....any ideas and let me know is anything wrong on my code 
******************************************************************
    public class EmailNotification {
    public string toAddress{get;set;}
    public string message{get;set;}
@InvocableMethod  
        public static void sendingEmail(){
       Level_Agreement__c sla = new Level_Agreement__c();  
        Case c = new Case();    
          if(c.Task_Category__c == sla.Task_Category__c) 
          {
           Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();     
            String[] toAddresses =new List<String>{sla.Approver_email__c};
            semail.setToAddresses(toAddresses);
           semail.setSubject('Testing email through apex');
           semail.setBccSender(false);
           semail.setUseSignature(true);
           semail.setPlainTextBody('Dear User, Request for Process Reviewer notification mail ');   
           Messaging.sendEmail(new Messaging.SingleEmailMessage[] { semail });   
              
          }
          
           }        
      
   
    }
 pls let me know if i did any wrong in the code .......Thanks 
Sekhar
Hello,
Contacts are created by users which has a multi select picklist to capture candidates skillset. 
Job records are created by users which has a multi select picklist to capture what skill set is needed. 
Requirement: Whenever a job record is created, based on what skill set is needed the system needs to find the corresponding contacts (candidates) matching atleast 1 skillset and email them job record. 
trigger JobTrigger on Job__c (after insert) {
    
    Set<String> SkillCode = new Set<String>();
    
    // when a new job is posted, based on Skill_Code__c on job record, get matching contact records based on Candi_Skill_Codes__c
    for (Job__c J : Trigger.new) {
        
        // Skill_Code__c is a multi select picklist value
        if (J.Skill_Code__c != null) {
            
            List<String> JobOrderSkillCode = J.Skill_Code__c.split(';');
            SkillCode.addAll(JobOrderSkillCode);

        }
    }

    //Candi_Skill_Codes__c is a multi select picklist value
    for (Contact C : [SELECT Id, Alert__c, Candi_Skill_Codes__c FROM Contact WHERE Candi_Skill_Codes__c INCLUDES (:SkillCode) AND Alert__c = 'Yes']) {
        // Above query returning 0 results
        // If i change the query to something like, 
        // SELECT Id, Alert__c, Candi_Skill_Codes__c FROM Contact WHERE Candi_Skill_Codes__c INCLUDES ('sfdc', 'developer') AND Alert__c = 'Yes'
        // This query returned 2 results
        // I understand bind variables cannot be used with INCLUDES but i also don't know how to proceed in this scenario, please help
        
    }
    
    //Send an email to matched contacts

}
Hi,

I am trying to call a Static method from Custom Button but getting the error " missing ) after argument List. Can somebody guide me how I can recitfy the same 

Here is my Apex code :
global class ProductGroupFamilyAddOrderTarget {
    
    webservice static void addOrderTarget(){
        List<Sales_Target__c> newSalesTarget = new List<Sales_Target__c>();
        
        List<Product_Group__c> productGrpFamilywithSeries =[SELECT Id,Name,Short_Name__c,
                                                            (SELECT Id,Parent__c,Short_Name__c FROM Children_Groups__r WHERE Group_Level__c='Series' AND isActive__c = True ) 
                                                            FROM Product_Group__c WHERE Group_Level__c='Family'AND isActive__c = True];
        
        SFDC_Fiscal_Year__c currentFiscalYear = [SELECT Id,Name FROM SFDC_Fiscal_Year__c WHERE Current__c= true];
        List<Region__c> region = [SELECT Id FROM Region__c WHERE Is_Active__c = true AND isRegion__c = true];
        List<Sales_Target__c> existOrderTarget =[SELECT Id,Product_Group__c,Region__c,SFDC_Fiscal_Year__c FROM Sales_Target__c WHERE Region__c IN :region AND SFDC_Fiscal_Year__c =: currentFiscalYear.Id];
        Map<String,Id> TargetOrder = new Map<String,Id>();
        if(existOrderTarget !=null && !existOrderTarget.isEmpty()){
            for(Sales_Target__c st : existOrderTarget){
                TargetOrder.put(String.valueOf(st.Product_Group__c)+String.valueOf(st.Region__c),st.Id);
            }
            
        }
        System.debug('Is there any Target Group Created by Error '+TargetOrder.values());
        if(productGrpFamilywithSeries != null && !productGrpFamilywithSeries.isEmpty()){
            for(Product_Group__c prdGrp : productGrpFamilywithSeries){
                if(prdGrp.Children_Groups__r !=null && !prdGrp.Children_Groups__r.isEmpty()){
                    for(Product_Group__c prdGrpChild : prdGrp.Children_Groups__r){
                        if(region !=null && !region.isEmpty()){
                            for(Region__c r : region){
                                if(!TargetOrder.containsKey(String.valueOf(prdGrpChild.id)+String.valueOf(r.Id))){
                                    Sales_Target__c newOrderTarget = new Sales_Target__c();
                                    newOrderTarget.Name = 'Newtarget2020';
                                    newOrderTarget.Target_Type__c ='Product Group';
                                    newOrderTarget.Product_Group__c = prdGrpChild.Id;
                                    newOrderTarget.Region__c = r.Id;
                                    newOrderTarget.SFDC_Fiscal_Year__c = currentFiscalYear.Id;
                                    newSalesTarget.add(newOrderTarget);
                                }
                            }
                        }
                    }
                }
            }
        }
        
        if(newSalesTarget !=null && !newSalesTarget.isEmpty()) insert newSalesTarget;
    }
    
}


And My Custom Button 

{!REQUIRESCRIPT("/soap/ajax/47.0/connection.js")}{!REQUIRESCRIPT("/soap/ajax/47.0/apex.js")}

var result = sforce.apex.execute("ProductGroupFamilyAddOrderTarget","addOrderTarget",{});
alert(result);
Hi All , 

I have a requirement where in
The contact record has a custom field as member ID (123456) and there is one more custom object lets say 'xyz' which has the same member ID field but it starts with 'A' (A123456) and rest is same.

Based on this member id I need to fetch fields from xyz and store them on the contact record having the same member id
Dear Team ,

Greetings !!!

How can i use Lightning group radio button in Component file of Lightning component . How can i bind radio button with piclist in custom object .
<aura:component controller="BISPController">
	        <aura:attribute name="NewCon" 

            type="Questions__c"

            default="{ 'sobjectType': 'Questions__c',

                     
                     
                     'Does_Lightning_Component_uses_Javascript__c	' : '',
                     
                     'Which_file_not_part_of_lightning_comp__c' : '',}" />
    
      <form>
                 <div class="slds-form-element">
          <div class="slds-form-element__control">
              <label class="slds-form-element__label" for="form-element-01">Does Lightning Component uses Javascript</label>
            <div style="background-color:white; height:33px; border:solid; border-color:rgb(217,219,221); border-radius:4px;">
                  <force:inputField value="{!v.NewCon.Does_Lightning_Component_uses_Javascript__c}" class="form-control" />
              </div>
               
    </div>
  </div>  
          
          <div class="slds-form-element">
          <div class="slds-form-element__control">
              <label class="slds-form-element__label" for="form-element-01">Which file not part of lightning comp</label>
            <div style="background-color:white; height:33px; border:solid; border-color:rgb(217,219,221); border-radius:4px;">
                  <force:inputField value="{!v.NewCon.Which_file_not_part_of_lightning_comp__c}" class="form-control" />
              </div>
               
    </div>
  </div>      
          
          <div>
                          <ui:button label="Save" press="{!c.save}"/>
          </div>
           </form>
    
</aura:component>

 
I need to send an email to one of two Public Groups depending on the value of the 3 fields in the `If Statement`. Within the the If and Else blocks I have a `String mailGroup` with the value of the Public Class.Now that I need the Else statement to access that private class with a different Public class name, I am having issues inserting `String mailGroup` , into the Private class `getAddresses()`. The Variable `emailAdds` declared at the top holds the email address values from the `getAddresses()` function. Is it my syntax? I am receiving numerous errors:

`Unexpected token 'private'`
 `Unexpected token '<'`
`Unexpected token '>'`

`Method does not exist or incorrect signature: void getAddresses(String) from type CaseHandlerCountAlert`

 
trigger CaseHandlerCountAlert on Case (after insert) {
    
 				String messageToSend;
   				List<String> ListOfMessages = new List<String>();
   		     	Set<Id> AcctIds = new Set<Id>();
				List<String> clientEmail;
				String messageBody;
    			String mailGroup;
    			List<String> emailAdds = getAddresses(mailGroup);
    
List<AggregateResult> AggregateResultList = [SELECT AccountId, Account.Name name, COUNT(Id) co
                                             FROM Case
                                             WHERE CreatedDate = LAST_N_DAYS:1 AND 
                                             Id IN :Trigger.New
                                             GROUP BY AccountId, Account.Name
                                             HAVING COUNT(Id)  >= 5 ];
    		 
            Map<Id, String> accountIdEmailmessageMap = new Map<Id, String>();
            
				for(AggregateResult aggr: AggregateResultList){
                String messageToSend = 'Account name: ' + aggr.get('name') +
                    ' has ' + (Integer)aggr.get('co') +
                    ' cases opened in the last 8 days.';
                Id accId = (Id)aggr.get('AccountId');
                accountIdEmailmessageMap.put(accId,messageToSend);
                AcctIds.add(accId); 
            }
            
			
List<Case> caseList = [SELECT Id, AccountId, Account.Name,Parent_Project_if_applicable__r.Implementation_status__c,
                       Parent_Project_if_applicable__r.PM_Implementation_Status__c, 
                       Parent_Project_if_applicable__r.RCM_Implementation_Status__c,
                       Parent_Project_if_applicable__r.Client_Advisor_Email__c
                       FROM Case
                       WHERE AccountId IN :AcctIds];

for(Case cl:caseList){ 
  
    if(cl.Parent_Project_if_applicable__r.Implementation_status__c == 'Live - Closed Project'||
       cl.Parent_Project_if_applicable__r.PM_Implementation_Status__c == 'Live - Closed Project'||
       cl.Parent_Project_If_Applicable__r.RCM_Implementation_Status__c == 'Live - Closed Project'){    
        	
           	
            mailGroup = 'Customer Success Managers'; 
           
	String messageBody = accountIdEmailmessageMap.get(cl.AccountId);
        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
	  mail.setSenderDisplayName('IT Support'); 
          mail.setToAddresses(emailAdds);
          mail.Subject = 'Multiple cases created alert message';
          mail.setPlainTextBody(messageBody);
           
         if(messageToSend != null){
          Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
          }
        
    }
    else{  
            
      			
         mailGroup = 'BI Team';
         
        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
	  mail.SetSenderDisplayName('IT Support');
          mail.setToAddresses(emailAdds);
          mail.Subject = 'Multiple cases created alert message';
          mail.setPlainTextBody(messageToSend);
      
        
        if(messageToSend != null){
          Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        }
    }
       
         
    }

    


private List<String> getAddresses(mailGroup){
    List<User> UserList =
        [SELECT id, name, email
         FROM User 
         WHERE id 
         IN (SELECT userorgroupid 
             FROM groupmember
             WHERE group.name = :mailGroup)];
    
    List<String> emailString = new List<String>();
    
    for(User u: UserList){
        emailstring.add(u.email);
    }   
    return (emailString);
    //System.debug(emailString);
}    

               }

 
Has anyone ran across this error when validating their components? SFDCAccessControllerTest is managed by Pardot... System.AssertException: Assertion Failed: Expected: false, Actual: true
Stack Trace: Class.SFDCAccessControllerTest.testAccessControl: line 53, column 1 
Hi, 
This is my trigger code:
    if(trigger.isAfter && trigger.isInsert){
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
        EmailTemplate emtemp = [SELECT Id from EmailTemplate WHERE Name = 'Email Notification'];
        System.debug('em temp'+emtemp);
        for (EM_Event_Team_Member_vod__c addedmem : Trigger.new) {
            
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            email.setTargetObjectId(addedmem.Team_Member_vod__c);
            email.setTemplateId(emtemp.Id);
            email.saveAsActivity = false;
            emails.add(email);
            
        }
        
        Messaging.sendEmail(emails);
    }
This is the email template:
<messaging:emailTemplate subject="Addition of Team Member" relatedToType="EM_Event_Team_Member_vod__c">
<messaging:HTMLEmailBody >
Hi {!relatedTo.Event_vod__r.Name},
<br/><br/>
Event Name: {!relatedTo.Event_vod__r.Name}<br/>
Event City: {!relatedTo.Event_vod__r.City_vod__c}<br/>
Event Start Time : {!relatedTo.Event_vod__r.Start_Time_vod__c}<br/>
Event URL :
<br/>
</messaging:HTMLEmailBody>
</messaging:emailTemplate>

And this is the email i received:
Hi ,

Event Name:
Event City:
Event Start Time :
Event URL :


Please help me how to get values populated in the email.
Thanks.
Hi guys,

I want to send an email notification to users based on two field criterias. These are:
1. the payment method = Barter 
2. the payment amount field has been updated

I have created a custom field to capture the previous amount value when that field has been changed and I have built a workflow rule with a field update for this.

AND(
              ISCHANGED( Payment_Amount__c ),

              NOT(ISBLANK(TEXT(Payment_Amount__c)))
             )
Lightning Component  - 
<aura:component implements="flexipage:availableForAllPageTypes, force:hasRecordId" access="global" controller="addBooks">
    <aura:attribute name="bookToAdd" type="Books__c" />
    <aura:attribute name="authId" type="String" />
    
    <div class="Styling">
        <lightning:card title="Quick register Books">
            
            <lightning:input label = "Book Name : " value="{!v.bookToAdd.Name}" required="true" />
            <lightning:input label = "Book Price : " value="{!v.bookToAdd.Price__c}" required="true" />
            <lightning:button variant="brand" label="Add books" title="Add books" onclick="{! c.addBooks }"/>
        </lightning:card>
    </div>
</aura:component>

JS - 
({
    addBooks : function(component, event, helper) {
        var action = component.get('c.addbooks');
        component.set('v.authId',v.recordId);
        console.log('v.recordId***',v.recordId);
        action.setParams({
            b : component.get('v.bookToAdd'),
            authId : component.get('v.authId')
        });
        action.setCallback(this, function(response){
            
        },'ALL');
        $A.enqueueAction(action);
    }
})

Controller - 
public class addBooks {
    @AuraEnabled
    public static void addbooks(Books__c b, Id authId){
        if((b.Name != NULL ||b.Name !='') && (b.Price__c >0)){
            b.Author__c=authId;
            insert b;
        }
    }
}

I get the following error when I try to enter input -

Error
Hi,
User-added imageI want an action that, when i will click ine of those link then my input box with that name.


im giving my codes..
Component:
<aura:attribute name="String" type="String[]"/>
    
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<lightning:card title="Filtered Values">
<div class="search-field">
<lightning:input aura:id="nameFilter" label="Filter names" onchange="{!c.handleNameFilterChange}" />
</div>
    <!--
<div class="results">
<aura:if isTrue="{!v.contacts.length > 0}">
<p class="has-results">
Showing {!v.contacts.length} contact(s):
</p>
<ol class="slds-list_dotted">
-->
   
    <ol>
        
<aura:iteration items="{!v.String}" var="s">
<li>
<a id="getId" onclick="{!c.handleClick}">
{!s}
</a> 
</li>
       
</aura:iteration>
                                       
    </ol></lightning:card></aura:component>


controller
({
init: function(component, event, helper) {
helper.loadList(component);
},

handleNameFilterChange: function (component, event, helper) {
helper.loadList(component);
},

})

helper
 
({
loadList: function(component) {
var action = component.get("c.allContacts");
var nameFilterString = component.find("nameFilter").get("v.value");
action.setParams({
nameFilterString: nameFilterString
});
action.setCallback(this, function(a) {
component.set("v.String", a.getReturnValue());
});
$A.enqueueAction(action); 
}
})
thanks,
​​​​​​​
 Hi all,
How can I call Static resource on Visualforce page, If I'm doing with  "<apex: include script value= value="{!$Resource.add}"/>}"/>" is not functioning. Please help in doing. Thanks for Help.
Suppose there is an inputfield/picklist field.........i want to populate an output textbox with the value of input field or value selected in picklist.
how to do this?
I need help in writing a trigger, I have two objects

1) Opportunity
2) Opportunity_ Program__c

both are having lookup relationship, Opportunity is Parent and Opportunity Program is child.

Opportunity program has Status field.

I need to write a trigger on Opportunity Program object, for a given Opportunity if any of the child records contains status as "MATR" then Opportunity.StageName = 'Closed Won', if any of the child record for a given opportunity does not contain "MATR" then Opportunity.StageName = 'Closed Lost'

Can anyone helps me out in this issue please.
I am new to LWC and cant seem to figure out how to open the source code for LWC. Aura can be opened in the dev console but from what i understand this is not possible with LWC.

Is it possible to open a LWC source code from within the org? I have a LWC that was developed by someone else that needs editing. How can I access the source code?