You need to sign in to do that
Don't have an account?

Trigger Misfiring
I have written below Cross Object value transition trigger ...
When the status field on Monthly Activity is either of the 4 values, I would like to capture these 4 values from Approver_Editorial/Financial and ApproverE/F_Date ... And then assign them to 4 fields on ExpertMmonthlyAudit object...
The only connection between the 2 objects is via a lookup.
Unfortunately the fields on the 'ExpertMmonthlyAudit' are still blank.
Not sure what I am doing wrong.
Can any one care to point out.
Thanks!
When the status field on Monthly Activity is either of the 4 values, I would like to capture these 4 values from Approver_Editorial/Financial and ApproverE/F_Date ... And then assign them to 4 fields on ExpertMmonthlyAudit object...
The only connection between the 2 objects is via a lookup.
Unfortunately the fields on the 'ExpertMmonthlyAudit' are still blank.
Not sure what I am doing wrong.
Can any one care to point out.
Thanks!
trigger updateValues on Monthly_Activity__c (before insert, before update) { Set<Id> Ids= new Set<Id>(); for ( Monthly_Activity__c m: Trigger.new){ if(m.Status__c == 'Rejected by Editorial' || m.Status__c == 'Submitted to Finance' || m.Status__c == 'Rejected by Finance' || m.Status__c == 'Approved'){ Ids.add(m.Id); } } List<Monthly_Activity__c> mList = new List<Monthly_Activity__c>([SELECT Id, Status__c, Approver_Editorial__c, Approver_Financial__c,ApproverE_Date__c, ApproverF_Date__c FROM Monthly_Activity__c WHERE Id in:Ids]); for(Monthly_Activity__c temp : mList){ ExpertMonthlyAudit__c mVal = new ExpertMonthlyAudit__c(); mVal.EditName__c = temp.Approver_Editorial__c; mVal.FinName__c = temp.Approver_Financial__c; mVal.EditDate__c =temp.ApproverE_Date__c; mVal.FinDate__c = temp.ApproverF_Date__c; insert mVal; } }
Lookup field API ... Lookup_Monthly_Activity__c
And to asnwer your second question .... No. Status field for a single record will go through multiple steps, and I would like to update the 4 values based on status progression.
The reason is I need all affiliated records based on each status__c value as I need to display all those values on a progress bar.
So I need Name and Date from each Status level.
Below is the code based on that,
So the deal is that the entire approval life cycle needs to be shown as an Audit Log..
Unsubmitted >> Submitted By>> <Details of user> >> Approved/Rejected By >><Details of user> >> Submitted for 2nd approval >> Approved/Rejected By >> <Details of user>
I used your approach , but the fields are still empty...
I checked the list view for the object and found that at every stage, the trigger is creatying a new records...
Here are the 3 screen shots ..
Upon initial submission...
After 1st approval..
After 2nd Approval...
Is the fields on the MonthlyAudittable has these fields populated. I know this sounds silly, but wanted to confirm.
Could you add debug statement for these four fields and see how its going after every stage of approval.
Yes, the fields did get populated.. But by the 3rd record, Salesforce lost the parent record of Monthly Activity for which it is supposed to siplay this information ...
See that Month, Year, User, Timestamp, Type, Total are all filled out for the first screenshot.
Starting second, we have a blank.
Probably that why my Audit Log shows blank for the EditName/EditDate and FinName/FinDate... because Salesforce is not able to capture from where the information is supposed to come in...