You need to sign in to do that
Don't have an account?
frank2anil
help me with trigger
hi guys,
I have a relatd list called feed back on accounts and contacts.
My requirement is when ever a feedback is created it should display in the relatd opportunity also.
if a feedback is created from oppty it should visible in contact also.
please help me with a triigger.
Thanks in advance.
Thanks
Frank
can you explain little more about feed back object? Are you using task object or is it a custom object?
Hi sam_sfdc
My requirement is i have a custom object called feed back .which is having lookup of onto contact,oopportunity,payments.
when ever i have created a new efeedback records from contact object.
Then if the contact is having opportunity then these feedback sholud be appear in opportunity related list comments.
If attach a new feedback in opportunity it should attach to related contact of opportunity as well as fpayments object.
Simply when ever u create a feedback from contact or opportunity or payments these comment should be appear in all the
objects related list.
Thanks
Frank.
Suppose Feedback is added to a Contact, then you need to find the opportunity to which this contact is related with. It can be done by querying OpportunityContactRole object. So you might use something like this,
List<OpportunityContactRole> listCRole = [Select ContactId,OpportunityId FROM OpportunityContactRole WHERE ContactId IN: Trigger.newMap.keySet()];
Then in 2 for loops (for(Feedback__c f : Trigger.New), and for(OpportunityContactRole ocr: listCRole)) you can iterate and check for the matching ContactId, once match found, just update the current record - i.e. here, f.Opportunity__c = ocr.OpportunityId.
Please note that you might require additional maps/sets/lists to handle records in bulk.