-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
5Questions
-
0Replies
Write a Test Case for Trigger
Can you let me know how should I begin with and what things I should take into consideration.
Trigger
Trigger
trigger Timecard on pse__Timecard_Header__c (after insert) { List<pse__Timecard_Header__c> tc_list = [select Id, pse__End_Date__c, pse__Project__r.pse__Region__r.ffpsai__OwnerCompany__r.Id from pse__Timecard_Header__c where Id IN :Trigger.newMap.KeySet()]; system.debug('TC_LIST: ' + tc_list); Set<Date> tc_setofDate = new Set<Date>(); Set<Id> tc_setofId = new Set<Id>(); for (pse__Timecard_Header__c tcdate: tc_list) { Date aDate = tcdate.pse__End_Date__c.toStartOfMonth(); tc_setofDate.add(aDate); system.debug('SET DATE ' + tc_setofDate); } for (pse__Timecard_Header__c tcId: tc_list) { Id ids = tcId.pse__Project__r.pse__Region__r.ffpsai__OwnerCompany__c; tc_setofId.add(ids); system.debug('SET ID ' + tc_setofId); } List <c2g__codaPeriod__c> periodDetails = [Select Id, c2g__StartDate__c,c2g__EndDate__c, c2g__OwnerCompany__c from c2g__codaPeriod__c where c2g__StartDate__c IN: tc_setofDate and c2g__OwnerCompany__c IN: tc_setofId]; system.debug('PERIOD_DETAILS: ' + periodDetails); List<pse__Timecard_Header__c> tcUpdate = new List<pse__Timecard_Header__c>(); for (pse__Timecard_Header__c timecardCompare: tc_list){ for (c2g__codaPeriod__c periodCompare: periodDetails){ if ((timecardCompare.pse__End_Date__c.toStartOfMonth() == periodCompare.c2g__StartDate__c) && (timecardCompare.pse__Project__r.pse__Region__r.ffpsai__OwnerCompany__c == periodCompare.c2g__OwnerCompany__c)) { timecardCompare.Period__c = periodCompare.Id; tcUpdate.add(timecardCompare); } } } update tcUpdate; }
-
- sagarshah
- December 05, 2014
- Like
- 0
- Continue reading or reply
How to fill my lookup field evrytime I create a new Timecard?
I have an object Timecard <pse__Timecard_Header__c> and a lookup field PD <PD__c> which is related to another object called Period i.e. <c2g__codaPeriod__c>. I want to fill this lookup field everytime I create a new Timecard.
-
- sagarshah
- December 02, 2014
- Like
- 0
- Continue reading or reply
How to find whether Google Maps API is licensed or not?
I am using Google maps API in my salesforce application. I am using this javascript file https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places (https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places) to integrate my application with google maps.
Usually with google, a key should be used to access this API. The idea is that this API is not free and we should license this, we may be using a development version but this version is limited based on number of calls and requests.
I looked into the javascript file, also in the controller class but was not able to determine or find the key.
I just want to find out are we using a licensed version ?
Usually with google, a key should be used to access this API. The idea is that this API is not free and we should license this, we may be using a development version but this version is limited based on number of calls and requests.
I looked into the javascript file, also in the controller class but was not able to determine or find the key.
I just want to find out are we using a licensed version ?
-
- sagarshah
- November 24, 2014
- Like
- 0
- Continue reading or reply
Trigger to validate if the update is for rejecting timecard
I want to validate the timecard if it is updating for a rejection then only I want to continue.
-
- sagarshah
- November 18, 2014
- Like
- 0
- Continue reading or reply
Trigger to match fields in another object
I have 2 custom objects
Timecard (pse__Timecard_Header__c)
Period (c2g__codaPeriod__c).
They don't have relationship.
Timecard fields:- Start date (pse__Start_Date__c), Close date (pse__CloseDate__c), Project (pse__Proj__c). Now here, inside project is one field Region (pse__Region__c).
Period fields:- Start date (c2g__StartDate__c), Close date (c2g__Closed__c), Region (c2g__Region__c ), status (checkbox).
If the status is checked and start date, close date and region are matching with the start date, close date and region of Timecard object then I want Timecard to be rejected.
I started with the following code but then get lost realising I don't have direct access to region inside project.
Timecard (pse__Timecard_Header__c)
Period (c2g__codaPeriod__c).
They don't have relationship.
Timecard fields:- Start date (pse__Start_Date__c), Close date (pse__CloseDate__c), Project (pse__Proj__c). Now here, inside project is one field Region (pse__Region__c).
Period fields:- Start date (c2g__StartDate__c), Close date (c2g__Closed__c), Region (c2g__Region__c ), status (checkbox).
If the status is checked and start date, close date and region are matching with the start date, close date and region of Timecard object then I want Timecard to be rejected.
I started with the following code but then get lost realising I don't have direct access to region inside project.
trigger TimecardRejection on pse__Timecard_Header__c (before update) { List tcdata = new List (); for(pse__Timecard_Header__c tc: Trigger.new) { tc.pse__Start_Date__c tc.pse__End_Date__c tcdata.add(tc); } }Any help would be appreciated. Thanks in advance.
-
- sagarshah
- November 17, 2014
- Like
- 0
- Continue reading or reply