Get all audit recordes for a module with Sugar Query?!

Is it possible to get all audit records for a specific module, Similar to a database query to load the table. Not only the ones linked to specific record.

What is the sugar query equivalent of this MySQL call;

SELECT *

FROM accounts_audit

Best regards

Gustav Lindstrom

Parents
  • 1) For example, you need get audit for module Accounts:

    $bean = new Account();

    $bean->retrieve($id); //audit log only for record

    $audit = new Audit();

    $audit_for_module = $audit->getAuditLog($bean);

    2) By custom query:

    $auditTable = 'Account';

    $query = "SELECT {$auditTable}.*

      FROM {$auditTable}

      ORDER BY {$auditTable}.date_created DESC";

    $db = DBManagerFactory::getInstance();

    $results = $db->query($query);


  • Not sure if I understand the answer, non of the alternatives is utilizing sugarquery. The second one seem to be loading the accounts table not the accounts_audit table?!

  • Gustav Lindström написал(а):

    ...The second one seem to be loading the accounts table not the accounts_audit table?!

    Yeah.. sorry.

    $auditTable = 'accounts_audit';

  • I've found this, it will load audit info for one record with sugar query.

            $this->requireArgs($args,array('module', 'record'));

            $focus = BeanFactory::getBean($args['module'], $args['record']);

            if (!$focus->ACLAccess('view')) {

                throw new SugarApiExceptionNotAuthorized('no access to the bean');

            }

            $auditBean = BeanFactory::newBean('Audit');

            return array(

                'next_offset' => -1,

                'records' => $auditBean->getAuditLog($focus),

            );

Reply
  • I've found this, it will load audit info for one record with sugar query.

            $this->requireArgs($args,array('module', 'record'));

            $focus = BeanFactory::getBean($args['module'], $args['record']);

            if (!$focus->ACLAccess('view')) {

                throw new SugarApiExceptionNotAuthorized('no access to the bean');

            }

            $auditBean = BeanFactory::newBean('Audit');

            return array(

                'next_offset' => -1,

                'records' => $auditBean->getAuditLog($focus),

            );

Children
No Data