Answers.Body: <p>The contact summary screen is divided into different panes, and they are each refreshed separately. If a popup form needs to refresh one or more panes, it can specify them by jQuery selector. For example, the relationship form has this in its post-process function:</p>
  
  <pre><code>$this-&gt;ajaxResponse['reloadBlocks'] = array('#crm-contactinfo-content');
  </code></pre>
  
  <p>Which has the effect of refreshing the pane that contains, among other things, the current employer (which the relationship form may affect).</p>
  
  <p>When you implement this in your form hook it will look like:</p>
  
  <pre><code>function ccas_hooks_civicrm_postProcess($formName, &amp;$form){
    if ($formName == 'CRM_Contact_Form_Inline_CustomData') {
      $form-&gt;ajaxResponse['reloadBlocks'][] = '#crm-contactinfo-content';
    }
  }
  </code></pre>
  
  <p>Or substitute/add the jQuery selectors of whichever other blocks you'd like to see refreshed. Note that this code uses the array append syntax rather than overwriting the entire array.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-31T00:26:14.263Z
Answers.Text: I wasn't really trying to target the main contact edit form.  I blindly copied some of the code I used for hooks_civicrm_validateForm, which does need to target both.
Answers.UserDisplayName: Paul-Tahoe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-31T01:15:14.120Z
Answers.Text: Thank you for an answer and excellent example.  Unfortunately, one can not just stick the $this->ajaxResponse... in the hooks code.  $this is not in object context.  In the example, it's used in a function within a class.  Since the example is extending CRM_Core_Form, I'd try the same thing but alas it complained of not finding class CRM_Core_Form.  I would have been surprised if it had worked.  Clearly, I could do the exact same thing by creating a custom form and adding the post thing, but it seems like a lot of work and maintenance
Answers.UserDisplayName: Paul-Tahoe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-31T01:53:06.360Z
Answers.Text: The variable `$form` gets passed into form-related hooks, which is a copy of the form object, so just change the code to `$form->ajaxResponse...`
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-31T04:10:11.807Z
Answers.Text: Ah, thank you, thank you.  I didn't see the forest for the trees.  It was right there in front of me.
Answers.UserDisplayName: Paul-Tahoe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-29T21:58:05.413Z
Answers.LastActivityDate: 2015-03-31T13:25:28.260Z
Answers.LastEditDate: 2015-03-31T13:25:28.260Z
Answers.UserDisplayName: Coleman
Body: <p>I created some database triggers that update a read only custom field that is displayed on the main contacts page.  You change the value in another field and the db triggers update the custom field.  </p>
  
  <p>So how do I get that read only field to be refreshed with the new value or, at the very least, just refresh the entire page?</p>
  
  <p>The civicrm ajax wiki page suggests CRM.refreshParent so I tried to put that in a post processing hook</p>
  
  <pre><code>function ccas_hooks_civicrm_postProcess($formName, &amp;$form){
      if ( $formName == 'CRM_Contact_Form_Contact' or  $formName ==   
               'CRM_Contact_Form_Inline_CustomData') {
          CRM.refreshParent;}
  }
  </code></pre>
  
  <p>Of course, that didn't work.  I ended up with following two error messages</p>
  
  <p>Notice: Use of undefined constant CRM - assumed 'CRM' in ccas_hooks_civicrm_postProcess() (line 300 of ...</p>
  
  <p>Notice: Use of undefined constant refreshParent - assumed 'refreshParent' in ccas_hooks_civicrm_postProcess() (line 300...</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-29T17:02:56.900Z
Comments.Text: It looks like you are confusing javascript with PHP. `CRM.refreshParent` is a javascript function.
Comments.UserDisplayName: Coleman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-29T22:00:28.933Z
Comments.Text: Note: database triggers are normally aggregated by CiviCRM to get around the 1-trigger-per-table limit imposed by MySQL. So manually creating them might cause trouble.
Comments.UserDisplayName: Coleman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-31T00:22:31.390Z
Comments.Text: Excellent point about triggers.  I believe the hook_civicrm_trigger_info (http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_trigger) allows one to add custom triggers logic that gets compiled into the core triggers.
Comments.UserDisplayName: Paul-Tahoe
Tags: <hooks><ajax>
Title: Can I update/requery a custom field that got changed via another field on the same page?
ThreadText: # Can I update/requery a custom field that got changed via another field on the same page?
  
  (Asked by: username_0 on 2015-03-28)
  
  I created some database triggers that update a read only custom field that is displayed on the main contacts page. You change the value in another field and the db triggers update the custom field.
  
  So how do I get that read only field to be refreshed with the new value or, at the very least, just refresh the entire page?
  
  The civicrm ajax wiki page suggests CRM.refreshParent so I tried to put that in a post processing hook
  
  ```
  function ccas_hooks_civicrm_postProcess($formName, &$form){
      if ( $formName == 'CRM_Contact_Form_Contact' or  $formName ==   
               'CRM_Contact_Form_Inline_CustomData') {
          CRM.refreshParent;}
  }
  
  ```
  
  Of course, that didn't work. I ended up with following two error messages
  
  Notice: Use of undefined constant CRM - assumed 'CRM' in ccas\_hooks\_civicrm\_postProcess() (line 300 of ...
  
  Notice: Use of undefined constant refreshParent - assumed 'refreshParent' in ccas\_hooks\_civicrm\_postProcess() (line 300...
  
  **Tags:** hooks, ajax
  
  > **Comments:**
  > **username_1**: It looks like you are confusing javascript with PHP. `CRM.refreshParent` is a javascript function.  
  > **username_1**: Note: database triggers are normally aggregated by CiviCRM to get around the 1-trigger-per-table limit imposed by MySQL. So manually creating them might cause trouble.  
  > **username_0**: Excellent point about triggers.  I believe the hook_civicrm_trigger_info (http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_trigger) allows one to add custom triggers logic that gets compiled into the core triggers.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-03-29. Score: 3 | Accepted answer
  
  The contact summary screen is divided into different panes, and they are each refreshed separately. If a popup form needs to refresh one or more panes, it can specify them by jQuery selector. For example, the relationship form has this in its post-process function:
  
  ```
  $this->ajaxResponse['reloadBlocks'] = array('#crm-contactinfo-content');
  
  ```
  
  Which has the effect of refreshing the pane that contains, among other things, the current employer (which the relationship form may affect).
  
  When you implement this in your form hook it will look like:
  
  ```
  function ccas_hooks_civicrm_postProcess($formName, &$form){
    if ($formName == 'CRM_Contact_Form_Inline_CustomData') {
      $form->ajaxResponse['reloadBlocks'][] = '#crm-contactinfo-content';
    }
  }
  
  ```
  
  Or substitute/add the jQuery selectors of whichever other blocks you'd like to see refreshed. Note that this code uses the array append syntax rather than overwriting the entire array.
  
  > **Comments:**
  > **username_0**: I wasn't really trying to target the main contact edit form.  I blindly copied some of the code I used for hooks_civicrm_validateForm, which does need to target both.  
  > **username_0**: Thank you for an answer and excellent example.  Unfortunately, one can not just stick the $this->ajaxResponse... in the hooks code.  $this is not in object context.  In the example, it's used in a function within a class.  Since the example is extending CRM_Core_Form, I'd try the same thing but alas it complained of not finding class CRM_Core_Form.  I would have been surprised if it had worked.  Clearly, I could do the exact same thing by creating a custom form and adding the post thing, but it seems like a lot of work and maintenance  
  > **username_1**: The variable `$form` gets passed into form-related hooks, which is a copy of the form object, so just change the code to `$form->ajaxResponse...`  
  > **username_0**: Ah, thank you, thank you.  I didn't see the forest for the trees.  It was right there in front of me.  
  
  ---
  
  