function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kate StarostinaKate Starostina 

How to update the standard Opportunity "Amount " field from custom object?

We have implemented a third party quoting tool.  When you create quotes for an opportunity you have the choice to mark one quote as the main quote.  I need that quote's extended price to be in the "Amount" field on the Opportunity so that it is included in our forecasts.  Any ideas?  If I try a workflow rule, the Opportunity and the custom Quote object don't seem to be related so that I can't do a field update.  Completely stuck!  TIA.
sandeep sankhlasandeep sankhla
Hi ,

You can simply have a small trigger to do this...
 
Quotetrigger on Quote(after insert)
{

           List<Opportunity> lstOpptToUpdate = new List<Opportunity>();
		   
              for(Quote obj : trigger.new)
            {
				if(obj.checkbox = true) {
                 Opportunity objOppt = new Opportunity(Id = obj.OpportunityId);
				 objOppt.Amount = obj.extendedPrice;
				 lstOpptToUpdate.add(objOppt);
				 }
            }
			
			
			update lstOpptToUpdate;
}

you can write a small trigger where in if condition you can check which quote value you need to updaet in parent opportunity...if that is main quote then you can simply update parent opportunity amount..

Please check this and let me know if it helos yoiu..

thanks,
Sandeep
sandeep sankhlasandeep sankhla
Hi Kate,

I haev one question, what is the relationship bewten custom Quote Object and the Opportunity ? how you will identify which quote amount should be updated to which opportunity...please let me know thee so I can help you out..

 
Kate StarostinaKate Starostina
Hi Sandeep, Quote Object is linked to the Opportunity by the Opportunity Name field (look up relationship).  When I try to do a workflow rule on the Quote Object, I can't select the Opportunity Object fields for my field update??
sandeep sankhlasandeep sankhla
Hi,

You can use above mentioned trigger for the same....we can not update lookup field from workflow...you can make use of trigger wgoch I have shared that will do the job..

thanks,
sandeep
Kate StarostinaKate Starostina
Thank you Sandeep.  I don't want to update a look up field.  I want to update the Amount field on the Opportunity based on the Extended price of the Quote.  I know nothing about triggers and wouldn't know where to start.  I was hoping to use workflow.  Thanks.
sandeep sankhlasandeep sankhla
Yes Kate,

Same trigger will do this job..lookup firld means related opportunity field...

Please ue above trigger and let me know if it helps..