• Anthony McDougald
  • NEWBIE
  • 360 Points
  • Member since 2018

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 84
    Replies
Hello, I'm trying to get a text formula field working that would kick back the value of another formula field.


IF(
AND(ISPICKVAL( Cerner_Tier__c,"A"), TEXT(End_Market__c),
IF(
AND(ISPICKVAL( Cerner_Tier__c,"B"), TEXT(End_Market__c),
IF(
AND(ISPICKVAL( Cerner_Tier__c,"C"), TEXT(End_Market__c),
IF(
AND(ISPICKVAL( Cerner_Tier__c,"D"), TEXT(End_Market__c),
IF(
AND(ISPICKVAL( Cerner_Tier__c,"E"), TEXT(End_Market__c), null))))))))))

Basically, if the Tier is filled in with A-E, then I would like what is in the End Market field to display. The End Market field is a text formula that looks at the classification picklist fied and displays some values.  I used the CASE function for that and it works fine.  However, this formula that references that formula field errors out with this:
Error: Incorrect parameter type for function 'TEXT()'. Expected Number, Date, DateTime, Picklist, received Text
Hi,
During the project we are asked to create 2 fields in the object "Drink Orders" such as "Size" and "Price" which are both Picklist type.
My question is how can I link those 2 fields so when I pick "Size" "Price" is automatically filled ?
Hi All,

I am getting the below exception 

System.StringException: Starting position out of bounds: 11 Class.Test.datecalculation: line 29

Please help me the issue here
public class test {
    
    public static void datecalculation(List<Case> caseList )
    {
        if(caseList.size() >0 )
        {
            List<Case> caseList2  = new List<Case>();
            for(Case c: caseList)
            {
                if(c.Departure_Date_Time__c!=null){
                //Case ca = new Case();
                String firstDate = c.Departure_Date_Time__c;
                String month = firstDate.substring(3,5);
                String day = firstDate.substring(0,2);
                String year = firstDate.substring(6,10);          
                string hour = firstDate.substring(11,13);               
                string minute = firstDate.substring(14,16);               
                string second = firstDate.substring(17,19);
                  
                string stringDate = year + '-' + month + '-' + day + ' ' + hour + ':' 
                    + minute +  ':' + second;
                System.debug('stringDate:'+stringDate);
                
                Date myDate = Date.valueOf(stringDate);
                c.Updated_Departure_Date_Time__c = myDate;
                }
            
            }
        }
        
    }
    
}

ERROR LINE :
                string hour = firstDate.substring(11,13);               

Kindly help me on the same,

Thanks in advance
​​​​​​​
Hello, Can someone tell me what I'm missing in the validation rule: 
AND(
ISPICKVAL( Status, 'Working - Contacted'),
ISPICKVAL( Rating, 'Hot')
)
I'm trying to not let users select save if the Status of Working - Contacted is selected and the picklist Rating field is not selected as Hot and try to save the record, the system should prompt them they will not be able to save this record. 

The other values in the picklist are: none, Cold, Warm. 

If the field is left blank, the user is still able to bypass but I'm trying to prevent that.

Thanks!
 
  • December 16, 2019
  • Like
  • 0
trigger emiTrigger on EMI_Payment__c (after insert) {
Set<id> loanid = new Set<id>();
List<Loans__c> loanslist = new List<Loans__c>();
for(EMI_Payment__c e : Trigger.new){
   loanid.add(e.Loan_Id__c);
}
for(Loans__c loan : [select id,Name,EMI__c,paid_amount__c,(select id,amount__c from EMI_Payment__r) from Loans__c where id IN : loanid]){
   for(EMI_Payment__c e:loan.EMI_Payment__r){
         //ading Emi amount to old paid amount , its giving worng value
         loan.paid_amount__c = loan.paid_amount__c +e.amount__c;
         system.debug('updated for...'+loan.paid_amount__c+'...>'+ e.amount__c);
   }
   loanslist.add(loan);
}
update loanslist;
system.debug('updated ...');
}

==================================================
Loans__c  ==> parent object
EMI_Payment__c  ==> child object
trying to update   loan.paid_amount__c with new EMI payment amount but its coming up with wrong value but if I debug for same value its showing correct in logs

Example : Assume 45281 is a initial value of loan.paid_amount__c 
and next if I give 45281 as input  for e.amount__c
expected to happen -
loan.paid_amount__c = loan.paid_amount__c +e.amount__c;
45281 = 45281 + 45281; ==> 96502
but its coming up with ==> 144,753


I am not understanding why ?
 
Hey, I have object A.

A has lookup to Account. All records on A have the same owner.

I need to change the owner of A records to the owner of the Account in lookup.

Example: John owns 10 records of object A. All of those records have lookup to an Account called McDonalds. Owner of the McDonalds record is user McDonald. I need to change ownership of John's records to the user in related Account (that might not only be McDonald, but others...).

I'm experiencing difficulties with my code:

List <TestObj__c> list1 = New List<TestObj__c>();
list1 = [SELECT id, NAME From TestObj__c WHERE (OwnerId = '0052o000009Stq8')];
for(TestObj__c a :list1) {
   
    /**
   /* variable a;
   /* variable a = [Select AccountOwner from Account where (TestObj__c.lookupToAccount equals AccountId];
    /* a.Owner = a;
    /*
                                                          
}

The for look works, but I don't know what to put inside, because it gives me errors, so I just deleted it and put something vague inside and commented it. How do I do this?
Hi 
pls find scenario below:
I have Task category picklist and values  ' Add' , 'Edit' ,'Override' and 'PF'.
And
Region is multi picklist  and values are 'US','UK','China' and 'Global'.

my rquirement is :
Global Region picklist value is only applicable for PF Task category.
Other Task category values try to select 'Globa' fire an error message.

I write below VR rule ...but its not working .. can some one pls check and help on this:
AND( 
OR(
ISPICKVAL(Task_Category__c,“Add ”),
ISPICKVAL(Task_Category__c,“Edit”), 
ISPICKVAL(Task_Category__c,“Override”) 

)
NOT includes(Regions__c ,"Global")
)
But its not working , can you pls help on this
  • December 09, 2019
  • Like
  • 0
I am completely new to Apex and could really use some help with what seems to be a simple task.  I have a formula on the contact, Persona_True__c, that returns a 1 if the custom field "persona" is populated and a 0 if it is blank.

I would like to have a roll-up summary that sums this field at the account level in a field called Related_Personas__c.  

Because we can't roll-up from contact to account I'm reading that this type of action needs to be a trigger, but I don't even know where to start.  Does anyone have any thoughts or expertise they can share to help me out? 

I am trying to create a process through Process builder to update the following Fields if the field Future Interest = True:
Lead Disposition = Contacted DM
Outbound Disposition = Not Interested
Status = Nurture.

What I am trying to achieve is when a user marks Future interest as true I want these field to auto update to the above mentioned values.

BillAndPayWrapper(BillingHistoryServiceSet__x billPay, String companyCode) {
            this.postDate      = billPay.PostingDate__c;
            this.invoice      = billPay.InvoiceNo__c;
            this.amount      = billPay.TotalDueAmt__c.setScale(2);
            this.billPeriod  = billPay.BillPeriod__c;

billPeriod is string and BillPeriod__c field under external object is data type text . It is external data and i get it as YYYY/MM. But i need to format it to MM/YYYY
Hello, I am trying to unlock a "Matter" record when the record goes into an approval process. A trigger will see that it is locked and then unlock the record. This is working, but my test class is only covering 66%. How can I get it to 100%? Thanks!

Trigger
trigger UnlockMatter on litify_pm__Matter__c (after insert, after update) {
    for(litify_pm__Matter__c matter : trigger.New) {
        If(Approval.isLocked(matter.Id)) {
            Approval.unlock(matter.Id);
        }
    }
}

Test Class
@isTest
public class TestUnlockMatter {
     @isTest static void TestEditMatterInApproval() {
          // Test data setup
          
          // Create A Party to assign to the matter
          Account party = new Account(litify_pm__First_Name__c='Jim', litify_pm__Last_Name__c='Halpert');
          insert party;
          
          // Create A Matter that is locked and unlock and edit it
          litify_pm__Matter__c matter = new litify_pm__Matter__c(litify_pm__Display_Name__c='Jim Halpert vs. Dwight Schrute', litify_pm__Client__c= party.Id);
          insert matter;
          Approval.lock(matter.Id);
         
         //Perform Test
         Test.startTest();
         Approval.unlock(matter.Id);
         matter.litify_pm__Display_Name__c ='Jim Halpert vs. Micheal Scott';
         Test.stopTest();
     }
}

 
Hello,
I'm getting this error when I use the below code. The bold part below is the line where it says the error occurred. Here is the error message: 

"execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 00Q3l00000vUpy4EAC; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] "


List<id> refToDelete = new List<id>();
Lead refToUpdate;      
Set<Id> oldReferral =  new Set<id>();
Id cldId;
      for (lead thisLead : trigger.new){
          if (thislead.Existing_Referral__c !=null  && thislead.Community_Lead__c !=null ){
              refToDelete.add(thisLead.id);
              oldReferral.add(thislead.existing_referral__c);
              cldId = thislead.Community_Lead__c;
          }
      }
     //delete new referral
          if (!refToDelete.isempty()){
              system.debug('*****DELETED REFERRAL:  ' + reftodelete);
              database.delete(refToDelete);     }
      
     //populate community lead of existing referral
        if (!oldReferral.isempty()){
refToUpdate = [Select Id, community_lead__c from lead where id in :oldReferral];
            list<lead> updateExisting = new list<lead>();
            if (refToUpdate.community_lead__c == null){
              refToUpdate.Community_Lead__c = cldId;
              //updateExisting.add(l);
           system.debug('****************EXISTING LeadTO UPDATE:  ' + reftoupdate);
            } update refToUpdate;  
public class CreateCampaignfromLead {
    Public static void AddCampaignmember(list<lead>ListLead){
        list<lead>ListLd=new list<lead>();
        Id OppId;
        Date FCDate;
        Id CampId;
        list<campaignmember> cmmlist = new list<campaignmember>();
        for(Lead ld:ListLead){
            if(ld.Agent_Site_Source__c=='Re-Marketed opportunity' && ld.Referenced_Opportunity__c !=null ){
                OppId=ld.Referenced_Opportunity__c;  
            }
            List<opportunity>OppList=[select id,stagename,Future_Contact_Date__c from opportunity where 
                                      (stagename='No Solution - Not Qualified' OR 
                                       stagename='No Solution - No Experience' 
                                       OR stagename='No Solution - Age Experience' OR
                                       stagename='No Solution - Outside of quote period') AND ID=:OppId];
            
            for(opportunity Opp:OppList){
                FCDate=opp.Future_Contact_Date__c;
            }  
            if(OppList.Isempty()){
                List<opportunity>OpList=[select Id,stagename,CloseDate from opportunity where (stagename='NTU - Deal Lost' OR 
                                                                                               stagename='NTU - Too Expensive' )AND ID=:OppId];
                
                for(opportunity Opp:OpList){
                    FCDate=opp.CloseDate;
                }
            }
            list<campaign>camplist = new list<campaign>();
            camplist = [select Id , Name,Campaign_Date__c from campaign  where
                        CALENDAR_MONTH(Campaign_Date__c) = :FCDate.month() AND CALENDAR_YEAR(Campaign_Date__c) 
                        =:FCDate.YEAR()];
            for(campaign cam:camplist){
                CampId=cam.Id;
            }
            campaignmember cmm = new campaignmember();
            cmm.campaignid= CampId;
            cmm.LeadId =ld.id;
            cmmlist.add(cmm);
        }
        insert cmmlist;
    }
}
Hello, I don't know how to bulkify this. Please help
 
trigger QuoteLineItemEmailBeforeDelete on QuoteLineItem (after delete) {
    Set<Id> quids = new Set<Id>();

    for(QuoteLineItem qli :Trigger.Old) {
        quids.add(qli.QuoteId);
    }

    Quote[] quo = [Select Id, Name, Status, RecordTypeId from Quote Where id In :quids];

    if((quo[0].Status == '2. Validated - Waiting for order' || quo[0].Status == '3. Offer partially entered in SAP' || quo[0].Status == '4. Offer fully entered in SAP')&& (Quo[0].Name.Contains('H3'))) {
  Messaging.reserveSingleEmailCapacity(trigger.size);
    List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
    for (QuoteLineItem qli : Trigger.old) {
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setToAddresses(new String[] {'becommingaprogrammer@example.com'});
        email.setSubject('Oznámení o změně nabídky');
        email.setPlainTextBody('Došlo ke změně nabídky ' + Quo[0].Name + '.\n\n' + 'Pro otevření záznamu v Salesforce klikněte na následující odkaz:\n\n' +  'https://sg--testing.lightning.force.com/lightning/r/Quote/' + quo[0].Id + '/view');
        emails.add(email);
    }

    Messaging.sendEmail(emails);
        
    }
}

 
Hi All,

I have a process that maps a custom field from the Lead Object to a standard field on the Account Object and it also populates a lookup on the Opportunity, upon conversion.

It works perfectly fine, but I want it now to only map the value, if the Account is a new Account rather than existing.
  • The process fires when a record is created or edited.
  • Nod Criteria - conditions are met:
             [Lead].IsConverted = TRUE
  • Update Records: [Lead].Converted Account ID - meet all conditions:
           Condition: 1. Created Date = DATETIMEVALUE([Lead].ConvertedDate])

Update Records: standard field = [Lead].custom_field__c
  • Update Records: [Lead].Converted Opportunity ID
Contact = [Lead].ConvertedContactId

The PB doesn't populate the standard field on Account, because of the condition.

Any help will be much appreciated.

Thanks.

 I have a validation rule on the number field like number should be less than 10000. Now I have a workflow field update and it is updating with 15000. Now user has entered 12000. What will happen in this case? what will happen if we replace validation Rule with before trigger? Will the record be not saved in the both cases?
I'm in need of some technical help and was hoping you will be kind enough to assist??
 
I have created this formula field
 
IF(Active_PL_Membership_Count__c>0, "Primary Member"&IF( Membership_NDA__c = TRUE," - NON DISCLOSURE AGREEMENT",""),
IF(NOT(ISBLANK( Inherit_Member_Access__c)), "Related to Member",
IF(Parent_Child_Has_Membership__c =TRUE, "Related to Member",
IF(Orignal_Membership_Start_Date__c > Today(), "Pending Member",
IF(AND (NOT(ISBLANK(Membership_Expiry_Most_Recent__c)),Membership_Expiry_Most_Recent__c> today()), "Pending Member",
IF(Active_SEIC_Membership_Count__c>0, "SEIC Member",
IF(NOT(ISBLANK(Membership_Expiry_Most_Recent__c)), "Expired Member",
"Not Member")))))))
 
However I don't think it is working: as there was an account that did not have "Inherit_Member_Access__c" box checked OR "Parent_Child_Has_Membership__c =TRUE" yet the child accounts account membership status was 'Related to member'
 
let me know if this doesn't make any sense; or if you cant help I really appreciate your time and effort.
 
Can someone help me with this formula? I need to check if a date field is between 2 dates fields.

"check that the date of performance is between the start and end date of the policy." Thanks in advance
Is their is any difference between one to many or many to one relationship and what is the difference between owner and created by??
I am a Salesforce admin working to finish a Trigger in our Sandbox for tesitng. I have an Apex Trigger that is being used to rollup certain activities onto the lead record. When I try to convert the lead I'm hitting an error that I'm interpreting is because it's pushing an update to the activities on the record and then looking for the Lead.Id but this no longer exists. Can someone show me how to trigger only if the Lead is not converted?

Error message:

Error: There was an error converting the lead. Please resolve the following error and try again: ActivityRollups: execution of AfterUpdate caused by: System.SObjectException: Invalid Id for Lead 
How can I trigger a task to be automatically at the time a case is created when a specific case reason is selected?  For some reason, the task layout I created within the task object cannot be selected within process builder?  Process builder only allows me to select the task object, not the layouts within the object.

Furthermore, it is not clear how a quick action task is created from process builder?  What is best practice?
Hi,

The problem that I have is that when an opportunity is closed, not all the Amount will come into the business in the Closed Date Financial Year.

As a solution, I was thinking of creating a separate Custom Object to track the Annual Value of the opportunity.

Opp Annual Value
Financial Year

In order to calculate the Opp Annual Value, I would count the number of months in that FY and * by the Opp Amount/Duration in Months.

In terms of the Financial Year, that is a picklist. 16/17, 17/18, 18/19,. etc. Is there an easy way to assign these values?

Should this be written as a Trigger or as a Class?

Thanks,

emeric.
  • January 05, 2020
  • Like
  • 0
Im gettting htis error while owrking on servic elcoud please help me out.User-added image
Please save me from this hell.
I have been stucked this hell for 3 days.


User-added imageI set the approval process(Confirm Volunteer Shift) and process(Launch Shift Approver).
Created User Dan Wong as well.

I restart from the new playground more than 6 times to handle this issue.
Please save me from this hell.
Hey guys, 

Looking to write a test class for the following: 

trigger OpportunityAmountTrigger on Opportunity (Before Insert, Before Update) {
    for(Opportunity o : Trigger.New){
    if(trigger.isinsert && o.amount < 5000)
    o.addError('Amount can not be less than 5000');
    else if (Trigger.isUpdate && o.amount < 3000)
    o.adderror('Amount can not be updated to less than 3000');
 
    }
}

Here is what I have so far, but not sure where to go from here:

@isTest
public class OpportunityAmountTriggerTest {
    
    @isTest static void testOpportunity()
    {
        Integer Opportunity= Opportunity.amount(4000);
        System.assertEquals('Amount can not be less than 5000', Opportunity);
    }
}
Hello, I'm trying to get a text formula field working that would kick back the value of another formula field.


IF(
AND(ISPICKVAL( Cerner_Tier__c,"A"), TEXT(End_Market__c),
IF(
AND(ISPICKVAL( Cerner_Tier__c,"B"), TEXT(End_Market__c),
IF(
AND(ISPICKVAL( Cerner_Tier__c,"C"), TEXT(End_Market__c),
IF(
AND(ISPICKVAL( Cerner_Tier__c,"D"), TEXT(End_Market__c),
IF(
AND(ISPICKVAL( Cerner_Tier__c,"E"), TEXT(End_Market__c), null))))))))))

Basically, if the Tier is filled in with A-E, then I would like what is in the End Market field to display. The End Market field is a text formula that looks at the classification picklist fied and displays some values.  I used the CASE function for that and it works fine.  However, this formula that references that formula field errors out with this:
Error: Incorrect parameter type for function 'TEXT()'. Expected Number, Date, DateTime, Picklist, received Text
Hi,
During the project we are asked to create 2 fields in the object "Drink Orders" such as "Size" and "Price" which are both Picklist type.
My question is how can I link those 2 fields so when I pick "Size" "Price" is automatically filled ?
trigger QuoteLineItemTrigger on Quotes__c (Before insert, Before update) 
{
    List<QuoteLineitem__c> quote = new List<QuoteLineitem__c>();
    Set<Id>productidSet =New Set<Id>();
    for(Quotes__c  child : trigger.new)
    {
        if(child.IsSyncing__c != true)
        {
            productidSet.add(child.Product2Id__c);   
            //quote.add(child.Product_Image__c = Product2Id.Product_Image__c);
        }      
    }
   Map<id,Product2__c>ProductMap=New Map<Id,Product2__c>([Select id,Name From Product2__c where id=:productidSet ]);
     for(Quotes__c child : trigger.new)
    {
        if(child.Product2__c != null && ProductMap.containskey(child.Product2Id))
        {
            child.Product2__c = ProductMap.get(child.Product2Id__c).Name;
        }      
    }
}

User-added image
 
I'm having an issue with "Method does not exist or incorrect signature" on this test class...



Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(id currentlead: LeadIds){
                Database.LeadConvert Leadconvert = new Database.LeadConvert();
                Leadconvert.setLeadId(currentlead);                
                Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
                MassLeadconvert.add(Leadconvert);
        }
        
        if (!MassLeadconvert.isEmpty()) {
            List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);
        }
    }
}





@isTest
private class AutoConvertLeadsTest {
    @isTest
    public static void testLeadInsert ()
    {
        List<Id> lListIds = new List<Id>();
        List<Lead> lList = new List<Lead>();
        
        Lead objLead = new Lead (LastName = 'Test', Email = 'test@gmail.com', mobilephone = '+1234567890', Company = 'Test company');
        insert objLead; 
        
        lList = [SELECT Id FROM Lead];
        
        for(Lead l : lList){
            lListIds.add(l.Id);
        }
        
        insert lList;
        
        Test.startTest();
        AutoConvertLeadsTest.LeadAssign(lListIds);
        Test.stopTest();
    }
}
 
Is there any other solutions other than salesforce recommended (https://help.salesforce.com/articleView?id=000324937&language=en_US&type=1&mode=1) for this error "Compiled formula is too big to execute (5,259 characters). Maximum size is 5,000 characters"User-added image
I am completely new to Apex and could really use some help with what seems to be a simple task.  I have a formula on the contact, Persona_True__c, that returns a 1 if the custom field "persona" is populated and a 0 if it is blank.

I would like to have a roll-up summary that sums this field at the account level in a field called Related_Personas__c.  

Because we can't roll-up from contact to account I'm reading that this type of action needs to be a trigger, but I don't even know where to start.  Does anyone have any thoughts or expertise they can share to help me out?