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 Reply Children
  • The default sugar field was a text field which I ended up changing recently. It is now an integer field. There is no way the field can contain regular characters now. I made sure to change that before starting this whole process. 

  • 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