SuiteCRM Index and Index Event

Hi all,

What is main difference between Index and Index Event. Why it is present in Role.

Hi @owatheowais,

The Index Event module is used by the Index module to record the result/status of an indexation attempt.

Usage example: code snippet from AOD_Index module
    public function index($module, $beanId)
    {
        try {
            if (!$this->isEnabled()) {
                return;
            }
            if (empty($GLOBALS['beanList'][$module])) {
                return false;
            }
            $bean_name = $GLOBALS['beanList'][$module];
            $bean = new $bean_name();
            if (!$bean || ! $bean instanceof SugarBean) {
                return false;
            }

            if (!self::isModuleSearchable($module, BeanFactory::getObjectName($module))) {
                return false;
            }

            $bean = $bean->retrieve($beanId);
            if (!$bean) {
                return false;
            }

            $indexEvent = $this->getIndexEvent($module, $beanId);
            $indexEvent->name = $bean->get_summary_text();

            $document = $this->getDocumentForBean($bean);
            //Index name, id, date, filename
            if (!$document['error']) {
                $this->remove($module, $beanId);
                $this->getLuceneIndex()->addDocument($document['document']);
                $indexEvent->success = true;
            } else {
                $indexEvent->success = false;
                $indexEvent->error = $document['error'];
            }
            $indexEvent->save();
        } catch (Exception $ex) {
            $GLOBALS['log']->error($ex->getMessage());
            return false;
        }
        return true;
    }

Regarding:

Why it is present in role

Its kind of standard module behavior to be able to configure it in roles. Though there are some exceptions.

When configuring permissions for the Index module I would add exactly the same permissions for the Index Event module also. Think that is what makes the most sense. However, you may have specific needs and may want to configure it in another way.

Hope this helps

2 Likes