Results 1 to 2 of 2

Thread: How to auto calculate a custom field based on selections from two other custom fields

  1. #1
    mobileaspects is offline Junior Member
    Join Date
    Mar 2011
    Posts
    1

    Exclamation How to auto calculate a custom field based on selections from two other custom fields

    we are looking to build a "priority que" for our CS team.

    we just transferred over from salesforce, and previously we used the "case" function in the formula builder to have the field auto populated.

    The two relevant custom fields are "priority" with dropdown selections of (high, medium, low) and "Effort level" (less than one hour, less than one day, less than one week, more than one week)

    hence if the Priority was "high" and "effort level" was "less than one hour" the priority que would assign a score of "1".

    below is the formula we have used in SF... unfortunately sugar does not appear to have the "case function"
    we have the same fields in sugarCRM and have tried using the "ifElse" formula but it does not seem to be working ....

    CASE(Priority, "1 - High", CASE(Effort_Level__c, "A - Less Than 1 Hour", 1, "B - Less Than 1 Day", 3, "C - Less Than 1 Week", 4, "D - More Than 1 Week", 6, 0),"2 - Medium", CASE(Effort_Level__c, "A - Less Than 1 Hour", 2, "B - Less Than 1 Day", 7, "C - Less Than 1 Week", 8, "D - More Than 1 Week", 9, 0),"3 - Low",CASE(Effort_Level__c, "A - Less Than 1 Hour", 5, "B - Less Than 1 Day", 10, "C - Less Than 1 Week", 11, "D - More Than 1 Week", 12, 0),0)

    Can anyone help me translate this formula into something workable in SugarCRM??

  2. #2
    Editha is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    58

    Default Re: How to auto calculate a custom field based on selections from two other custom fi

    I tried to setup your example under Accounts and it works for me.

    Dropdowns in custom/Extension/application/Ext/Language/en_us.priority.php
    <?php
    $app_list_strings['tpriority_dom'] =
    array (
    '1' => '1 - High',
    '2' => '2 - Medium',
    '3' => '3 - Low',
    );
    $app_list_strings['teffort_level_dom'] =
    array (
    'A' => 'A - Less Than 1 Hour',
    'B' => 'B - Less Than 1 Day',
    'C' => 'C - Less Than 1 Week',
    'D' => 'D - More Than 1 Week',
    );
    ?>

    Fielddefinitions in custom/Extension/modules/Accounts/Ext/Vardefs/sugarfield_priority_que.php
    <?php
    $dictionary['Account']['fields']['tpriority']= array(
    'name' => 'tpriority',
    'type' => 'enum',
    'options' => 'tpriority_dom',
    );

    $dictionary['Account']['fields']['teffort_level']= array(
    'name' => 'teffort_level',
    'type' => 'enum',
    'options' => 'teffort_level_dom',
    );

    $dictionary['Account']['fields']['priority_que']= array(
    'name' => 'priority_que',
    'type' => 'varchar',
    'calculated' => true,
    'formula' =>
    'ifElse(
    and(equal($tpriority,"1"),equal($teffort_level,"A" )),"1",
    ifElse(
    and(equal($tpriority,"1"),equal($teffort_level,"B" )),"3",
    ifElse(
    and(equal($tpriority,"1"),equal($teffort_level,"C" )),"4",
    ifElse(
    and(equal($tpriority,"1"),equal($teffort_level,"D" )),"6",
    ifElse(
    and(equal($tpriority,"2"),equal($teffort_level,"A" )),"2",
    ifElse(
    and(equal($tpriority,"2"),equal($teffort_level,"B" )),"7",
    ifElse(
    and(equal($tpriority,"2"),equal($teffort_level,"C" )),"8",
    ifElse(
    and(equal($tpriority,"2"),equal($teffort_level,"D" )),"9",
    ifElse(
    and(equal($tpriority,"3"),equal($teffort_level,"A" )),"5",
    ifElse(
    and(equal($tpriority,"3"),equal($teffort_level,"B" )),"10",
    ifElse(
    and(equal($tpriority,"3"),equal($teffort_level,"C" )),"11",
    ifElse(
    and(equal($tpriority,"3"),equal($teffort_level,"D" )),"12","0"
    )))) )))) ))))',

    'enforced' => true
    );
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 2011-10-14, 06:24 AM
  2. Replies: 12
    Last Post: 2011-07-12, 10:54 AM
  3. Auto-filling fields in custom Module field not working.
    By bharat12345 in forum Developer Help
    Replies: 3
    Last Post: 2010-12-20, 01:28 PM
  4. Replies: 6
    Last Post: 2010-10-15, 04:37 PM
  5. Replies: 4
    Last Post: 2007-04-03, 02:27 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •