3

In our CiviCRM instance, the value of a some contact custom field can be retrieved by calling an external API.

So I implemented hook_civicrm_summaryActions. If the user clicks on a custom action I added, a popup form appears with the generated result (or error messages). The external API is called, and the result is saved in our custom field.

If the user then clicks 'OK', the form disappears, so the contact summary is shown again, but the value in the custom field is not updated until the user reloads the page in his browser.

Is anyone aware of a way to make the 'calling' page refresh after the user clicks 'ok'? Another option would be to replace the popup form by an ordinary full screen form (anybody knows how to do that for a summary action?), and redirect after the form has been submitted. Or maybe there are better ways to achieve my goal than with summary actions.

Any suggestion is much appreciated.

Thx, Johan

  • Add some JS, with a call to location.reload() in the onclick event of the OK button? – naomi Dec 7 '16 at 15:32
1

I know this is like two years later but I just went through a really similar problem and there's no answer here yet...

First off Coleman posts a good answer here for lots of situations: Can I update/requery a custom field that got changed via another field on the same page?

I couldn't get this to work with certain ajax-y elements like the "disable" button under the relationships tab (we had a tab of custom fields that calculate values from other contacts based on relationships, when those relationships aren't active the data recalculates and we want it to display current values).

I worked around this by adding a JS file in hook_civicrm_summary, where the JS asks our custom data to reload every time you click the tab, so you always get current values at a slight performance cost. I'd imagine you could do this with an inline header as well:

  CRM.$(function($) {
    $('#ui-id-22').click(function(){
      CRM.refreshParent($('#Site_Demographics_1_2760'));
    });
  });

Where '#ui-id-22' was our tab link and '#Site_Demographics_1_2760' was the panel we wanted to update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.