-1

I have a requirement to update the Lookup field on the Opportunity with the Account from OpportunityPartner.

As OpportunityPartner is read only object ,i am facing lot of challenges .

let me know if there is any way to do it

6
  • Oppurtunity partner can be queried and if we are stamping just account Id not sure whats the problem.Can you elaborate a little Commented Oct 9, 2012 at 7:43
  • as i mentioned in my Question, I want the Partner Lookup field on the Opportunity to be updated with Account from OpportunityPartner. I want to know how can i trigger this to happen. Yes we can query on the Opportunitypartner,but any approach how to achieve the above requirement ?? Commented Oct 9, 2012 at 7:46
  • I think your question is not very clear, what field exactly you need to update on the opportunity object?
    – PepeFloyd
    Commented Oct 9, 2012 at 7:50
  • Ok. I have an Opportunity and it has a look up field called Partner account .Now we want to update this look up field with the AccountToId from OpportunityPartner object. salesforce.com/us/developer/docs/api/Content/… Hope this is clear. Commented Oct 9, 2012 at 7:54
  • In a before update trigger you could query the OpportunityPartner object, get the AccointToId value and update your custom lookup field in the opportunity with this value. But that was already said, perhaps you could share the code you have developed and shows the errors you are getting.
    – PepeFloyd
    Commented Oct 9, 2012 at 8:15

2 Answers 2

2

Vipul

this is not possible without the use of an Apex Trigger ( see success.salesforce.com topic here) as lookup fields cannot be updated via Workflow.

You will need to write some custom apex code in order to be able to perform this.

UPDATED:

The best solution for this will be to use scheduled apex as you are unable to run workflow on the object as desired and there is not the ability to create triggers on the object or to have a roll-up summary on partners for you to use.

You could create a trigger on opportunity and see if you have any updated information? This will only run when the opportunity is updated however and so is unlikely to provide the coverage you need. Therefore I would suggest writing a scheduled class to implement the functionality you want.

Paul

1
  • On which object/Action we write trigger,Opportunitypartner is a read only object.I want to update the Lookup whenever an partner is added to the Opportunity. Only solution i see is writing schedule Apex and Update the Opportunity records periodically. Commented Oct 9, 2012 at 9:05
0

Write a trigger on the after update of opportunity Check whether this field has changed its value =PartnerAccount

trigger PopulatePartnerOnAccountFromList on Opportunity (after update) {

for (Opportunity o : Trigger.new) {

i(o.parneraccount!= trigger.oldmap.get(o.id).partneraccount)

   OpportunityPartner[] PartnerArray =
   [select AccountToID, IsPrimary from OpportunityPartner where OpportunityId = :o.id ORDER BY isPrimary DESC, CreatedDate];
   if (PartnerArray.size() > 0) {

       o.Description = PartnerArray[0].AccountToID;

   }else{

       o.Description = null;
             }

} }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .