Calculating other calculated fields

Hello All,
Thank you in advance! I have poured over https://suitecrm.com/wiki/index.php/Userguide#Advanced_Open_Workflow to try and understand my challenge. I have not found anything specific so here it goes…

I have 5 custom fields in a module that hold a numeric value entered by the user. The workflow I built takes each field and multiplies the value of that field against a static number. example: {multiply({P0};6)}. Each answer goes into it’s own field in a new section of the module.

The second step of the process involves taking the results of the 5 calculated fields and adding them together to get a “grand total” number in my last field. here is my formula: {add({P0};{P1};{P2};{P3};{P4})} certainly not complicated.

The problem I’m having is it will only add P0 and P1 and display the answer. Thus I’m missing values from 3 other fields P2-P4.

Can you only add the value from 2 fields at a time? What am I missing? I’m trying to add a couple screen shots but the “add file” button is not functioning at the moment.

Here is a copy and paste from each workflow.

Select Action: Name: Process One
Parameters
Field name Value type Identifier
Total Face to Face Raw value {P0}
Total Voice Contacts Raw value {P1}
Total Emails with Responses Raw value {P2}
Total Referrals - New Raw value {P3}
Total Referrals - Existing Raw value {P4}

Formulas
Field name Formula
Total Points - Face to Face
{multiply({P0};6)}
Total Points - Voice Contacts
{multiply({P1};5)}
Total Points - Emails
{multiply({P2};4)}
Total Points - New Referrals
{multiply({P3};2)}
Total Points - Existing Referrals
{multiply({P4};1)}

Select Action: Name:Process 2

Parameters
Field name Value type Identifier
Total Points - Face to Face Raw value {P0}
Total Points - Voice Contacts Raw value {P1}
Total Points - New Referrals Raw value {P2}
Total Points - Existing Referrals Raw value {P3}
Total Points - Emails Raw value {P4}

Formulas
Field name Formula
Total Weekly Points
{add({P0};{P1};{P2};{P3};{P4})}
Add formula

Hi, I never used this, but… the Guide states clearly that “add” is a function that takes only two parameters:

https://suitecrm.com/wiki/index.php/Userguide#Mathematical_functions

So you could try adding like so:

total=P0
total = total + P1
total = total + P2
total = total + P3
total = total + P4
etc

Good luck with your efforts

1 Like

I appreciate the reply. I know the examples given in the guide show only 2 parameters…odd that it would not take more. I will give your suggestions a try for sure. thanks again for your reply

IT only Allows Adding 2 Fields at a time so the Solution is to write it in such a way that it considers the addition of the first 2 as a single entity and then adds again

add({add({add({add({add({P0};{P1})};{P2})};{P3})};{P4})};{P5})

This is how the Formula should look like to add all P0 to P5, well i added 6 parameters, in case it should be 5 but yous should get the General Idea.

1 Like

Hello Darkey and others,
I see you have very good idea on calculated fields and hope if possible you can help us too.

We have added a field called inventory count in Products and we wanted to reduce the inventory with every single invoice generated for respective products.

What we have done is as follows
Workflow Module = Products
Status = Active
Run: Only on Save
Run on : All records
Repeated Runs: Yes (Checked)

Conditions:
Module - Invoices: Invoices
Field: Date Modified
Operator: Equal To
Type: Any Change

Actions:
Select Action: Calculated Fields
Parameters
Inventory Raw Value {P0}

Relation Parameters
Line Items : Line Items Quantity Raw value {R0}

Formulas
Inventory:
{subtract{{P0};{R0}}

Attached Snapshot of Actions

Is it possible if you can really guide us, we will be highly obliged. Thanks a lot for support and co-operation.