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

Field Update on Unrelated Object
Hello:
I have to unrelated custom objects - Penetration_Summary__c and Release__c.
Penetration_Summary__c and Release__c will have the same name.
I need to update a field on Penetration_Summary__c using a formula that is:
(Penetration_Summary__c.CBW_Rev__C * Release__c.CBW_Rev_Share__r.Tier_One__c)
Below is the trigger I have written but am getting an error around the map. Any thoughts on how to proceed?
trigger RevShareUpdate on Penetration_Summary__c (before insert, before update) { Set<String> penSumName = new Set<String>(); for (Penetration_Summary__c pen : Trigger.new) { if(pen.Current__c = TRUE) { penSumName.add(pen.Name); } } Map<ID, Name> releaseSumMap = new Map<ID, Name>(); for(Release__c release1:[Select ID, Name, CBW_Rev_Share__c, CBW_Rev_Share__r.Tier_One__c from Release__c Where Name IN: penSumName ]) { releaseSumMap.put(release1.ID, release1.Name); } List<Penetration_Summary__c> penForUpdate = new List<Penetration_Summary__c>(); for(Penetration_Summary__c c:[Select Id, CBW_Rev__c, CBW_Rev_Share__c from Penetration_Summary__c where Name In : releaseSumMap.Name ]) { (c.CBW_Rev_Share__c) == ((releaseSumMap.get.(c.ID).CBW_Rev_Share__r.Tier_One__c)*c.CBW_Rev__c); } update penForUpdate; }
Thanks,
Hampton
Here is the modified code
s_k_a:
Thank's for the quick reply. The good news is the code saved without any errors. It is still not putting a value into the Penetration_Summary__c.CBW_Rev_Share__c
Any other thoughts?
Thanks,
Hampton
Check the data type of fields CBW_Rev_Share__c, CBW_Rev__C on Penetration_Summary__c and Tier_one__c on Release__c. if all field data types are number s, add condition to check null values.
Here is the modified block code
So I think the issue here is still around the map. The query is looking in releaseSumMap for c.ID, which does not exist. The objects are unrelated and their Name value is the same. I've tried playing with it, changing ID to name, etc but it still won't update.
Any other thoughts?
hi change this
Appreciate the changed code, still did not get a value in the field. I am lost at this point.
Hampton