Answers.Body: <p>I'm not familiar with this hook, but <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_trigger_info/" rel="nofollow noreferrer">the manual</a> seems to suggest that <code>OLD.column_name</code> and <code>NEW.column_name</code> can be used to access old and new values respectively.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T18:53:03.417Z
Answers.Text: You are correct its working now;
Answers.UserDisplayName: ManiMuthuPandi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T14:17:57.563Z
Answers.LastActivityDate: 2017-07-05T14:17:57.563Z
Answers.UserDisplayName: universalhandle
Body: <p>I have created below hook for trigger some values in my table.</p>
  
  <p>Here how to get source table values that are being updated or inserted</p>
  
  <pre><code>function history_civicrm_triggerInfo(&amp;$info, $tableName) {
    $sourceTable = 'civicrm_membership_log';
  
    $sql = "
      INSERT INTO `civicrm`.`civicrm_membershipperiod` 
  (`id`, `membership_id`, `start_date`, `end_date`) VALUES (NULL, '1', '2017-07-03', '2018-07-03');";
  
  
    $info[] = array(
        'table' =&gt; $sourceTable,
        'when' =&gt; 'AFTER',
        'event' =&gt; 'INSERT',
        'sql' =&gt; $sql,
    );
    $info[] = array(
        'table' =&gt; $sourceTable,
        'when' =&gt; 'AFTER',
        'event' =&gt; 'UPDATE',
        'sql' =&gt; $sql,
    );
  }
  </code></pre>
  
  <p>Based on the source table value I have to rewrite the query <code>$sql</code></p>
  
Tags: <hooks>
Title: get source table values in civicrm_triggerInfo
ThreadText: # get source table values in civicrm_triggerInfo
  
  (Asked by: username_0 on 2017-07-04)
  
  I have created below hook for trigger some values in my table.
  
  Here how to get source table values that are being updated or inserted
  
  ```
  function history_civicrm_triggerInfo(&$info, $tableName) {
    $sourceTable = 'civicrm_membership_log';
  
    $sql = "
      INSERT INTO `civicrm`.`civicrm_membershipperiod` 
  (`id`, `membership_id`, `start_date`, `end_date`) VALUES (NULL, '1', '2017-07-03', '2018-07-03');";
  
    $info[] = array(
        'table' => $sourceTable,
        'when' => 'AFTER',
        'event' => 'INSERT',
        'sql' => $sql,
    );
    $info[] = array(
        'table' => $sourceTable,
        'when' => 'AFTER',
        'event' => 'UPDATE',
        'sql' => $sql,
    );
  }
  
  ```
  
  Based on the source table value I have to rewrite the query `$sql`
  
  **Tags:** hooks
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-07-05. Score: 1 | Accepted answer
  
  I'm not familiar with this hook, but [the manual](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_trigger_info/) seems to suggest that `OLD.column_name` and `NEW.column_name` can be used to access old and new values respectively.
  
  > **Comments:**
  > **username_0**: You are correct its working now;  
  
  ---
  
  