08-28-2014 07:19 AM
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.
Solved! Go to Solution.
09-04-2014 03:57 PM
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.
09-09-2014 05:25 PM
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.
09-12-2014 03:14 AM
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!