• HARSHIL U PARIKH
  • PRO
  • 2660 Points
  • Member since 2016


  • Chatter
    Feed
  • 75
    Best Answers
  • 2
    Likes Received
  • 25
    Likes Given
  • 46
    Questions
  • 641
    Replies
There is custom obj and have a checkbox .
I want to sort the records based on Created date.
The checkbox should be checked for the record if created date is the oldest among the list of records.

 
Hello - I'm trying to pass trigger.new and trigger.old to a single list which then will be passed to a class.

Here's the class I'm calling in the trigger: 
LeadOwnerAssignment.assignOwner(Trigger.new, Trigger.old);
Here is the class method I'm passing the lists to:
public static void assignOwner(List<Lead> newLead, List<Lead> oldLead) {

I'm hoping to do something like this (except pass both trigger.new and trigger.old).
List<Lead> newLeadList = new List<Lead>();
                    for(Lead newLead : Trigger.new){
                        if(newLead.Lead_Id__c == null){
                            newLeadList .add(newLead);
                        }  
                    }
                   LeadOwnerAssignment.assignOwner(newLeadList );
 
Any help would be greatly appreciated. 
Hi All,

I want insert the same attachment of the Opportunity object to the Account object.
When I query to the attachment object and get the body of that file then I'm not able to convert the "Blob" format of that body.

Please give the correct tested solution (snippet code).

Thanks in Advance.
I am using an SOQL in a webservice that is querying the Contact object based on the BirthDate field. The webservice request has the date in the format of 'yyyy-MM-dd',i.e.,1962-01-29 as an example.
I am not able to use this value to query the Contact Object. I tried converting this String Date into Date object. However, it always has 00:00:00 at the end. I tried the below options.
String strDate = '1962-01-29'; 
Date birthDate = Date.valueOf(strDate) ==> This results in 1962-01-29 00:00:00 String strDate = '1962-01-29'; 

Date dob = Date.valueOf(strDate) 
Datetime dt = Datetime.newInstance(dob.Year(),dob.Month(),dob.day()); 
Date birthDate = dt.date() ==> This also results in 1962-01-29 00:00:00

How do I construct a Date object (without time) from the string date '1962-01-29'?
I did search for solutions in various forums and most of them are suggesting the above two solutions only, which does not work. I am not sure whether this behavior was changed in some Salesforce's releases.

I even tried the Date.parse() method. Whatever I do, I always get the Date with 00:00:00 at the end and this is messing up the SOQL query. When the SOQL is executed, I am getting a message saying [Exception: Line 1:343 No Viable Alternative at character '' ]. The SOQL is built as shown below.
 
USER_DEBUG [112]|DEBUG|Query:: SELECT id,LastName,FirstName,BirthDate,MiddleName__c,MailingAddress,OtherAddress,EmploymentStatus__c,Suffix__c,MaritalStatus__c,Gender__c,MailingState__c,HomePhone,MobilePhone,Email FROM Contact WHERE LastName LIKE 'Smith%' AND BirthDate = 1962-01-29 00:00:00  ORDER BY lastName,firstName,BirthDate LIMIT 50

If I run this query in workbench, I get the same error message.

Can someone help?
Since our recent move to Lightning, we've lost the ability to use the Contact Roles feature on our Accounts. 

The given response from salesforce is to use the Account Contact Relationship object and add a checkbox called "Primary" (Primary__c)

This has been working well, but this unfortunetely doesn't prevent our sales reps from accidently selecting multiple primary contacts. 

I believe what I'm needing is a trigger on the AccountContactRelationship object that will prevent multiple people from being checked and display an error. 

I've found a few trigger codes that say they work, but all seem to error out when complied in my sandbox org as I don't believe they were written for the AccountContactRelationship object
Hi Experts,

I need to calculate the Date of current week in apex class, i have two fields preferred date and WeekDate field , eg: when  'Preferred Day(picklist list field)” = Monday so i need to set to the date for the "WeekDate" field  to  Monday of this week like wise i need to do till friday. if Preferred Day value is none then i need to populate todays date for the WeekDate field.

Thanks indavance
I have a business case where I need to be able to report on the Mean Time between certain records based on some criteria.

Example: I have an object that tracks IT issues and they are prioritized 1 - 5 (1 being Severe to 5 being benign). I need to show Mean Time between the Priority 1 tickets and am struggling to pull that information into report format.

Any suggestions?
Hi,

I am trying to create a trigger which will be checking a checkbox automatically when another process is done.
In specific, I have a custom object Vacation Requests which follows an approval process. If the request is approved, a checkbox "Approved" is being checked.
Then I am creating a trigger which needs to check if the current date is = to the start date of the vacation. if yes, then the checkbox should be selected.
However this doesn't happen.
Any ideas?
trigger Vacation on Vacation_Requests__c (before insert) {
    User u = new User();
    for (Vacation_Requests__c vr:Trigger.new) {
        if (vr.Approved__c==true && vr.Start_Date__c==System.Today()) 
            u.On_Vacation__c=true;        
    }

}

 
Given I have an Opportunity and there are no open Mandatory sales tasks associated to it When I try and change the opportunity stage
then this shall be allowed by the system. Given I have an Opportunity and there are open Mandatory sales tasks associated to it
When I try and change the opportunity stagetThen the system shall throw a validation error.

trigger Opportunity_Task on Opportunity (before update) {
    List<Task> ts =new List<Task> ();
    List<Opportunity> op =new List<Opportunity>();
    Map<Id,Opportunity> oldMap = trigger.oldMap;
    Map<Id,Opportunity> newMap = trigger.newMap;
    List<id> optyid = new List<id>();
    for(id opid:oldMap.keySet()) {
        Opportunity op =new Opportunity();
        if(oldMap.get(opid).tasks == null && op.stageName=='Closed Won') {
            op.addError('You can create a new task for that Opportunity');
            task t = new task();
            t.WhatId=opid;
            t.Description='kjdkfhsdkf';
            t.Status='open';
            ts.add(t);
        }
        else{
            if(oldMap.get(opid).tasks!=null && op.StageName=='Closed Won')
            op.addError('You cannot modify the opportunity status');
            
        }
    }
    
}
How can task assignee get an email notification when there is an attachment added to the task?
Need to develop a batch which will create investment projects for all accounts having minimum one opportunity

NOTE : If already project available on account then we don't have to create new, if it not exist then create new project and run batch  with batch size 5. 


Thanks
amit