How to create calculated field by using a field from another module.

Hello,

I am trying to implement a calculated field in the Meetings module which has the sole purpose to show a 'Score' i.e. 1,2,3,4 etc... 

The calculation behind this field derives from the number of employees for an organisation in our Accounts module. 

So in more simpler terms;

If an Account has less than 500 employees, then the 'Score' field in the meetings module has to have a value of '1'. If an Account has between 501-1000 employees, then the 'Score' field in the meetings module has to have a value of '2'.

... and so on.

I hope this makes sense and would appreciate some feedback on this. 

Thanks.

Regards,

Punit Desai.

sugar 9.0.2

calculated field

Parents
  • Hi Punit,

    To give the best guidance, can you clarify how you are tracking the number of employees on the account record? Are you using the stock 'Employees' field or a custom field? If you are using a custom field, what field type (e.g. text, integer, etc.) is associated with the field? The stock 'Employees' field is a text field so there is no guarantee that the value in the field will be numeric. If you are using the 'Employees' field or a custom text field, what score would you want associated if the field contains non-numeric values?

  • Hi Punit,

    You can achieve this scoring in the Meetings module with the following calculation:

    ifElse(
       not(
          greaterThan(
             related($accounts,"employees"), 500
          )
       ),
       1,
       ifElse(
          not(
             greaterThan(
                related($accounts,"employees"), 1000
             )
          ),
          2,
          ifElse(
             not(
                greaterThan(
                   related($accounts,"employees"), 2000
                )
             ),
             3,
             4
          )
       )
    )

    Using not() with greaterThan() creates the same effect as a "less than or equal to" formula. If the employee number is greater than the number evaluated, the false condition of ifElse() evaluates the upper limit of the next scoring tier. This formula also assumes you are evaluating against the native Accounts <-> Meetings relationship and would only function if the meeting record is related to the account through the stock flex relate field. If you have a custom relationship between the 2 modules to always capture the related account, then modify the $accounts variable accordingly. 

    I hope this helps!

    Chris

  • Much appreciated there Chris. Works like a charm!  

    Thank you! 

Reply Children
No Data