How to fetch all records from Account Module and also updating a field value in all record

Hi Folks,

I want to get All records from Accounts Module and want to do some manipulation on that data.

Once it is done then i will update the data to same record.

How to do this bulk operation read and update the all records.

Thanks in Advance

Regards

John

Parents
  • Hi Follow John

    You can do it by both ways SQLQuery or SugarQuery.

    Using SQLQuery to do so:

    follow this link.

    Using sugarQuery to do so:

    $bean = BeanFactory::getBean('Accounts');
    $query = new SugarQuery();
    $query->from($bean, array('team_security' => false));
    $query->where()->equals('deleted', '0');
    $account_list = $query->execute();     
    if ( $account_list != null ) {
       foreach ($account_list as $acct) {               
         $accounts = new Account();
         $accounts->retrieve($acct->id);
         $accounts->name = 'Updating by Ramana';
         $accounts->save();
       }
    }

    Hope this Helps..!!

    Best Regards

    S Ramana Raju

Reply
  • Hi Follow John

    You can do it by both ways SQLQuery or SugarQuery.

    Using SQLQuery to do so:

    follow this link.

    Using sugarQuery to do so:

    $bean = BeanFactory::getBean('Accounts');
    $query = new SugarQuery();
    $query->from($bean, array('team_security' => false));
    $query->where()->equals('deleted', '0');
    $account_list = $query->execute();     
    if ( $account_list != null ) {
       foreach ($account_list as $acct) {               
         $accounts = new Account();
         $accounts->retrieve($acct->id);
         $accounts->name = 'Updating by Ramana';
         $accounts->save();
       }
    }

    Hope this Helps..!!

    Best Regards

    S Ramana Raju

Children