Forums › Forums › OroCRM › OroCRM – How do I? Questions › Summarize fields values
This topic contains 8 replies, has 2 voices, and was last updated by Yevhen Shyshkin 9 years, 2 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- December 15, 2014 at 1:03 am #28274
Hello,
For Opportunity I created two custom fields (“Сost of a license” and “Cost of implementing”).
How to automatically summarize values of these fields, and write it into “Budget amount” fild?
Data type of these custom fields is “money”.
Value of “Budget amount” must be changed every time when changing value at least one of these custom fields. - CreatorTopic
- AuthorReplies
- December 15, 2014 at 6:48 am #28275
Hello, Igor.
You can use processes to implement this functionality. You should create one process that will listen to Opportunity update and check whether your two fields are defined in change set, and if they are there then update sum.
December 18, 2014 at 2:44 am #28276You should create one process that will listen to Opportunity update and check whether your two fields are defined in change set, and if they are there then update su
Yevhen, do you mean I have to use Listener?
Whether it is possible to implement in YML-files by setting workflow for Opportunity?December 18, 2014 at 3:33 am #28277> Yevhen, do you mean I have to use Listener?
I meant that you can create custom process to refresh your field. Here is example.Well, you can use listener too. In fact processes impelemented as a listener, so there is not much difference between these two approaches.
> Whether it is possible to implement in YML-files by setting workflow for Opportunity?
No sure what you mean by that… Workflow is used to manipulate entity data via transitions. In your case it would be better to create process and use it to handle updates. Here is example of existing process.December 22, 2014 at 10:57 am #28278I’m sorry, but could you give an example of summing the two values?
December 23, 2014 at 4:28 am #28279Here is example of such process. Of course, it doesn’t have any sense from business poin of view, but it should be just fine as a demonstraction of such functionality.
12345678910111213141516171819202122232425262728293031323334353637definitions:sum_opportunity_definition:label: 'Contact Definition'enabled: trueentity: OroCRM\Bundle\SalesBundle\Entity\Opportunityactions_configuration:- @assign_value:[$.sum, []]- @assign_value:conditions:@not_empty: $budgetAmountparameters:['$.sum[0]', $budgetAmount]- @assign_value:conditions:@not_empty: $closeRevenueparameters:['$.sum[1]', $closeRevenue]- @call_method:conditions:@not_empty: $.sumparameters:attribute: $budgetAndRevenuemethod: 'array_sum'method_parameters: [$.sum]triggers:sum_opportunity_definition:-event: create-event: updatefield: budgetAmount-event: updatefield: closeRevenueDecember 23, 2014 at 5:28 am #28280Notice: If you don’t know how to perform some action you can always create your own action, register it and use it in your configuration.
January 26, 2015 at 3:42 pm #28281Yevhen,
thanks you for good example. It works!
But now I have another problem :(
This process works on our test installation, but do not works on production installation. Both installations have same version of oro/platform — 1.3.0.
How can I debug this problem?January 27, 2015 at 2:41 am #28282First – you should check whether this process is loaded and enabled – you can check that in menu System > Processes.
Second – you can set breakpoint into Oro\Bundle\WorkflowBundle\EventListener\ProcessCollectiorListener and check whether process is scheduled and executed.
Third – you should clear cache because data about enabled processes is stored there.
- AuthorReplies
The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.