-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
7Questions
-
9Replies
Newbie question
OK...I have my classes and trigger working in my sandbox; how do I get them created in my prod org? I do not have an Add button in Prod like I did in the sandbox.
-
- LisaSturz
- August 30, 2013
- Like
- 0
- Continue reading or reply
Code question
I am getting the following error when executing my test code...does anyone know how to fix?:
System.AssertException: Assertion Failed: Expected: 1, Actual: null
Class.TestActivityCount.testCountTask: line 18, column 1
test code:
@istest
private class TestActivityCount{
/*
* Test method for this class and TaskUpdateContact and EventUpdateContact
*/
public static testMethod void testCountTask() {
//Setup
Contact con = new Contact(lastname='Test Con');
insert con;
//Insert our first task
Task t = new Task(subject='Test Activity', whoId = con.id, activity_Type__c='Visit', macro_service_line__c='ASC');
insert t;
//Verify count
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(1,con.activity_count__c);
//Disconnect task from the contact
// didRun = false; //Reset
t.whatId = null;
update t;
//Verify count = 0
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(0,con.activity_count__c);
//didRun = false; //Reset
//Add an event
Event e = new Event(subject='Test Event', whatId = con.id, startDateTime = System.Now(), endDateTime = System.now());
insert e;
//Verify count = 1
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(1,con.activity_count__c);
//Relink the task to the contact
//didRun = false; //Reset
t.whatId = con.id;
update t;
//Verify count = 2
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(2,con.activity_count__c);
//Disconnect the event from the contact
//didRun = false; //Reset
e.whatId = null;
update e;
//Verify count is back down to 1
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(1,con.activity_count__c);
//Delete the task
// didRun = false; //reset
delete t;
//Verify count is back down to 0
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(0,con.activity_count__c);
}
}
-
- LisaSturz
- August 29, 2013
- Like
- 0
- Continue reading or reply
Code to count completed activities on a contact
I would like to tweak the apex code in the link below to count the number of activities on the CONTACT object and only if the activity status = "COMPLETED". Does anyone know how I can do that?
Link: http://www.radialweb.com/2010/08/summarizing_salesforce_fields_with_triggers/#comments
-
- LisaSturz
- August 28, 2013
- Like
- 0
- Continue reading or reply
Default Value based on field on page
Is there a way to set the default value of a field based on the value of another field on the page layout? We would like to default a date field to 1/1/ of the current year only if the Network field is set to "ACN". Thank you!
-
- LisaSturz
- August 22, 2013
- Like
- 0
- Continue reading or reply
Trigger to set default value
Is there a way to use a trigger to set the default value of a date field on a custom object based on the value of another field on the page?
-
- LisaSturz
- August 22, 2013
- Like
- 0
- Continue reading or reply
Trigger to update a field on all child objects when a parent object field is updated
I have a junction object created between Accounts and Contacts called Affiliations. Any time a user updates a particular field on an Account record(ACO CMS Pending checkbox = false), I need to update a field on all of the related Affiliation records (ACO Participation = Yes). Could anyone point me in the right direction to getting this working? I tried a cross-object workflow rule, but it didn't appear to be working because I need to update the child records and not the parent record, so I am assuming I need to write a trigger. Unfortunately, this is my first so I could use assistance. Thanks!
-
- LisaSturz
- August 22, 2013
- Like
- 0
- Continue reading or reply
Add Filtered Dashboard to a VF page that is added to Contacts page layout
I would like to add a dashboard to our contacts page layout that displays a graphical interpretation of one of the related lists on that particular contact. Example: Contact: John Doe has a related list of Claims, each with a Type. When opening the John Doe record detail page, I would like to see a pie chart with the claim types (& percentage of total) as slices. Is this possible?
-
- LisaSturz
- July 24, 2013
- Like
- 0
- Continue reading or reply
Newbie question
OK...I have my classes and trigger working in my sandbox; how do I get them created in my prod org? I do not have an Add button in Prod like I did in the sandbox.
- LisaSturz
- August 30, 2013
- Like
- 0
- Continue reading or reply
Code question
I am getting the following error when executing my test code...does anyone know how to fix?:
System.AssertException: Assertion Failed: Expected: 1, Actual: null
Class.TestActivityCount.testCountTask: line 18, column 1
test code:
@istest
private class TestActivityCount{
/*
* Test method for this class and TaskUpdateContact and EventUpdateContact
*/
public static testMethod void testCountTask() {
//Setup
Contact con = new Contact(lastname='Test Con');
insert con;
//Insert our first task
Task t = new Task(subject='Test Activity', whoId = con.id, activity_Type__c='Visit', macro_service_line__c='ASC');
insert t;
//Verify count
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(1,con.activity_count__c);
//Disconnect task from the contact
// didRun = false; //Reset
t.whatId = null;
update t;
//Verify count = 0
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(0,con.activity_count__c);
//didRun = false; //Reset
//Add an event
Event e = new Event(subject='Test Event', whatId = con.id, startDateTime = System.Now(), endDateTime = System.now());
insert e;
//Verify count = 1
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(1,con.activity_count__c);
//Relink the task to the contact
//didRun = false; //Reset
t.whatId = con.id;
update t;
//Verify count = 2
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(2,con.activity_count__c);
//Disconnect the event from the contact
//didRun = false; //Reset
e.whatId = null;
update e;
//Verify count is back down to 1
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(1,con.activity_count__c);
//Delete the task
// didRun = false; //reset
delete t;
//Verify count is back down to 0
con = [SELECT ID, activity_count__c FROM Contact WHERE ID = :con.id];
System.assertEquals(0,con.activity_count__c);
}
}
- LisaSturz
- August 29, 2013
- Like
- 0
- Continue reading or reply
Code to count completed activities on a contact
I would like to tweak the apex code in the link below to count the number of activities on the CONTACT object and only if the activity status = "COMPLETED". Does anyone know how I can do that?
Link: http://www.radialweb.com/2010/08/summarizing_salesforce_fields_with_triggers/#comments
- LisaSturz
- August 28, 2013
- Like
- 0
- Continue reading or reply
Trigger to update a field on all child objects when a parent object field is updated
I have a junction object created between Accounts and Contacts called Affiliations. Any time a user updates a particular field on an Account record(ACO CMS Pending checkbox = false), I need to update a field on all of the related Affiliation records (ACO Participation = Yes). Could anyone point me in the right direction to getting this working? I tried a cross-object workflow rule, but it didn't appear to be working because I need to update the child records and not the parent record, so I am assuming I need to write a trigger. Unfortunately, this is my first so I could use assistance. Thanks!
- LisaSturz
- August 22, 2013
- Like
- 0
- Continue reading or reply