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

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 78
    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
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();
     }
}

 
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
 
Can anyone tell why getting this error.Here is my code
public class insertclass 
{
   public static void insertMethod(string LastNameOfAccount)
   {
       List<Account> acclist = New List<Account>();      
           account acc = new account();
           acc.name = LastNameOfAccount;
           acclist.add(acc);         
        system.debug('.....acclist'+acclist);
         insert acclist;
       List<Account> acc1 = New List<Account>();
       acc1 = [SELECT Name,Id From Account Where name =:LastNameOfAccount];
       system.debug('acc1...'+acc1);
       Id accountId;
       for (Account acc23: acc1)     
       {
           accountId = acc23.Id ;
           system.debug('acc2---'+accountId);
       } 
         List<Contact> conlist = New List<Contact>();
         for(integer i = 0; i<2; i++)
         {           
            Contact con = new contact();
            con.Firstname = 'Test'+ string.valueOf(i);
            con.Lastname = 'Ramesh';
            con.accountId =  accountId ;
            conlist.add(con);       
         }      
         system.debug('.....conlist'+conlist);
         insert conlist;
     }
                    List<opportunity> opplist = New List<opportunity>();
error line >        for(integer i = 0; i<2; i++)
              {           
            opportunity opp = new opportunity();
            opp.Firstname = 'Test'+ string.valueOf(i);
            opp.Lastname = 'Ramesh';
            opp.accountId =  accountId ;
            opplist.add(opp);       
         }      
         system.debug('.....opplist'+opplist);
         insert opplist;
     }
Thanks is advance.
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();
    }
}
 

Hi all - 
I am hoping you can help me modify a trigger - currently, it fires every time a record is updated, but we need to modify it to fire upon create only - thank you!! 
1trigger AssetTrigger on Asset (before insert, before update, before delete, after insert, after update, after delete) {
2        if(Trigger.isBefore) {
3            if(Trigger.isInsert && AssetTriggerHelper.firstRunBefore) {
4                AssetTriggerHelper.setAccountOnAsset(trigger.new);
5            }
6            if(Trigger.isUpdate) {
7                AssetTriggerHelper.setAccountOnAsset(trigger.new);
8            }
9            if(Trigger.isDelete) {
10                //do nothing for now
11            }
12            AssetTriggerHelper.firstRunBefore = false;
13        }
14        
15        if(Trigger.isAfter && AssetTriggerHelper.firstRunAfter) {
16            if(Trigger.isInsert) {
17                //do nothing for now
18            }
19            if(Trigger.isUpdate) {
20                //do nothing for now
21            }
22            if(Trigger.isDelete) {
23                //do nothing for now
24            }
25            AssetTriggerHelper.firstRunAfter = false;
26        }
27    }

Order__c od = new Order__c();
        
        for(Item__c it : addedItems){    //addedItems (type: List) already created and populated!
            it.Order__c = od.id;
        }

In the code, I'm trying to put the Items in 'addedItems' list, each, into the Order__c object.
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
​​​​​​​
Hi I am getting CUMULATIVE_LIMIT_USAGE_END in debug logs.
 
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?