• Akhil Reddy
  • 60 Points
  • Member since 2015

  • Chatter
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 54
I need a new Case Insert Trigger code and we already have 
trigger CaseAfter on Case (after delete, after insert, after undelete, after update)

I only need "after insert" with some specific conditions (a particular account type to add a predefined Case Team) .  Should I created a new trigger or update the exisiting and a separate processing for the specific "after insert" I need?

Hello, I'm a salesforce novice. Our project is to use gitlib as a multi-person collaborative development, eclipse force.com plug-in configuration development environment, but recently very confused, team increasingly disappointed with me and blame, I can't bear it.
My force.com somehow saves other people's code into org when I click team - > pull from gitlib. Team members asked me to remove the option of using tooling API deploy path when possible, but it still could not be solved, and always appeared'Save error: Conflict found while preparing to save'LtngNewWordOrderCtrl. cls' to server. Remote instance has been updated since last save or sync. Error message like'erspective to resolve the conflict.', so I deleted the error, but still in vain, I think my configuration problem, I hope you can help me, thank you very much.
User-added image

Fairly new to dev/apex. Just looking for some advice on how to start/structure my trigger as I'm struggling to get it started. 

We want to send emails when Sales Invoices are overdue, to an email address on the related Account (related via lookup from invoice to account). My first thought was to create the trigger from the Account, but can I access the records related via the lookup on Sales Invoice? I couldn't get the SOQL statement working, so thought to do it from Sales Invoice, but that makes no sense as I need to group the Sales Invoices together where there are more than one overdue for each account, which happens more than not. 

Any sugegstions greatly appreciated! 

[{"message":"Unexpected parameter encountered during deserialization: user at [line:1, column:10]","errorCode":"JSON_PARSER_ERROR"}]
    [2] => Array
            [A] => Donation: Tithing
            [B] => D-THTN
            [C] => 22.52
            [D] => 185290
            [E] => No
            [F] => Tina
            [G] => Dixon Smith
            [H] => fgfghhgsmith@gmail.com
            [I] =>
            [J] => 3059951200
            [K] =>
            [L] =>
            [M] =>
            [N] =>
            [O] =>
            [P] =>

    [3] => Array
            [A] => Donation: Tithing
            [B] => D-THTN
            [C] => 150.00
            [D] => 185289
            [E] => No
            [F] => Eugene
            [G] => Chaviano
            [H] => huhuhu.chaviano@gmail.com
            [I] =>
            [J] => (917) 202-5007
            [K] =>
            [L] =>
            [M] =>
            [N] =>
            [O] =>
            [P] =>

    [4] => Array
            [A] => Donation: Zohar Project                           
            [B] => D-ZHPR
            [C] => 100.00
            [D] => 185268
            [E] => No
            [F] => Jill
            [G] => Janisch
            [H] => j51fdjdfdanidsch@comcast.net
            [I] => 7733442137
            [J] =>
            [K] => 7735451927
            [L] => United States
            [M] => IL
            [N] => Chicago
            [O] => 6059
            [P] => 425 Street

    [5] => Array
            [A] => Donation: Tithing
            [B] => D-THTN
            [C] => 260.00
            [D] => 185267
            [E] => No
            [F] => Esteban
            [G] => Arias
            [H] => estebanarisdfffascardona@hotmail.com
            [I] =>
            [J] => 3057536991
            [K] =>
            [L] => United States
            [M] => FL
            [N] => M
            [O] => 3337
            [P] => 425  Street

Is it possible to reduce the if else statements in the below code, I am interested to know :-
if (engagementStatusSet.contains(CommonConstants.CONS_CONT_NEW) && engagementStatusSet.size() == 1) {

					lstAccount.add(new Account (Id=accountId,Engagement_Status__c = CommonConstants.CONS_CONT_NEW));
				else if (engagementStatusSet.contains(CommonConstants.CONTACT_ESTATUS_UNRESPONSIVE) && engagementStatusSet.size() == 1) {

					lstAccount.add(new Account (Id=accountId,Engagement_Status__c = CommonConstants.CONTACT_ESTATUS_UNRESPONSIVE));
				else if (engagementStatusSet.contains(CommonConstants.CONS_CONT_RECYCLED) && engagementStatusSet.size() == 1) {

					lstAccount.add(new Account (Id=accountId,Engagement_Status__c = CommonConstants.CONS_CONT_RECYCLED));
				else if (engagementStatusSet.contains(CommonConstants.CONTACT_ESTATUS_DONOTCONTACT) && engagementStatusSet.size() == 1) {

					lstAccount.add(new Account (Id=accountId,Engagement_Status__c = CommonConstants.CONTACT_ESTATUS_DONOTCONTACT));
				else if (engagementStatusSet.contains(CommonConstants.CONTACT_ESTATUS_BADDATA) && engagementStatusSet.size() == 1) {

					lstAccount.add(new Account (Id=accountId,Engagement_Status__c = CommonConstants.CONTACT_ESTATUS_BADDATA));
				else if (engagementStatusSet.contains(CommonConstants.CONS_CONT_CUSTOMER)) {

					lstAccount.add(new Account (Id=accountId,Engagement_Status__c = CommonConstants.CONS_CONT_CUSTOMER));
				else if (engagementStatusSet.contains(CommonConstants.CONS_CONT_PROSPECT)) {

					lstAccount.add(new Account (Id=accountId,Engagement_Status__c = CommonConstants.CONS_CONT_PROSPECT));
				else if (engagementStatusSet.contains(CommonConstants.CONS_CONT_ENGG_STS)) {

					lstAccount.add(new Account (Id=accountId,Engagement_Status__c = CommonConstants.CONS_CONT_ENGG_STS));
				else if (engagementStatusSet.contains(CommonConstants.CONTACT_ESTATUS_APPROACHING)) {

					lstAccount.add(new Account (Id=accountId,Engagement_Status__c = CommonConstants.CONTACT_ESTATUS_APPROACHING));

I have written up my console statment in javascript controller as 
                console.log('return' +response.getReturnValue());
1. Not sure, if this is correct or not. If not, then what is the correct step. ?
2. Its giving log as below where i cant see 'return' text in not present in the log though it return the 5 records i am expecting. Am i missing something?
User-added image
I have two custom tables (opportunity__c and Pipe_Owner__c).
When an opportunity is created, it should be linked to only one Pipe Owner. 
I would like to create a custom button on the Pipe Owner table which send a separate custom email to all of the selected owners. In this email I would like to have the list of all related opportunities that are linked to this owner.

e.g : 
Dear XXX, 
Please find below your open pipe:
Opp 1 | Account Name | Amount
Opp 2 | Account Name | Amount

I'm new to the Salesforce environment, but now I have done the following:
- Create a custom button which is launching a VisualForce page and sending an email to myself (but with hard coded values)

I would like now to be able to send one separate email to each of selected records with inside the body the opportunities related to this record. How can I do that ? Do you have some sample code or documentation ?

I'm using lightning version. 

Many thanks,
Hi Guys,

I have a process builder with certain criteria, i want to add another criteria to say if the Created Date equals This Week and another one to say if the Created Date equals Next Week.

I have been looking everywhere for this info but can't find it. 

Hope someone can help! 
I tried creating a formula, but I got an error message that said there were too many characters in my formula.  Any ideas on how to shorten the formula is much appreciated!
Error: Invalid Data. 
Review all error messages below to correct your data.
Compiled formula is too big to execute (9,526 characters). Maximum size is 5,000 characters (Related field: Formula)

IF(ISPICKVAL(Frequency_of_Service__c, "One-time"),
ABS((Cost__c * Probability) / 1),

IF(ISPICKVAL(Frequency_of_Service__c, "Yearly"),
ABS((Cost__c * Probability) / 1),

IF(ISPICKVAL(Frequency_of_Service__c, "Twice Yearly"),
ABS((Cost__c * Probability) / 2),

IF(ISPICKVAL(Frequency_of_Service__c, "Quarterly"),
ABS((Cost__c * Probability) / 4),

IF(ISPICKVAL(Frequency_of_Service__c, "Monthly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Twice Monthly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Weekly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Twice Weekly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Daily"),
ABS((Cost__c * Probability) / 12),


Where the field Cost__c is another formula:
IF(ISPICKVAL(Margin__c , "60"), 
ABS((Amount -(0.60 * Amount))), 

IF(ISPICKVAL(Margin__c , "50"), 
ABS((Amount -(0.50 * Amount))), 

IF(ISPICKVAL(Margin__c , "40"), 
ABS(( Amount -(0.40 * Amount))), 

IF(ISPICKVAL(Margin__c , "45"), 
ABS((Amount -(0.45 * Amount))), 

IF(ISPICKVAL(Margin__c , "35"), 
ABS((Amount -(0.35 * Amount))), 

IF(ISPICKVAL(Margin__c , "30"), 
ABS((Amount -(0.30 * Amount))), 

The "Send notification email" checkbox is defaulted to true when using salesforce classic for case ownership change, but not in lightning. The "Notify Case Owners when Case Ownership Changes" setting is set to true in Case Support Setting. Does anyone know why is it not working in lightning?
  • February 16, 2017
  • Like
  • 1
When I try to Change the Owner of a case record in Salesforce Classic, the "Send notification email" checkbox is defaulted to true but when I am trying to Change the Owner in lightning the checkbox is not checked.

The "Notify Case Owners when Case Ownership Changes" is set to true in the Case Support Settings.
  • February 16, 2017
  • Like
  • 0
Hi There!

I have a custom object (Contract Loan) which is related to the Case object, and I'd like to be able to count how many Contract Loan records there are related to each case.
I can't use a ROLLUP Summary, because we don't have (don't want) a Master-Detail Relationship field on the Contract Loan object to the case, so it'd need to be done by an APEX Trigger - I won't lie, I have no idea what I'm doing.

Can anyone give me a hand at starting this, please?


Hi all,

I seem to have hit a snag with my work. I have used this technique before but for some reason I am gettting this error, Method does not exist or incorrect signature: [List<AggregateResult>].get(String). 

List<Contact> l_ConToUpdate = [SELECT ID,INV_YTD_Entertainment_Spend__c,INV_PYTD_Entertainment_Spend__c FROM Contact where Id in :Set_Id];
        For (Contact con:l_ConToUpdate){
            List<AggregateResult> l_EventToCountCY = [SELECT SUM(INV_Cost__c) Total FROM Event WHERE WhoId = :con.Id AND CALENDAR_YEAR(ENDDATETIME) = :System.Today().year() AND INV_Type__c = 'Entertainment'];
            CY_Sum = Double.valueOf(l_EventToCountCY.get('Total')); <-- error on this line

Any hints?

I need help with joined query syntax.

If Resource (pse__Resource__c) has logged billable hours on client projects (pse__Project__r.Account_18_Char_ID__c) within the last 12 months,
return the number of continuing education hours logged during the last 12 months for each resource.

Source Object: 

Data Fields Needed: 
Resource: pse__Resource__c, pse__Resource__r.FirstName, pse__Resource__r.LastName

Total Hours: pse__Total_Hours__c

Client Project Filter Criteria:
Billable: pse__Billable__c = true
End Date: pse__End_Date__c = LAST_N_MONTHS:12

Continuing Education Filter Criteria: (All CE hours are logged to our account '001G000000oviiRIAQ')
Project Account ID: pse__Project__r.Account_18_Char_ID__c = '001G000000oviiRIAQ'
End Date: pse__End_Date__c = LAST_N_MONTHS:12
Milestone Name:  pse__Milestone__r.Name = 'Coding Compliance Review' OR pse__Milestone__r.Name = 'Other Continuing Education' OR pse__Milestone__r.Name = 'Meetings'

I currently have 2 different queries that work individually.

(Query - 1) This query is currently working to pull CE Hours in last 12 Months:

SELECT  pse__Resource__c, pse__Project__r.Account_18_Char_ID__c, pse__Total_Hours__c, pse__End_Date__c, pse__Milestone__r.Name, pse__Resource__r.FirstName, pse__Resource__r.LastName 
FROM pse__Timecard__c
WHERE pse__Project__r.Account_18_Char_ID__c = '001G000000oviiRIAQ' AND pse__End_Date__c = LAST_N_MONTHS:12 AND  (pse__Milestone__r.Name = 'Coding Compliance Review' OR pse__Milestone__r.Name = 'Other Continuing Education' OR pse__Milestone__r.Name = 'Meetings')

(Query - 2) This query is currently working to pull Resources who whave logged billable hours against a particular client project(s) in the last 12 months:

SELECT  pse__Resource__c, pse__Project__r.Account_18_Char_ID__c, pse__Total_Hours__c, pse__End_Date__c
FROM pse__Timecard__c
WHERE pse__Project__r.Account_18_Char_ID__c = '001G000001laKqrIAE' AND pse__End_Date__c = LAST_N_MONTHS:12 AND pse__Billable__c = true

Again, I am looking for the number of CE hours for any resource who has logged time to a given client's projects by limiting the results of Query 1 by the matching results of Query 2 (matching on pse__Resource__c).
How should I copy a text field to a lookup field
I tried doing it with workflow field update but its in vain as workflows dont update lookup field
and my next approach was process builder ,but this too is failing because since I am updating a lookup field its should update the ID not the name .

This is the error for Process builder:Error Occurred: The flow tried to update these records: null. This error occurred: MALFORMED_ID: Previous: id value of incorrect type: Mike Dan. For details, see API Exceptions.

My two fields are Previous Manager which is a text field 
Previous is a lookup field 
Hey everyone,

One of our developers who is no longer with the company created a VF that would create and contact under an account called "Next of Kin"

The page would then tie the Next of Kin contact back to the Account that the "Next of Kin" button was pressed

As of a few days ago the Account Contact Relationship is no longer being created.

I need help making that relationship happen again. Thank you in advance

Here is the VF Page:
<!--This Page is called from the [Add Next Of Kin] button from the Individual Account record. This page get the input for the Next of Kin Contact infomation and the relationship information 
with the specified individual Account-->
<apex:page standardController="Account" extensions="CreateNextofKinContact">
 <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js" />
    <apex:styleSheet value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/smoothness/jquery-ui.css" />   
    <apex:stylesheet value="{!URLFOR($Resource.stacktable, 'stacktable.css')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.slds120,'assets/styles/salesforce-lightning-design-system.css')}"/>
    <apex:form >
        <apex:pageBlock mode="maindetail" title="Contact Edit">
            <apex:pageBlockButtons >
             <apex:commandButton value="Save" action="{!saveDetails}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            <apex:pageBlockSection title="Contact Information">
                <apex:repeat value="{!$ObjectType.Contact.FieldSets.Next_of_Kin_Contact_Creation}" 
                    <apex:inputField value="{!currContact[field]}" />
            <apex:pageBlockSection title="Contact Relationship">              
              <!-- <apex:inputField value="{!currAccountContactrelation.StartDate}"/>
               <apex:inputField value="{!currAccountContactrelation.EndDate}"/>-->
                 <apex:inputField value="{!currAccountContactrelation.Roles}"/>

Here is the Class:
/* This Class act as a controller extension for the 'Create_Next_of_Kin_Contact' page. It will create a contact under the 'Next of Kin' Account and create a relationship AccountContact
relation between the  Individual account and the created contact*/
public class CreateNextofKinContact{   
    public Account currAccount;
    Public Contact currContact{get;set;}
    private Account nextOfKinAccount; 
    public AccountContactRelation currAccountContactrelation{get;set;}
    public CreateNextofKinContact(ApexPages.StandardController stdController) {
        this.currAccount = (Account) stdController.getRecord();
        currContact = new Contact();
        currAccountContactrelation = new AccountContactRelation();
        if(Label.Next_of_Kin_Account_Name != Null){
            List <Account> accountLst = [SELECT ID FROM Account WHERE name = : Label.Next_of_Kin_Account_Name];
            if(accountLst.size() > 0)
                nextOfKinAccount = accountLst[0]; 
    public pagereference saveDetails(){
        if(nextOfKinAccount != Null){
                currContact.AccountId = nextOfKinAccount.id;
                currContact.RecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Next of Kin').getRecordTypeId();
                insert currContact;
            }Catch(Exception ex){
                System.Debug('Exception ex'+ex.getMessage());
            AccountContactRelation newAccountContactRelations = new AccountContactRelation();
            newAccountContactRelations.AccountId = currAccount.id;
            newAccountContactRelations.ContactId = currContact.id;
            newAccountContactRelations.IsActive = true;
            newAccountContactRelations.Roles = currAccountContactrelation.Roles;
            newAccountContactRelations.StartDate = currAccountContactrelation.StartDate;
            newAccountContactRelations.EndDate = currAccountContactrelation.EndDate;
                insert newAccountContactRelations;                
            }Catch(Exception ex){
                System.debug('Exception Ex'+ex.getMessage());
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.Severity.ERROR,'We are unbale to find the Next of Kin Account. Please contact the Administrator.');
            return null;
        return new Pagereference('/'+currAccount.id);

I have a custom Related Activity List which, (through the use of a custom field called "hubspot generated activity" , a workflow that updates the Custom field based on subject line of the task and a process builder), gives me the listing of all activity not generated by hubspot and this is working brilliantly - with the exception of those tasks that are created using the BCC email (email to salesforce)

For some reason the workflow is not "seeing" the email tasks as they are created in salesforce, so the workflow is not triggering and subsquently the process builder is not pulling them into the right list.  If I open each of these tasks and re-save it, the workflow is started and the rest of the process works through to the end- so i just need a way to set the workflow off without having to manually open the record. (we are talking about 250 records+ per day). 

I understood that the standard functionality of workflow rules couldnt do this so needed to created an Apex trigger... 

The apex trigger set to run when an email (bcc) is sent which populates the "hubspot generated activity" field to "To Sync" so that I can see which records need to be updated and the workflow process in place says if hubspot generated activity field equals "To Sync"- change field to "no" 

What can I do to make the task be seen? 

I did wonder if i need the Apex trigger to be an update after the record is created? But not sure if thats the right thing to do and if so how to change the code to reflect that?   Below is the Apex Trigger I have currently..

trigger HubspotGenActivity on Task (before insert) {
 for(Task newTask : trigger.new){
            !String.isBlank(newTask.Subject) &&
            newTask.Hubspot_generated__c = 'To Sync';

Any ideas please? 
Thanks in Advance
I am looking for some help with a test class. My code looks at when a lead comes in and creates a taks with an after business hours flag. I am trying creat a test class that uses business hours to test the following code. I havnt figured out a way to simulate after hours. 
trigger Working_Lead_business on Lead (after insert) {
    public datetime mydate = system.now();
    List<Task> tsk_lst = new list<task>{};
    BusinessHours bh = [select id from businesshours where id = '01m50000000LjJ5'];
    Boolean isWithin = BusinessHours.isWithin(bh.id, mydate);
    system.debug('BusinessHours = ' + isWithin);
    For(Lead l: Trigger.new) {
        if(l.Status == 'New' && isWithin == false && (l.Country != 'UK' || l.Country != 'United Kingdom')){
            Task taskcreate = new Task();
            taskcreate.OwnerId = '00550000005ThR4';
            taskcreate.WhoId = l.id;
            taskcreate.ReminderDateTime = date.today();
            taskcreate.Subject = 'Call';
            taskcreate.Status = 'Completed';
    upsert tsk_lst;
Thank you for any help. 

HI All,


We are using Salesforce as IdP and we enabled also the Single Sign-on settings in Salesforce. Now we want to use Heroku and Play! to access Salesforce and the Play! application is the service provider.


This all works fine when using an internal salesforce user, but we want to use this functionality with a customer portal user but how can we manage that.


I found a doc where it states that we need to add the portal_id and the organization_id to the saml assertion but we only have a saml request and the saml assertion comes from the identity provider i think.


Help would be appreciated.


thx Sven

  • March 08, 2012
  • Like
  • 0