• Trinityed78
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies

Hello all! 

 

I've been trying to create a workflow rule, to add two fields together to create a new date value (in a separate custom field. 

 

So here's the background:

 

Field Names:

 

Deal End - a date field which notes when our product will end its run on our client's website. 

 

Number of Days - a formula field that looks to the contract to calculate the number of days in the contract life span in months. For example - 3 = 92 days

 

Date To Contact - a formula date field which adds Deal End + Number of Days to give us the new date after the product last featured. 

 

 

What I tried:

 

Initially it was all working well, until I discovered that the contract life span could be amended at the last minute (from 3 to 4 months - for example). But while the Number of Days changed, the Date To Contact value remained the same as the previous value. It would only changed when someone edited the record. So unfortunately workflow rules won't work here (or so I was told by Salesforce.com.

 

 

HELP??

 

Could an apex trigger, in effect, add the Deal End and the Number of Days field to produce a self-updating date value, without the user having to edit the custom object record? If so, what could this trigger look like?

 

 

 

Hope someone can help??

 

 

Ed.

 

 


Hello all! 

 

I need to learn how to write a test code coverage for my account trigger, and i've tried many time, but I just can't get my head around the logic. I've read up on so many articles, but I couldn't find any which would apply to my particular scenario. 

 

Here's the trigger:

 

 

 

trigger OnAccountOwnerChanged on Account (before insert, before update) {
    for( Account a : Trigger.new )
    {
        Account AcctBeforeUpdate = Trigger.oldMap.get( a.Id );
        if( AcctBeforeUpdate.OwnerId != a.OwnerId )
        {
            a.Previous_Owner__c = AcctBeforeUpdate.OwnerId;
        }
    }
}

 

Can anyone help me with this? 

 

 

Ed.

 

Hi all!

 

For some reason an apex test class is missing in my production environment, and I have no clue as to where it went or why it disappeared.

 

So instead of looking for it, and to save time, I am trying to create a new test class to satisfy it.

 

I know I created one a while back, but cannot remember how I formatted it (as I'm not an expert) or what was covered in the test.

 

Here's the apex class:

 

public class ext_contact_subscriptions {
 
 public Contact contact = new Contact();
 
 public Boolean emailVerified   { get; set; }
 public String enteredEmail    { get; set; }
 public Boolean success     { get; set; }
 public Boolean validationError   { get; set; }
 public string msg       { get; set; }
 
 public Subscription_Update__c subscription { get {return subscription;} set {subscription = value;} }
  
 public ext_contact_subscriptions() {
        emailVerified = false;
        validationError = false;
        success = false;
    }
    
    public PageReference validateEmail() {
    List<Contact> contacts = [select id, email, HasOptedOutOfEmail, Subscription_Update__c from contact where email = :enteredEmail];
    if (contacts.size()==1) 
      { contact = contacts[0];
    //contact.email = 'john.smith@ibs.net';     if (enteredEmail == contact.email)  {
      emailVerified = true;
      validationError = false;
      subscription = new Subscription_Update__c();
      subscription.contact__c = contact.id;
      subscription.Email_Address__c = contact.email;
     } else {
      validationError = true; 
     }
     } else {
      validationError = true; 

     }
     return null; 
    }

     
    public PageReference save() {
    
     try {
      //update contact;
     
        insert subscription;
        
         success = true;
        } catch (exception e) { 
         msg = e.getMessage(); 
        }
     
     return null; 
    }
}

 

Can anyone help me to create a test class, based on this code?

 

 

Ed.

Hello all! 

 

I've been trying to create a workflow rule, to add two fields together to create a new date value (in a separate custom field. 

 

So here's the background:

 

Field Names:

 

Deal End - a date field which notes when our product will end its run on our client's website. 

 

Number of Days - a formula field that looks to the contract to calculate the number of days in the contract life span in months. For example - 3 = 92 days

 

Date To Contact - a formula date field which adds Deal End + Number of Days to give us the new date after the product last featured. 

 

 

What I tried:

 

Initially it was all working well, until I discovered that the contract life span could be amended at the last minute (from 3 to 4 months - for example). But while the Number of Days changed, the Date To Contact value remained the same as the previous value. It would only changed when someone edited the record. So unfortunately workflow rules won't work here (or so I was told by Salesforce.com.

 

 

HELP??

 

Could an apex trigger, in effect, add the Deal End and the Number of Days field to produce a self-updating date value, without the user having to edit the custom object record? If so, what could this trigger look like?

 

 

 

Hope someone can help??

 

 

Ed.

 

 


Hello all! 

 

I need to learn how to write a test code coverage for my account trigger, and i've tried many time, but I just can't get my head around the logic. I've read up on so many articles, but I couldn't find any which would apply to my particular scenario. 

 

Here's the trigger:

 

 

 

trigger OnAccountOwnerChanged on Account (before insert, before update) {
    for( Account a : Trigger.new )
    {
        Account AcctBeforeUpdate = Trigger.oldMap.get( a.Id );
        if( AcctBeforeUpdate.OwnerId != a.OwnerId )
        {
            a.Previous_Owner__c = AcctBeforeUpdate.OwnerId;
        }
    }
}

 

Can anyone help me with this? 

 

 

Ed.

 

Hi all!

 

For some reason an apex test class is missing in my production environment, and I have no clue as to where it went or why it disappeared.

 

So instead of looking for it, and to save time, I am trying to create a new test class to satisfy it.

 

I know I created one a while back, but cannot remember how I formatted it (as I'm not an expert) or what was covered in the test.

 

Here's the apex class:

 

public class ext_contact_subscriptions {
 
 public Contact contact = new Contact();
 
 public Boolean emailVerified   { get; set; }
 public String enteredEmail    { get; set; }
 public Boolean success     { get; set; }
 public Boolean validationError   { get; set; }
 public string msg       { get; set; }
 
 public Subscription_Update__c subscription { get {return subscription;} set {subscription = value;} }
  
 public ext_contact_subscriptions() {
        emailVerified = false;
        validationError = false;
        success = false;
    }
    
    public PageReference validateEmail() {
    List<Contact> contacts = [select id, email, HasOptedOutOfEmail, Subscription_Update__c from contact where email = :enteredEmail];
    if (contacts.size()==1) 
      { contact = contacts[0];
    //contact.email = 'john.smith@ibs.net';     if (enteredEmail == contact.email)  {
      emailVerified = true;
      validationError = false;
      subscription = new Subscription_Update__c();
      subscription.contact__c = contact.id;
      subscription.Email_Address__c = contact.email;
     } else {
      validationError = true; 
     }
     } else {
      validationError = true; 

     }
     return null; 
    }

     
    public PageReference save() {
    
     try {
      //update contact;
     
        insert subscription;
        
         success = true;
        } catch (exception e) { 
         msg = e.getMessage(); 
        }
     
     return null; 
    }
}

 

Can anyone help me to create a test class, based on this code?

 

 

Ed.