Calculated Fields not updating on $bean->save()

Hi all.

I've been racking my brain on this one now, I tried $bean->updateCalculatedFields(); but it's not working. Currently I am filling in missing records, so I am creating: Lead -> Contact/Account -> Opportunity -> Meeting, they all have a "unique" ID between them that is generated. On all modules apart from the Lead it is a calculated field. But when adding the links between the modules and doing a $bean->save() it's not actually adding the calculated fields in.

I tried another save after the fact as well but had no luck. Here's an example of the creation:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//Create Account
$account = BeanFactory::newBean('Accounts');
$account->customer_salutation_c = $title;
$account->customer_first_name_c = $firstName;
$account->customer_last_name_c = $lastName;
$account->first_name_c = $firstName;
$account->last_name_c = $lastName;
$account->name = "$firstName $lastName ($firstName $lastName)"; //This matches formula on leads
$account->gender_c = $gender;
$account->date_of_birth_c = $dateOfBirth;
$account->age_c = $age;
$account->billing_address_street = $street;
$account->billing_address_city = $town;
$account->billing_address_state = $county;
$account->billing_address_postalcode = $postCode;
$account->phone_home_c = $phone;
$account->phone_mobile_c = $mobile;
$account->email1 = $email;
//$account->a_branch_accounts_name = $branch; //Should link branches automatically
$account->created_by = 1;
$account->save();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thanks!

Parents
  • Hi, 

    to be sure. After the relationhip adds did you put a $contact->updateCalculatedFields(); $account->updateCalculatedFields() before you hit save and that didn't work? Even when you dit it after the current saves on lines 100, 101 and adding 'extra' saves? 

  • Hi Jeroen. 

    Yep I've tried that I'm afraid, I am doing it via an entry point so not sure if that conforms to different practices?

Reply Children