• sagarshah
  • 0 Points
  • Member since 2014

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
  • 0
Can you let me know how should I begin with and what things I should take into consideration.

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();
            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;
            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;
  		update tcUpdate;

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.
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 ?
I want to validate the timecard if it is updating for a rejection then only I want to continue.
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.
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.