Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Highlighted
Copper Contributor
Posts: 6
Registered: ‎07-31-2014
Accepted Solution

Pulling data from the OpportunityProduct into Opportunity.

My client is wanting to pull data from the OpportunityProduct fields into the Opportunity screen.

 

Is this possible? I know that the sum of the calculated price is brought across as SalesPotential, so it must be doable by some degree.

 

One thing my client wants to achieve is to be able to sum the price of selected products. Is this possible to do?

 

I've been working on this for a while now, and I'm running out of options on potential solutions. Any help would be greatly appreciated.

Highlighted
Bronze Super Contributor
Posts: 152
Registered: ‎02-01-2011

Re: Pulling data from the OpportunityProduct into Opportunity.

Option one: you could set up a SQL view to provide the necessary calculations and import the view to SLX as a one-to-one relationship with Opportunity. You would first need to activate the view using the Database Manager through the administrator, then add it as an entity using App Architect. This method has the advantage of always having current values and current calculations. The disadvantage is in maintenance and having to manage SQL code outside of the SLX management tools.

 

Option two: you could set up a business rule to retrieve the necessary data and push a calculated value into a custom field, and run it on opportunity insert/update and opportunity product insert/update/delete. This method has the advantage of handling everything using SLX tools, so you can bundle it and maintain it as part of an SLX project. The disadvantage is the fact that calculations only occur on record changes, so data can become out of sync.

Andy Freeman
TrellisPoint, LLC
Highlighted
Copper Elite Contributor
Posts: 40
Registered: ‎03-31-2010

Re: Pulling data from the OpportunityProduct into Opportunity.

When ever I need to do something like this I just add an unbound control to the view and then a FLOC (few lines of code) on the form load event.  Since usually there aren't a huge number of opportunity products on any given opportunity iterating through the related Opporttunity Product collection is pretty quick.  I prefer this over addeing a custom property to the entity since that will be evaluated everytime the entity is retreived in the entity model whether you want to use it or not.

 

Cheers,

 

James.

James Sutton
Highlighted
Copper Contributor
Posts: 6
Registered: ‎07-31-2014

Re: Pulling data from the OpportunityProduct into Opportunity.

Thanks for all the help guys!

 

In the end I created a buisness rule method in OpportunityProduct that did all the calculations, then called the opportunity fields and saved them. the code snippets that I didn't know about are:

 

System.Collections.Generic.ICollection<Sage.Entity.Interfaces.IOpportunityProduct> allOppProducts = opportunityproduct.Opportunity.Products;

 

Which calls all opportunity products of a specified opportunity, and

 

IOpportunity opp = opportunityproduct.Opportunity;

 

which calls the opportunities related to that opportunity product.

 

Thanks again for all your help!