• Ganesh Prasath
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 8
    Replies
Hi Experts , 

   We have a scenario where we are required to report the YTD Budget achieved % (sum of sales every month / targets of months until the present month in a year) ,but we have numerous accounts without a target as well which results in the divide by zero sceantio. I've tried the below formula under a custom field called as %YTD Budget but I still do get the error , any help will be greatly appreciated

IF (((( July_16_Sales__c +     August_16_Sales__c +  MTD_Sales__c ) / ( July_16_Quota__c +  August_16_Quota__c + Sep_16_Quota__c )) <=0),
(( July_16_Sales__c +     August_16_Sales__c +  MTD_Sales__c ) / 1),
(( July_16_Sales__c +     August_16_Sales__c +  MTD_Sales__c ) / ( July_16_Quota__c +  August_16_Quota__c + Sep_16_Quota__c )))

Thanks
Ganesh
Hi All ,

Am new to Apex programmin , with some help ive written the following Apex trigger but I need to write the test class and I got the code covereage error as 0% , any help would be much appreciated.


trigger TaskTrigger on Task (after update , before insert) {
    
    set<string> Emails = new set<string>();
    list<contact>ContactList = [select id, email from contact];
    
    for(contact c: [select id, Email from contact])
    {
        Emails.add(c.Email);
    }
    
    list<contact>NewContactList = new list<contact>();
    for(task t : trigger.new)
    
  {
        if( t.Type == 'Visits') //This IF conditions checks whether task type is Meeting or not

    if (t.New_Key_Contact_s_Email_address__c <> null)
  { 
    
    {
        if((Emails.contains(t.New_Key_Contact_s_Email_address__c) == true) )
            {
            t.New_Key_Contact_s_First_Name__c.addError('This contact already exists');
            t.New_Key_Contact_s_Last_Name__c.addError('This contact already exists');
            t.New_Key_Contact_s_Email_address__c.addError('This Email already exists');
            }
        else
        {
            contact c = new contact();
            c.FirstName = t.New_Key_Contact_s_First_Name__c;
            c.LastName = t.New_Key_Contact_s_Last_Name__c;
            c.Position__c = t.New_Key_Contact_s_Position__c;
            c.Email = t.New_Key_Contact_s_Email_address__c;
            NewContactList.add(c);
        }
    }

Regards
Ganesh
Hi we have a scenario where a user creates a task and enters new contacts met during a site visit, this value entered in the task object has to be checked on the contacts object and if the value is not present already a new record has to be inserted. Am a newbie to apex programming any help would be much appreciated.

in short "salesforce trigger to check if a record value entered in task object is present in the contact object and insert if not available"
Hi we have a scenario where a user creates a task and enters new contacts met during a site visit, this value entered in the contact has to be checked on the contacts object and if not present already a new record has to be inserted. Am a newbie to apex programming any help would be much appreciated.

Regards,
Ganesh
Hi All ,

Am new to Apex programmin , with some help ive written the following Apex trigger but I need to write the test class and I got the code covereage error as 0% , any help would be much appreciated.


trigger TaskTrigger on Task (after update , before insert) {
    
    set<string> Emails = new set<string>();
    list<contact>ContactList = [select id, email from contact];
    
    for(contact c: [select id, Email from contact])
    {
        Emails.add(c.Email);
    }
    
    list<contact>NewContactList = new list<contact>();
    for(task t : trigger.new)
    
  {
        if( t.Type == 'Visits') //This IF conditions checks whether task type is Meeting or not

    if (t.New_Key_Contact_s_Email_address__c <> null)
  { 
    
    {
        if((Emails.contains(t.New_Key_Contact_s_Email_address__c) == true) )
            {
            t.New_Key_Contact_s_First_Name__c.addError('This contact already exists');
            t.New_Key_Contact_s_Last_Name__c.addError('This contact already exists');
            t.New_Key_Contact_s_Email_address__c.addError('This Email already exists');
            }
        else
        {
            contact c = new contact();
            c.FirstName = t.New_Key_Contact_s_First_Name__c;
            c.LastName = t.New_Key_Contact_s_Last_Name__c;
            c.Position__c = t.New_Key_Contact_s_Position__c;
            c.Email = t.New_Key_Contact_s_Email_address__c;
            NewContactList.add(c);
        }
    }

Regards
Ganesh
Hi we have a scenario where a user creates a task and enters new contacts met during a site visit, this value entered in the contact has to be checked on the contacts object and if not present already a new record has to be inserted. Am a newbie to apex programming any help would be much appreciated.

Regards,
Ganesh