You need to sign in to do that
Don't have an account?
sfadm sfadm
Trigger not updating a record field
In my code
I'm using the before update trigger in order to populate the calculated working hours into a custom field called "CalculatedWorkingHours__c".
I can see in the debug log that the "CalculatedWorkingHours__c" field is updated
Please advise what can be the issue and why the field is not populated in the record?
trigger ContactRole on Application__c (before update) { // Get the time between the last aTeam and bTeam DateTime lastUWCreated = lastCCUW.Created_Date__c; System.debug('lastUWCreated ' + lastUWCreated); DateTime lastAmTeamCreated = lastCCRiskAndChecked.Created_Date__c; System.debug('lastAmTeamCreated ' + lastAmTeamCreated); Double workingHours = calculateWorkingHours(lastUWCreated, lastAmTeamCreated); System.debug('workingHours ' + workingHours); Id ccAppId = lastAmTeamCreated.Id; List<Application__c> ccAppList = [SELECT CalculatedWorkingHours__c from Application__c where id = :ccAppId]; Application__c appRecord = ccAppList.get(0); appRecord.CalculatedWorkingHours__c = workingHours; System.debug('appRecord.CalculatedWorkingHours__c ' + appRecord.CalculatedWorkingHours__c); }
I'm using the before update trigger in order to populate the calculated working hours into a custom field called "CalculatedWorkingHours__c".
I can see in the debug log that the "CalculatedWorkingHours__c" field is updated
USER_DEBUG [184]|DEBUG|workingHours 17.5 USER_DEBUG [194]|DEBUG|ccAppRecord.CalculatedWorkingHours__c 17.5but on a record level the field remains blank
Please advise what can be the issue and why the field is not populated in the record?
try above one and make sure that if any class with name Application__c is present in your system, delete/rename it and then try.
Thanks
All Answers
Use the above code snippet and let me know, if you have any question.
Thanks
Hope this helps.
Hi Waqar,
I followed your suggestion and used your implementation however on line 12 I recieve the following problem:
try above one and make sure that if any class with name Application__c is present in your system, delete/rename it and then try.
Thanks