-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
4Questions
-
0Replies
Apex Test Class Not Finding Account ID - Survey Force
I'm pretty new to coding and really trying to just get through an error to deploy a changeset. When validating the changeset it fails due to an error in a test class related to this Test Class SurveyAndQuestionController_Test.
Each of the methods within the class seems to be hitting the same error.
Example Error Message:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Required field: [AccountId] Stack Trace: Class.SurveyTestingUtil.createTestContact: line 67, column 1 Class.SurveyTestingUtil.: line 13, column 1 Class.SurveyAndQuestionController_Test.testCreateQuestionController: line 7, column 1
What is strange is I do not see any validation rules on either the account or the survey object.
I think it more has to do with the fact that the AccountID is not being listed in the test class.
Would you know how I specify the account ID?
----
Here is the Test Class
@istest private class SurveyAndQuestionController_Test {
//test constructor and calls within it @isTest(SeeAllData='true') private static void testCreateQuestionController(){ SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller std; SurveyAndQuestionController cqc = new SurveyAndQuestionController(std); cqc.addQuestion(); cqc.getNewQuestionNum(); cqc.makeNewQuestionLink(); System.assert(cqc.surveyId == tu.surveyId); } @isTest(SeeAllData='true') //test constructor and calls within it private static void testEditQuestion(){ SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller std; SurveyAndQuestionController cqc = new SurveyAndQuestionController(std); cqc.editQuestion(); cqc.questionReference = tu.questionIds[0]; cqc.editQuestion(); cqc.questionReference = tu.questionIds[1]; cqc.editQuestion(); cqc.questionReference = tu.questionIds[2]; cqc.editQuestion(); cqc.questionReference = tu.questionIds[3]; System.assert(cqc.editQuestion()==null); } @isTest(SeeAllData='true') //test the saving of new questions private static void testsaveAndNewQuestion(){ SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller std; SurveyAndQuestionController cqc = new SurveyAndQuestionController(std); //test saving new question cqc.qQuestion = 'THIS IS A NEW QUESTION'; cqc.qChoices = '1\\n2\\n3\\3'; cqc.qRequired=true; cqc.questionType='Single Select--Vertical'; cqc.saveAndNewQuestion(); System.assertEquals(5, cqc.getNewQuestionNum()); //edit existing question SurveyAndQuestionController cqcI = new SurveyAndQuestionController(std); cqcI.questionReference = tu.questionIds[0]; cqcI.editQuestion(); cqcI.qQuestion = 'THIS IS A NEW QUESTION THAT IS EXTRA LONG SO THE NAME SHORTENING CALL WILL BE USED, THIS SHOULD BE LONG ENOUGH NOW THIS IS A NEW'; cqcI.qChoices = '1\\n2\\n3\\3'; cqcI.qRequired=true; cqcI.questionType='Single Select--Vertical'; cqcI.saveAndNewQuestion(); System.assertEquals(5, cqcI.getNewQuestionNum()); } @isTest(SeeAllData='true') private static void testsavesaveQuestion(){ SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller std; SurveyAndQuestionController cqc = new SurveyAndQuestionController(std); //test saving new question cqc.qQuestion = 'THIS IS A NEW QUESTION'; cqc.qChoices = '1\\n2\\n3\\3'; cqc.qRequired=true; cqc.questionType='Single Select--Vertical'; cqc.controllerSavQuestion(); System.assertEquals(5, cqc.getNewQuestionNum()); //edit existing question SurveyAndQuestionController cqcI = new SurveyAndQuestionController(std); cqcI.questionReference = tu.questionIds[0]; cqcI.editQuestion(); cqcI.qQuestion = 'THIS IS A NEW QUESTION THAT IS EXTRA LONG SO THE NAME SHORTENING CALL WILL BE USED, THIS SHOULD BE LONG ENOUGH NOW'; cqcI.qChoices = '1\\n2\\n3\\3'; cqcI.qRequired=true; cqcI.questionType='Single Select--Vertical'; cqcI.controllerSavQuestion(); System.assertEquals(5, cqcI.getNewQuestionNum()); } @isTest(SeeAllData='true') //test constructor and calls within it private static void testPreviewQuestion(){ SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller std; SurveyAndQuestionController cqc = new SurveyAndQuestionController(std); cqc.questionReference = tu.questionIds[0]; cqc.editQuestion(); cqc.previewQuestion(); cqc.questionReference = tu.questionIds[1]; cqc.editQuestion(); cqc.previewQuestion(); cqc.questionReference = tu.questionIds[2]; cqc.editQuestion(); System.assert(cqc.previewQuestion()==null); cqc.questionReference = tu.questionIds[3]; cqc.editQuestion(); System.assert(cqc.previewQuestion()==null); } @isTest(SeeAllData='true') private static void testUpdateSurveyName() { SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller stc; SurveyAndQuestionController vsc = new SurveyAndQuestionController(stc); vsc.surveyName = 'new name'; system.assert(vsc.updateSurveyName() == null); } @isTest(SeeAllData='true') private static void testupdateSurveyThankYouAndLink() { SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller stc; SurveyAndQuestionController vsc = new SurveyAndQuestionController(stc); vsc.surveyThankYouText = 'new stuff'; vsc.surveyThankYouURL = 'more new stff'; system.assert(vsc.updateSurveyThankYouAndLink()==null); } //------------------------------------------------------------------------------// @isTest(SeeAllData='true') private static void testRefreshQuestionList() { SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller stc; SurveyAndQuestionController vsc = new SurveyAndQuestionController(stc); vsc.getAQuestion(); // Retrieve questions for this survey List<Survey_Question__c> sq = new List<Survey_Question__c>(); sq = [Select id, orderNumber__c from Survey_Question__c]; // get question with orderNumber 1 Survey_Question__c first = [Select id, orderNumber__c from Survey_Question__c Where orderNumber__c =: 1 and Survey__c =: tu.surveyId]; System.assert(first.orderNumber__c == 1 ); // Specify the new order vsc.newOrderW = vsc.allQuestions[2].id + ',' + vsc.allQuestions[0].id + ',' + vsc.allQuestions[1].id + ',' + vsc.allQuestions[3].id + ','; vsc.updateOrderList(); // Verify that the question with order 1 is not the same as the one retrieved previously Survey_Question__c second = [Select id, orderNumber__c from Survey_Question__c Where orderNumber__c =: 1 and Survey__c =: tu.surveyId]; System.assert(second.id != first.id); // update the question list, and make sure it has been modified as well vsc.refreshQuestionList(); System.assert(vsc.allQuestions[1].id != first.id); }
//------------------------------------------------------------------------------//
@isTest(SeeAllData='true') private static void testDeleteQuestion() { SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller stc; SurveyAndQuestionController vsc = new SurveyAndQuestionController(stc); // Get a question to delete Survey_Question__c sq = [Select id, orderNumber__c from Survey_Question__c Where orderNumber__c =: 1 and Survey__c =: tu.surveyId]; vsc.questionReference = sq.Id; vsc.deleteRefresh(); Survey_Question__c sq2 = [Select id, orderNumber__c from Survey_Question__c Where orderNumber__c =: 1 and Survey__c =: tu.surveyId]; System.assert(sq.Id != sq2.Id); }
//------------------------------------------------------------------------------//
/**/ }
Each of the methods within the class seems to be hitting the same error.
Example Error Message:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Required field: [AccountId] Stack Trace: Class.SurveyTestingUtil.createTestContact: line 67, column 1 Class.SurveyTestingUtil.: line 13, column 1 Class.SurveyAndQuestionController_Test.testCreateQuestionController: line 7, column 1
What is strange is I do not see any validation rules on either the account or the survey object.
I think it more has to do with the fact that the AccountID is not being listed in the test class.
Would you know how I specify the account ID?
----
Here is the Test Class
@istest private class SurveyAndQuestionController_Test {
//test constructor and calls within it @isTest(SeeAllData='true') private static void testCreateQuestionController(){ SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller std; SurveyAndQuestionController cqc = new SurveyAndQuestionController(std); cqc.addQuestion(); cqc.getNewQuestionNum(); cqc.makeNewQuestionLink(); System.assert(cqc.surveyId == tu.surveyId); } @isTest(SeeAllData='true') //test constructor and calls within it private static void testEditQuestion(){ SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller std; SurveyAndQuestionController cqc = new SurveyAndQuestionController(std); cqc.editQuestion(); cqc.questionReference = tu.questionIds[0]; cqc.editQuestion(); cqc.questionReference = tu.questionIds[1]; cqc.editQuestion(); cqc.questionReference = tu.questionIds[2]; cqc.editQuestion(); cqc.questionReference = tu.questionIds[3]; System.assert(cqc.editQuestion()==null); } @isTest(SeeAllData='true') //test the saving of new questions private static void testsaveAndNewQuestion(){ SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller std; SurveyAndQuestionController cqc = new SurveyAndQuestionController(std); //test saving new question cqc.qQuestion = 'THIS IS A NEW QUESTION'; cqc.qChoices = '1\\n2\\n3\\3'; cqc.qRequired=true; cqc.questionType='Single Select--Vertical'; cqc.saveAndNewQuestion(); System.assertEquals(5, cqc.getNewQuestionNum()); //edit existing question SurveyAndQuestionController cqcI = new SurveyAndQuestionController(std); cqcI.questionReference = tu.questionIds[0]; cqcI.editQuestion(); cqcI.qQuestion = 'THIS IS A NEW QUESTION THAT IS EXTRA LONG SO THE NAME SHORTENING CALL WILL BE USED, THIS SHOULD BE LONG ENOUGH NOW THIS IS A NEW'; cqcI.qChoices = '1\\n2\\n3\\3'; cqcI.qRequired=true; cqcI.questionType='Single Select--Vertical'; cqcI.saveAndNewQuestion(); System.assertEquals(5, cqcI.getNewQuestionNum()); } @isTest(SeeAllData='true') private static void testsavesaveQuestion(){ SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller std; SurveyAndQuestionController cqc = new SurveyAndQuestionController(std); //test saving new question cqc.qQuestion = 'THIS IS A NEW QUESTION'; cqc.qChoices = '1\\n2\\n3\\3'; cqc.qRequired=true; cqc.questionType='Single Select--Vertical'; cqc.controllerSavQuestion(); System.assertEquals(5, cqc.getNewQuestionNum()); //edit existing question SurveyAndQuestionController cqcI = new SurveyAndQuestionController(std); cqcI.questionReference = tu.questionIds[0]; cqcI.editQuestion(); cqcI.qQuestion = 'THIS IS A NEW QUESTION THAT IS EXTRA LONG SO THE NAME SHORTENING CALL WILL BE USED, THIS SHOULD BE LONG ENOUGH NOW'; cqcI.qChoices = '1\\n2\\n3\\3'; cqcI.qRequired=true; cqcI.questionType='Single Select--Vertical'; cqcI.controllerSavQuestion(); System.assertEquals(5, cqcI.getNewQuestionNum()); } @isTest(SeeAllData='true') //test constructor and calls within it private static void testPreviewQuestion(){ SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller std; SurveyAndQuestionController cqc = new SurveyAndQuestionController(std); cqc.questionReference = tu.questionIds[0]; cqc.editQuestion(); cqc.previewQuestion(); cqc.questionReference = tu.questionIds[1]; cqc.editQuestion(); cqc.previewQuestion(); cqc.questionReference = tu.questionIds[2]; cqc.editQuestion(); System.assert(cqc.previewQuestion()==null); cqc.questionReference = tu.questionIds[3]; cqc.editQuestion(); System.assert(cqc.previewQuestion()==null); } @isTest(SeeAllData='true') private static void testUpdateSurveyName() { SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller stc; SurveyAndQuestionController vsc = new SurveyAndQuestionController(stc); vsc.surveyName = 'new name'; system.assert(vsc.updateSurveyName() == null); } @isTest(SeeAllData='true') private static void testupdateSurveyThankYouAndLink() { SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller stc; SurveyAndQuestionController vsc = new SurveyAndQuestionController(stc); vsc.surveyThankYouText = 'new stuff'; vsc.surveyThankYouURL = 'more new stff'; system.assert(vsc.updateSurveyThankYouAndLink()==null); } //------------------------------------------------------------------------------// @isTest(SeeAllData='true') private static void testRefreshQuestionList() { SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller stc; SurveyAndQuestionController vsc = new SurveyAndQuestionController(stc); vsc.getAQuestion(); // Retrieve questions for this survey List<Survey_Question__c> sq = new List<Survey_Question__c>(); sq = [Select id, orderNumber__c from Survey_Question__c]; // get question with orderNumber 1 Survey_Question__c first = [Select id, orderNumber__c from Survey_Question__c Where orderNumber__c =: 1 and Survey__c =: tu.surveyId]; System.assert(first.orderNumber__c == 1 ); // Specify the new order vsc.newOrderW = vsc.allQuestions[2].id + ',' + vsc.allQuestions[0].id + ',' + vsc.allQuestions[1].id + ',' + vsc.allQuestions[3].id + ','; vsc.updateOrderList(); // Verify that the question with order 1 is not the same as the one retrieved previously Survey_Question__c second = [Select id, orderNumber__c from Survey_Question__c Where orderNumber__c =: 1 and Survey__c =: tu.surveyId]; System.assert(second.id != first.id); // update the question list, and make sure it has been modified as well vsc.refreshQuestionList(); System.assert(vsc.allQuestions[1].id != first.id); }
//------------------------------------------------------------------------------//
@isTest(SeeAllData='true') private static void testDeleteQuestion() { SurveyTestingUtil tu = new SurveyTestingUtil(); Apexpages.currentPage().getParameters().put('id',tu.surveyId); Apexpages.Standardcontroller stc; SurveyAndQuestionController vsc = new SurveyAndQuestionController(stc); // Get a question to delete Survey_Question__c sq = [Select id, orderNumber__c from Survey_Question__c Where orderNumber__c =: 1 and Survey__c =: tu.surveyId]; vsc.questionReference = sq.Id; vsc.deleteRefresh(); Survey_Question__c sq2 = [Select id, orderNumber__c from Survey_Question__c Where orderNumber__c =: 1 and Survey__c =: tu.surveyId]; System.assert(sq.Id != sq2.Id); }
//------------------------------------------------------------------------------//
/**/ }
-
- TobyDog
- May 16, 2019
- Like
- 0
- Continue reading or reply
Straight Forward Trigger for Beginner
Hi Guys,
I have a trigger creation question that I think is pretty striaght forward, however I'm still pretty new to APEX and wanted to see if you could help.
I have a custom object called Interest which contains two custom fields I want to update the opportunity with. There is a look-up relationship from the Interest to the Opportunity. Interest records (that already have the relevant fields populated) are automatically associated with opportunities when opportunities are created.
Custom Object : Interests
API Name: Interest__c
Fields on Interest Record
Core Lead ID
Api Name: Core_Lead_Id__c
Core Instance ID
API Name: Core_Instance_id__c
Fields on Opportunity
Core Lead ID
Api Name: Core_Lead_Id__c
Core Instance ID
API Name: Core_Instance_id__c
I want to populate the opportunity fields upon creation of the opportunity which happens at the conversion of a lead, although it really doesn't matter as long as it happens before the opportunity reaches the stage "Enrolled" There are 4 stages before. Let's call them. Stage 1, Stage 2, Stage, 3.
I have a trigger creation question that I think is pretty striaght forward, however I'm still pretty new to APEX and wanted to see if you could help.
I have a custom object called Interest which contains two custom fields I want to update the opportunity with. There is a look-up relationship from the Interest to the Opportunity. Interest records (that already have the relevant fields populated) are automatically associated with opportunities when opportunities are created.
Custom Object : Interests
API Name: Interest__c
Fields on Interest Record
Core Lead ID
Api Name: Core_Lead_Id__c
Core Instance ID
API Name: Core_Instance_id__c
Fields on Opportunity
Core Lead ID
Api Name: Core_Lead_Id__c
Core Instance ID
API Name: Core_Instance_id__c
I want to populate the opportunity fields upon creation of the opportunity which happens at the conversion of a lead, although it really doesn't matter as long as it happens before the opportunity reaches the stage "Enrolled" There are 4 stages before. Let's call them. Stage 1, Stage 2, Stage, 3.
-
- TobyDog
- March 03, 2015
- Like
- 0
- Continue reading or reply
Activity Hour Time Stamp - Daylight Savings Accounted For
I have an interesting one for you.
We want to create a text field that will show the hour activity record was created and an "A.M. or P.M." after it, however it needs to compensate for Daylight Saving Time.
I have created the formula however, it is hard coded to either Eastern Standard Time or Daylight Savings.
I need help with the logic that would combine both into the same field. I think adding a simple IF statement would work but I am not sure how to fit it in.
-
Here is the formula for EST and EDT below. Daylight Savings is this year from 3/9/2014 to 11/2/2014. Thanks for your help!
EST:
Text(CASE(VALUE(MID(TEXT( CreatedDate ) , 12, 2)), 00 , 7,
01 , 8,
02 , 9,
03, 10,
04 , 11,
05 , 12,
06 , 1,
07 , 2,
08 , 3,
09 , 4,
10 , 5,
11 , 6,
12 , 7,
13 , 8,
14 , 9,
15 , 10,
16 , 11,
17 , 12,
18 , 1,
19 , 2,
20 , 3,
21 , 4,
22 , 5,
23 , 6, 24))
& IF(AND(VALUE(MID(TEXT( CreatedDate ) , 12, 2)) > 4, VALUE(MID(TEXT( CreatedDate ) , 12, 2)) < 17), " a.m.", " p.m.")
EDT:
Text(CASE(VALUE(MID(TEXT( CreatedDate ) , 12, 2)), 00 , 8,
01 , 9,
02 , 10,
03, 11,
04 , 12,
05 , 1,
06 , 2,
07 , 3,
08 , 4,
09 , 5,
10 , 6,
11 , 7,
12 , 8,
13 , 9,
14 , 10,
15 , 11,
16 , 12,
17 , 1,
18 , 2,
19 , 3,
20 , 4,
21 , 5,
22 , 6,
23 , 7, 24))
& IF(AND(VALUE(MID(TEXT( CreatedDate ) , 12, 2)) > 4, VALUE(MID(TEXT( CreatedDate ) , 12, 2)) < 17), " a.m.", " p.m.")
We want to create a text field that will show the hour activity record was created and an "A.M. or P.M." after it, however it needs to compensate for Daylight Saving Time.
I have created the formula however, it is hard coded to either Eastern Standard Time or Daylight Savings.
I need help with the logic that would combine both into the same field. I think adding a simple IF statement would work but I am not sure how to fit it in.
-
Here is the formula for EST and EDT below. Daylight Savings is this year from 3/9/2014 to 11/2/2014. Thanks for your help!
EST:
Text(CASE(VALUE(MID(TEXT( CreatedDate ) , 12, 2)), 00 , 7,
01 , 8,
02 , 9,
03, 10,
04 , 11,
05 , 12,
06 , 1,
07 , 2,
08 , 3,
09 , 4,
10 , 5,
11 , 6,
12 , 7,
13 , 8,
14 , 9,
15 , 10,
16 , 11,
17 , 12,
18 , 1,
19 , 2,
20 , 3,
21 , 4,
22 , 5,
23 , 6, 24))
& IF(AND(VALUE(MID(TEXT( CreatedDate ) , 12, 2)) > 4, VALUE(MID(TEXT( CreatedDate ) , 12, 2)) < 17), " a.m.", " p.m.")
EDT:
Text(CASE(VALUE(MID(TEXT( CreatedDate ) , 12, 2)), 00 , 8,
01 , 9,
02 , 10,
03, 11,
04 , 12,
05 , 1,
06 , 2,
07 , 3,
08 , 4,
09 , 5,
10 , 6,
11 , 7,
12 , 8,
13 , 9,
14 , 10,
15 , 11,
16 , 12,
17 , 1,
18 , 2,
19 , 3,
20 , 4,
21 , 5,
22 , 6,
23 , 7, 24))
& IF(AND(VALUE(MID(TEXT( CreatedDate ) , 12, 2)) > 4, VALUE(MID(TEXT( CreatedDate ) , 12, 2)) < 17), " a.m.", " p.m.")
-
- TobyDog
- February 20, 2014
- Like
- 1
- Continue reading or reply
Formula Help
Hi all!
I am creating a formula that counts events for a company. The hitch is - if the "meeting type" field (which is a custom picklist) on the activity record is "conference call" or "web meeting" - I do not want it to count it.
I put together the formula below - but it does not seem to be working. Any help would be very appreciated.
IF( AND(Activity_Type__c = "Event", OR( NOT( ISPICKVAL(Meeting_Type__c, "Conference Call")), NOT(ISPICKVAL(Meeting_Type__c, "Web Conference"))))
, 1, 0)
Actiivty_Type__C is a text formula field that will either be "Event" or "Task".
Best regards,
John
-
- TobyDog
- December 11, 2013
- Like
- 0
- Continue reading or reply
Activity Hour Time Stamp - Daylight Savings Accounted For
I have an interesting one for you.
We want to create a text field that will show the hour activity record was created and an "A.M. or P.M." after it, however it needs to compensate for Daylight Saving Time.
I have created the formula however, it is hard coded to either Eastern Standard Time or Daylight Savings.
I need help with the logic that would combine both into the same field. I think adding a simple IF statement would work but I am not sure how to fit it in.
-
Here is the formula for EST and EDT below. Daylight Savings is this year from 3/9/2014 to 11/2/2014. Thanks for your help!
EST:
Text(CASE(VALUE(MID(TEXT( CreatedDate ) , 12, 2)), 00 , 7,
01 , 8,
02 , 9,
03, 10,
04 , 11,
05 , 12,
06 , 1,
07 , 2,
08 , 3,
09 , 4,
10 , 5,
11 , 6,
12 , 7,
13 , 8,
14 , 9,
15 , 10,
16 , 11,
17 , 12,
18 , 1,
19 , 2,
20 , 3,
21 , 4,
22 , 5,
23 , 6, 24))
& IF(AND(VALUE(MID(TEXT( CreatedDate ) , 12, 2)) > 4, VALUE(MID(TEXT( CreatedDate ) , 12, 2)) < 17), " a.m.", " p.m.")
EDT:
Text(CASE(VALUE(MID(TEXT( CreatedDate ) , 12, 2)), 00 , 8,
01 , 9,
02 , 10,
03, 11,
04 , 12,
05 , 1,
06 , 2,
07 , 3,
08 , 4,
09 , 5,
10 , 6,
11 , 7,
12 , 8,
13 , 9,
14 , 10,
15 , 11,
16 , 12,
17 , 1,
18 , 2,
19 , 3,
20 , 4,
21 , 5,
22 , 6,
23 , 7, 24))
& IF(AND(VALUE(MID(TEXT( CreatedDate ) , 12, 2)) > 4, VALUE(MID(TEXT( CreatedDate ) , 12, 2)) < 17), " a.m.", " p.m.")
We want to create a text field that will show the hour activity record was created and an "A.M. or P.M." after it, however it needs to compensate for Daylight Saving Time.
I have created the formula however, it is hard coded to either Eastern Standard Time or Daylight Savings.
I need help with the logic that would combine both into the same field. I think adding a simple IF statement would work but I am not sure how to fit it in.
-
Here is the formula for EST and EDT below. Daylight Savings is this year from 3/9/2014 to 11/2/2014. Thanks for your help!
EST:
Text(CASE(VALUE(MID(TEXT( CreatedDate ) , 12, 2)), 00 , 7,
01 , 8,
02 , 9,
03, 10,
04 , 11,
05 , 12,
06 , 1,
07 , 2,
08 , 3,
09 , 4,
10 , 5,
11 , 6,
12 , 7,
13 , 8,
14 , 9,
15 , 10,
16 , 11,
17 , 12,
18 , 1,
19 , 2,
20 , 3,
21 , 4,
22 , 5,
23 , 6, 24))
& IF(AND(VALUE(MID(TEXT( CreatedDate ) , 12, 2)) > 4, VALUE(MID(TEXT( CreatedDate ) , 12, 2)) < 17), " a.m.", " p.m.")
EDT:
Text(CASE(VALUE(MID(TEXT( CreatedDate ) , 12, 2)), 00 , 8,
01 , 9,
02 , 10,
03, 11,
04 , 12,
05 , 1,
06 , 2,
07 , 3,
08 , 4,
09 , 5,
10 , 6,
11 , 7,
12 , 8,
13 , 9,
14 , 10,
15 , 11,
16 , 12,
17 , 1,
18 , 2,
19 , 3,
20 , 4,
21 , 5,
22 , 6,
23 , 7, 24))
& IF(AND(VALUE(MID(TEXT( CreatedDate ) , 12, 2)) > 4, VALUE(MID(TEXT( CreatedDate ) , 12, 2)) < 17), " a.m.", " p.m.")
-
- TobyDog
- February 20, 2014
- Like
- 1
- Continue reading or reply